~liuyq0307/lava-dispatcher/support-custom-command

« back to all changes in this revision

Viewing changes to lava_dispatcher/actions/lava-test.py

  • Committer: Yongqin Liu
  • Date: 2012-03-18 09:29:27 UTC
  • Revision ID: yongqin.liu@linaro.org-20120318092927-bym30o1qe4yvnzwy
modify to use the same format as lava-test today accroding to the review command

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
 
3
 
# Copyright (C) 2011 Linaro Limited
 
3
# Copyright (C) 2011-2012 Linaro Limited
4
4
#
5
5
# Author: Paul Larson <paul.larson@linaro.org>
6
6
#
25
25
 
26
26
from lava_dispatcher.actions import BaseAction
27
27
from lava_dispatcher.client.base import OperationFailed, CriticalError
 
28
from lava_dispatcher.utils import generete_bundle_file_name
28
29
 
29
30
 
30
31
def _install_lava_test(client, session):
32
33
    session.run('apt-get update')
33
34
    #Install necessary packages for build lava-test
34
35
    cmd = ('apt-get -y --force-yes install '
35
 
           'bzr usbutils python-apt python-setuptools python-simplejson lsb-release')
 
36
           'bzr usbutils python-apt python-setuptools '
 
37
           'python-simplejson lsb-release')
36
38
    session.run(cmd, timeout=2400)
37
39
    session.run("apt-get -y --force-yes install python-pip")
38
40
 
47
49
    # cleanup the lava-test - old results, cached files...
48
50
    session.run('lava-test reset', timeout=60)
49
51
 
 
52
 
50
53
class cmd_lava_test_run(BaseAction):
51
54
 
52
55
    parameters_schema = {
59
62
        'additionalProperties': False,
60
63
        }
61
64
 
62
 
    def test_name(self, test_name, test_options = "", timeout=-1):
 
65
    def test_name(self, test_name, test_options="", timeout=-1):
63
66
        return super(cmd_lava_test_run, self).test_name() + ' (%s)' % test_name
64
67
 
65
 
    def run(self, test_name, test_options = "", timeout=-1):
 
68
    def run(self, test_name, test_options="", timeout=-1):
66
69
        logging.info("Executing lava_test_run %s command" % test_name)
67
70
        with self.client.tester_session() as session:
68
71
            session.run('mkdir -p %s' % self.context.lava_result_dir)
69
72
            session.export_display()
70
 
            bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S")
71
 
 
 
73
            bundle_name = generete_bundle_file_name(test_name)
72
74
            if test_options != "":
73
75
                test_options = "-t '%s'" % test_options
74
76
 
75
77
            cmd = ('lava-test run %s %s -o %s/%s.bundle' % (
76
 
                    test_name, test_options, self.context.lava_result_dir, bundle_name))
 
78
                    test_name, test_options, self.context.lava_result_dir,
 
79
                     bundle_name))
77
80
            try:
78
81
                rc = session.run(cmd, timeout=timeout)
79
82
            except:
89
92
            if rc is None:
90
93
                raise OperationFailed("test case getting return value failed")
91
94
            elif rc != 0:
92
 
                raise OperationFailed("test case failed with return value: %s" % rc)
 
95
                raise OperationFailed(
 
96
                        "test case failed with return value: %s" % rc)
 
97
 
93
98
 
94
99
class cmd_lava_test_install(BaseAction):
95
100
    """
111
116
        'additionalProperties': False,
112
117
        }
113
118
 
114
 
    def run(self, tests, install_python = None, register = None, timeout=2400):
115
 
        logging.info("Executing lava_test_install (%s) command" % ",".join(tests))
 
119
    def run(self, tests, install_python=None, register=None, timeout=2400):
 
120
        logging.info(
 
121
            "Executing lava_test_install (%s) command" % ",".join(tests))
116
122
 
117
123
        with self.client.reliable_session() as session:
118
124
 
136
142
class cmd_add_apt_repository(BaseAction):
137
143
    """
138
144
    add apt repository to test image rootfs by chroot
139
 
    arg could be 'deb uri distribution [component1] [component2][...]' or ppa:<ppa_name>
 
145
    arg could be 'deb uri distribution [component1] [component2][...]'
 
146
    or ppa:<ppa_name>
140
147
    """
141
148
 
142
149
    parameters_schema = {