Merge ~canonical-kernel-team/+git/autotest-client-tests:phlin/stress-smoke-bailout into ~canonical-kernel-team/+git/autotest-client-tests:master

Proposed by Po-Hsu Lin
Status: Merged
Merged at revision: 7e20ab4b4c572c857e5e0481bd19f8f91a1119c0
Proposed branch: ~canonical-kernel-team/+git/autotest-client-tests:phlin/stress-smoke-bailout
Merge into: ~canonical-kernel-team/+git/autotest-client-tests:master
Diff against target: 88 lines (+34/-21)
2 files modified
ubuntu_stress_smoke_test/control (+18/-18)
ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py (+16/-3)
Reviewer Review Type Date Requested Status
Francis Ginther Approve
Review via email: mp+457663@code.launchpad.net

Commit message

If we want to bail early (even before the testing tool installation)
base on the requirement check in ubuntu_stress_smoke_test_checks.sh,
we need to move the test build process to a new build_source(), and
handle it just like a normal job in run_once().

This is because setup() will be triggered automatically right after
test execution before anything from run_once(). We can't skip it with
anything in run_once().

And it's not ideal to run the check in setup() before building the
test, firstly is because when you try to run the test again on the
same system, setup() won't be triggered unless the test version has
been bumped or the autotest/client/tmp/ubuntu_stress_smoke directory
has been removed. Secondly we might get confused when setup() fails.

Also fix a 'test_dir' is not defined issue.

To post a comment you must log in.
Revision history for this message
Francis Ginther (fginther) wrote :

This appears to be overriding the default 'setup' with two manually specified setup routines. "setup_check" runs first to make sure this host is sufficient to run the test. Then "setup_init" runs to install and build stress-ng.

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/ubuntu_stress_smoke_test/control b/ubuntu_stress_smoke_test/control
2index a610f6c..2867596 100644
3--- a/ubuntu_stress_smoke_test/control
4+++ b/ubuntu_stress_smoke_test/control
5@@ -48,26 +48,26 @@ flavour = utils.system_output(cmd, retain_output=True)
6 if flavour == 'kvm':
7 exclude.append('dnotify')
8
9-
10-job.run_test_detail(NAME, test_name='setup-check' , tag='setup-check', timeout=5*60)
11-
12-job.run_test_detail(NAME, test_name='setup-init' , tag='setup-init', timeout=5*60)
13-
14-result = job.run_test_detail(NAME, test_name='setup', tag='setup', timeout=60*60)
15+result = job.run_test_detail(NAME, test_name='setup-check', tag='setup-check', timeout=5*60)
16 if result == 'GOOD':
17- stressng_dir = os.path.join(job.bindir, 'tmp', NAME, 'src', 'stress-ng')
18- cmd = '%s/stress-ng --stressor' % (stressng_dir)
19- stressors = utils.system_output(cmd, retain_output=True).split()
20-else:
21- print("ERROR: can't get a list of available stressors")
22- exit(1)
23+ job.run_test_detail(NAME, test_name='setup-init', tag='setup-init', timeout=5*60)
24+ # Change the test build step from "setup" to "setup-test" so it won't get confused
25+ # with the setup() that triggered automatically (which we intetionally left blank)
26+ result = job.run_test_detail(NAME, test_name='setup-test', tag='setup-test', timeout=60*60)
27+ if result == 'GOOD':
28+ stressng_dir = os.path.join(job.bindir, 'tmp', NAME, 'src', 'stress-ng')
29+ cmd = '%s/stress-ng --stressor' % (stressng_dir)
30+ stressors = utils.system_output(cmd, retain_output=True).split()
31+ else:
32+ print("ERROR: can't get a list of available stressors")
33+ exit(1)
34
35-for stress in stressors:
36- if stress not in exclude:
37- job.run_test_detail(NAME, test_name=stress , tag=stress, timeout=35*60)
38+ for stress in stressors:
39+ if stress not in exclude:
40+ job.run_test_detail(NAME, test_name=stress , tag=stress, timeout=35*60)
41
42-src_dir = os.path.dirname(job.control)
43-cmd = '%s/ubuntu_stress_smoke_test_cleanup.sh' % (src_dir)
44-utils.system_output(cmd)
45+ src_dir = os.path.dirname(job.control)
46+ cmd = '%s/ubuntu_stress_smoke_test_cleanup.sh' % (src_dir)
47+ utils.system_output(cmd)
48
49 # vi:set ts=4 sw=4 expandtab syntax=python:
50diff --git a/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py b/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py
51index 6fec4d2..12b29a2 100644
52--- a/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py
53+++ b/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py
54@@ -47,9 +47,19 @@ class ubuntu_stress_smoke_test(test.test):
55 def initialize(self):
56 pass
57
58+
59 def setup(self):
60- self.install_required_pkgs()
61- self.job.require_gcc()
62+ '''
63+ We used to run code in build_source() here. Since we want to bail out early
64+ if the requirement in ubuntu_stress_smoke_test_checks.sh does not met, we
65+ can't build source here anymore. setup() will be triggered after initalize()
66+ There is no chace to run check before setup(), this is an ugly hack we need
67+ to keep until we have a better solution.
68+ '''
69+ pass
70+
71+
72+ def build_source(self):
73 os.chdir(self.srcdir)
74 shutil.rmtree('stress-ng', ignore_errors=True)
75 cmd = 'git clone --depth=1 https://git.launchpad.net/~canonical-kernel-team/+git/stress-ng'
76@@ -75,8 +85,11 @@ class ubuntu_stress_smoke_test(test.test):
77 nprocs = ''
78 utils.make(nprocs)
79
80+
81 def run_once(self, test_name):
82- if test_name == 'setup':
83+ if test_name == 'setup-test':
84+ self.install_required_pkgs()
85+ self.build_source()
86 return
87 elif test_name == 'setup-check':
88 cmd = '%s/ubuntu_stress_smoke_test_checks.sh' % (self.bindir)

Subscribers

People subscribed via source and target branches

to all changes: