Merge lp:~javier.collado/utah/bug1178238 into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 900
Merged at revision: 898
Proposed branch: lp:~javier.collado/utah/bug1178238
Merge into: lp:utah
Diff against target: 98 lines (+55/-1)
3 files modified
debian/changelog (+1/-0)
utah/client/tests/test_testsuite.py (+43/-0)
utah/client/testsuite.py (+11/-1)
To merge this branch: bzr merge lp:~javier.collado/utah/bug1178238
Reviewer Review Type Date Requested Status
Andy Doan (community) Approve
Review via email: mp+163133@code.launchpad.net

Description of the change

This branch makes sure that the overrides are applied regardless of where they
are defined.

The changes in this branch should be merged against 0.12 as well, but I think
it's better not to do it to avoid regressions that might be caused by the
change in the behavior with regard to overrides.

To post a comment you must log in.
Revision history for this message
Andy Doan (doanac) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-05-08 22:38:01 +0000
3+++ debian/changelog 2013-05-09 12:27:26 +0000
4@@ -7,6 +7,7 @@
5 * Set reboot default to 'never' in tc_control schema (LP: #1175809)
6 * Apply retry strategy to install UTAH client package (LP: #1175732)
7 * Added phoenix manpage (LP: #1067704)
8+ * Apply all overrides in tslist.run to the test cases (LP: #1178238)
9
10 -- Javier Collado <javier.collado@canonical.com> Tue, 07 May 2013 16:06:48 +0200
11
12
13=== modified file 'utah/client/tests/test_testsuite.py'
14--- utah/client/tests/test_testsuite.py 2013-05-08 22:25:45 +0000
15+++ utah/client/tests/test_testsuite.py 2013-05-09 12:27:26 +0000
16@@ -21,6 +21,8 @@
17
18 import jsonschema
19
20+from mock import Mock, patch
21+
22 from utah.client import testsuite
23 from utah.client.common import (
24 debug_print,
25@@ -161,6 +163,47 @@
26 self.assertEqual(case.name, included_test_name)
27 self.assertNotEqual(case.name, excluded_test_name)
28
29+ @patch('utah.client.testsuite.TestCase')
30+ @patch('utah.client.testsuite.os')
31+ def test_runlist_overrides(self, suite_os, testcase):
32+ """Verify overrides when they are in their own section."""
33+ overrides = {'timeout': 1,
34+ 'build_cmd': '<build_cmd>',
35+ 'command': '<command>',
36+ 'run_as': '<username>'}
37+ suite_os.path.exists.return_value = True
38+ suite_control_data = {}
39+ suite_runlist_data = [
40+ {'test': 'test_case_name',
41+ 'overrides': overrides,
42+ }
43+ ]
44+ suite = testsuite.TestSuite(
45+ name='testsuite_name', path='test_path', result=Mock(),
46+ _control_data=suite_control_data,
47+ _runlist_data=suite_runlist_data)
48+ case = suite.tests[0]
49+ case.process_overrides.assert_called_with(overrides)
50+
51+ @patch('utah.client.testsuite.TestCase')
52+ @patch('utah.client.testsuite.os')
53+ def test_overrides_at_test_level(self, suite_os, testcase):
54+ """Verify overrides when they are in mixed with the test case name."""
55+ overrides = {'timeout': 1,
56+ 'build_cmd': '<build_cmd>',
57+ 'command': '<command>',
58+ 'run_as': '<username>'}
59+ suite_os.path.exists.return_value = True
60+ suite_control_data = {}
61+ suite_runlist_data = [{'test': 'test_case_name'}]
62+ suite_runlist_data[0].update(overrides)
63+ suite = testsuite.TestSuite(
64+ name='testsuite_name', path='test_path', result=Mock(),
65+ _control_data=suite_control_data,
66+ _runlist_data=suite_runlist_data)
67+ case = suite.tests[0]
68+ case.process_overrides.assert_called_with(overrides)
69+
70
71 class TestTestSuiteRunlistSchema(unittest.TestCase):
72
73
74=== modified file 'utah/client/testsuite.py'
75--- utah/client/testsuite.py 2013-05-08 16:01:00 +0000
76+++ utah/client/testsuite.py 2013-05-09 12:27:26 +0000
77@@ -211,11 +211,21 @@
78 battery_measurements=self.battery_measurements,
79 _save_state_callback=self.save_state_callback,
80 _reboot_callback=self.reboot_callback)
81+
82+ runlist_properties = self.RUNLIST_SCHEMA['items']['properties']
83+ override_properties = \
84+ runlist_properties['overrides']['properties'].keys()
85+ overrides = {}
86+ for property_name in override_properties:
87+ if property_name in test:
88+ overrides[property_name] = test[property_name]
89 if 'overrides' in test:
90 if self.timeout is not None:
91 test['overrides']['timeout'] = self.timeout
92+ overrides.update(test['overrides'])
93
94- tc.process_overrides(test['overrides'])
95+ if overrides:
96+ tc.process_overrides(overrides)
97
98 self.tests.append(tc)
99

Subscribers

People subscribed via source and target branches