Merge lp:~joetalbott/utah/fix_result_counts into lp:utah

Proposed by Joe Talbott
Status: Merged
Approved by: Javier Collado
Approved revision: 770
Merged at revision: 768
Proposed branch: lp:~joetalbott/utah/fix_result_counts
Merge into: lp:utah
Diff against target: 678 lines (+432/-76)
9 files modified
tests/test_parser.py (+5/-2)
utah/client/examples/test_state_partial_all_failed.yaml (+90/-0)
utah/client/examples/test_state_partial_inprogress.yaml (+90/-0)
utah/client/examples/test_state_partial_run_all.yaml (+90/-0)
utah/client/runner.py (+12/-11)
utah/client/testcase.py (+10/-5)
utah/client/tests/common.py (+27/-0)
utah/client/tests/test_state_agent.py (+102/-55)
utah/client/testsuite.py (+6/-3)
To merge this branch: bzr merge lp:~joetalbott/utah/fix_result_counts
Reviewer Review Type Date Requested Status
Joe Talbott (community) Needs Resubmitting
Javier Collado (community) Approve
Review via email: mp+137337@code.launchpad.net

Description of the change

This branch fixes the result counts for runs that involve a reboot.

To post a comment you must log in.
767. By Joe Talbott

test_state_agent - Add a few more tests for resumes.

* make sure different scenarios return the expected results.

Revision history for this message
Javier Collado (javier.collado) wrote :

I've got a couple of questions:
- What does JAT stand for? I'd prefer all those commented lines to be removed.
- Why is there a long yaml file embedded in the code? I think maintenance would be easier if the file was in a separate location on its own.

review: Needs Information
768. By Joe Talbott

testcase - Remove leftover commented out code.

769. By Joe Talbott

tests - Move YAML content into separtate files.

Revision history for this message
Joe Talbott (joetalbott) wrote :

I've removed those commented out line. I meant to do that before pushing but forgot.

I also moved the YAML content into separate files.

review: Needs Resubmitting
Revision history for this message
Javier Collado (javier.collado) wrote :

Looks nice now. Thanks!

review: Approve
Revision history for this message
Javier Collado (javier.collado) wrote :

By the way, when running the test cases, I get three errors like the one below:

======================================================================
ERROR: Failure: TypeError (__init__() takes at least 4 arguments (1 given))
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 495, in makeTest
    return self._makeTest(obj, parent)
  File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 554, in _makeTest
    return MethodTestCase(obj)
  File "/usr/lib/python2.7/dist-packages/nose/case.py", line 345, in __init__
    self.inst = self.cls()
TypeError: __init__() takes at least 4 arguments (1 given)
----------------------------------------------------------------------

I get them for the dev branch as well, so I don't think it's because of any
change here. Anyway, I'm not merging this right now just in case you want to
take a look a this issue.

770. By Joe Talbott

parser - Fix test for malformed yaml file.

Revision history for this message
Joe Talbott (joetalbott) wrote :

It was an unrelated issue, but I went ahead and fixed it here.

review: Needs Resubmitting
Revision history for this message
Javier Collado (javier.collado) wrote :

Actually, I've found that the problem was on my side when running the test
cases.

Instead of passing `utah/client/tests`, I was passing just `utah/client`. The
side effect of this was that `nosetests` believed that there were some test
cases in `utah/client/testsuite.py` and tried to execute them causing the
backtrace in my previous comment.

Anyway, merging your changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/test_parser.py'
--- tests/test_parser.py 2012-11-14 22:10:40 +0000
+++ tests/test_parser.py 2012-12-05 15:31:21 +0000
@@ -3,7 +3,7 @@
3import tempfile3import tempfile
4import unittest4import unittest
55
6from utah.parser import UTAHParser6from utah.parser import UTAHParser, ParserError
77
8MALFORMED_CONTENT = """8MALFORMED_CONTENT = """
9---9---
@@ -22,6 +22,9 @@
2222
23 self.tmpfile.write(MALFORMED_CONTENT)23 self.tmpfile.write(MALFORMED_CONTENT)
2424
25 # reset the stream for later reading.
26 self.tmpfile.seek(0)
27
25 def tearDown(self):28 def tearDown(self):
26 self.tmpfile.close()29 self.tmpfile.close()
2730
@@ -30,7 +33,7 @@
30 data = self.parser.parse(self.fakelog)33 data = self.parser.parse(self.fakelog)
3134
32 def test_malformed_file(self):35 def test_malformed_file(self):
33 with self.assertRaises(jsonschema.ValidationError):36 with self.assertRaises(ParserError):
34 data = self.parser.parse(self.tmpfile)37 data = self.parser.parse(self.tmpfile)
3538
36 def test_parser(self):39 def test_parser(self):
3740
=== added file 'utah/client/examples/test_state_partial_all_failed.yaml'
--- utah/client/examples/test_state_partial_all_failed.yaml 1970-01-01 00:00:00 +0000
+++ utah/client/examples/test_state_partial_all_failed.yaml 2012-12-05 15:31:21 +0000
@@ -0,0 +1,90 @@
1master_runlist: /var/lib/utah/master.run
2status: RUN
3result_class: !!python/name:utah.client.result.ResultYAML ''
4fetched_suites:
5- examples
6- utah_tests
7- utah_tests_sample
8suites:
9- build_cmd: null
10 name: examples
11 passes: 0
12 errors: 0
13 failures: 2
14 status: DONE
15 tests:
16 - build_cmd: echo "building for test_one"
17 command: python test_one.py
18 description: A first sample test case.
19 name: test_one
20 path: examples/test_one
21 status: DONE
22 summary: FAIL
23 tc_cleanup: echo "cleanup for test_one"
24 tc_setup: echo "setup for test_one"
25 timeout: 3
26 type: userland
27 - build_cmd: echo "building for test_two"
28 command: python test_two.py
29 description: A second sample test case.
30 name: test_two
31 path: examples/test_two
32 status: DONE
33 summary: FAIL
34 tc_cleanup: echo "cleanup for test_two"
35 tc_setup: echo "setup for test_two"
36 timeout: 300
37 type: userland
38- build_cmd: null
39 name: utah_tests
40 passes: 0
41 errors: 0
42 failures: 2
43 status: DONE
44 tests:
45 - build_cmd: echo "building for test_one"
46 command: python test_one.py
47 description: A first sample test case.
48 name: test_one
49 path: utah_tests/test_one
50 status: DONE
51 summary: FAIL
52 tc_cleanup: echo "cleanup for test_one"
53 tc_setup: echo "setup for test_one"
54 timeout: 3
55 type: userland
56 - build_cmd: echo "building for test_two"
57 command: python test_two.py
58 description: A second sample test case.
59 name: test_two
60 path: utah_tests/test_two
61 status: DONE
62 summary: FAIL
63 tc_cleanup: echo "cleanup for test_two"
64 tc_setup: echo "setup for test_two"
65 timeout: 300
66 type: userland
67 timeout: 0
68 ts_cleanup: null
69 ts_setup: null
70- build_cmd: null
71 name: utah_tests_sample
72 passes: 0
73 errors: 0
74 failures: 1
75 status: DONE
76 tests:
77 - build_cmd: echo "building for sample_one"
78 command: python sample.py
79 description: A sample test case.
80 name: sample_one
81 path: utah_tests_sample/sample_one
82 status: DONE
83 summary: FAIL
84 tc_cleanup: echo "cleanup for sample_one"
85 tc_setup: echo "setup for sample_one"
86 timeout: 200
87 type: userland
88 timeout: 0
89 ts_cleanup: null
90 ts_setup: null
091
=== added file 'utah/client/examples/test_state_partial_inprogress.yaml'
--- utah/client/examples/test_state_partial_inprogress.yaml 1970-01-01 00:00:00 +0000
+++ utah/client/examples/test_state_partial_inprogress.yaml 2012-12-05 15:31:21 +0000
@@ -0,0 +1,90 @@
1master_runlist: /var/lib/utah/master.run
2status: RUN
3result_class: !!python/name:utah.client.result.ResultYAML ''
4fetched_suites:
5- examples
6- utah_tests
7- utah_tests_sample
8suites:
9- build_cmd: null
10 name: examples
11 passes: 2
12 errors: 0
13 failures: 0
14 status: DONE
15 tests:
16 - build_cmd: echo "building for test_one"
17 command: python test_one.py
18 description: A first sample test case.
19 name: test_one
20 path: examples/test_one
21 status: DONE
22 summary: PASS
23 tc_cleanup: echo "cleanup for test_one"
24 tc_setup: echo "setup for test_one"
25 timeout: 3
26 type: userland
27 - build_cmd: echo "building for test_two"
28 command: python test_two.py
29 description: A second sample test case.
30 name: test_two
31 path: examples/test_two
32 status: DONE
33 summary: PASS
34 tc_cleanup: echo "cleanup for test_two"
35 tc_setup: echo "setup for test_two"
36 timeout: 300
37 type: userland
38- build_cmd: null
39 name: utah_tests
40 passes: 1
41 errors: 0
42 failures: 0
43 status: INPROGRESS
44 tests:
45 - build_cmd: echo "building for test_one"
46 command: python test_one.py
47 description: A first sample test case.
48 name: test_one
49 path: utah_tests/test_one
50 status: DONE
51 summary: PASS
52 tc_cleanup: echo "cleanup for test_one"
53 tc_setup: echo "setup for test_one"
54 timeout: 3
55 type: userland
56 - build_cmd: echo "building for test_two"
57 command: python test_two.py
58 description: A second sample test case.
59 name: test_two
60 path: utah_tests/test_two
61 status: SETUP
62 summary: PASS
63 tc_cleanup: echo "cleanup for test_two"
64 tc_setup: echo "setup for test_two"
65 timeout: 300
66 type: userland
67 timeout: 0
68 ts_cleanup: null
69 ts_setup: null
70- build_cmd: null
71 name: utah_tests_sample
72 passes: 0
73 errors: 0
74 failures: 1
75 status: DONE
76 tests:
77 - build_cmd: echo "building for sample_one"
78 command: python sample.py
79 description: A sample test case.
80 name: sample_one
81 path: utah_tests_sample/sample_one
82 status: DONE
83 summary: FAIL
84 tc_cleanup: echo "cleanup for sample_one"
85 tc_setup: echo "setup for sample_one"
86 timeout: 200
87 type: userland
88 timeout: 0
89 ts_cleanup: null
90 ts_setup: null
091
=== added file 'utah/client/examples/test_state_partial_run_all.yaml'
--- utah/client/examples/test_state_partial_run_all.yaml 1970-01-01 00:00:00 +0000
+++ utah/client/examples/test_state_partial_run_all.yaml 2012-12-05 15:31:21 +0000
@@ -0,0 +1,90 @@
1master_runlist: /var/lib/utah/master.run
2status: RUN
3result_class: !!python/name:utah.client.result.ResultYAML ''
4fetched_suites:
5- examples
6- utah_tests
7- utah_tests_sample
8suites:
9- build_cmd: null
10 name: examples
11 passes: 0
12 errors: 0
13 failures: 0
14 status: NOTRUN
15 tests:
16 - build_cmd: echo "building for test_one"
17 command: python test_one.py
18 description: A first sample test case.
19 name: test_one
20 path: examples/test_one
21 status: NOTRUN
22 summary: PASS
23 tc_cleanup: echo "cleanup for test_one"
24 tc_setup: echo "setup for test_one"
25 timeout: 3
26 type: userland
27 - build_cmd: echo "building for test_two"
28 command: python test_two.py
29 description: A second sample test case.
30 name: test_two
31 path: examples/test_two
32 status: NOTRUN
33 summary: PASS
34 tc_cleanup: echo "cleanup for test_two"
35 tc_setup: echo "setup for test_two"
36 timeout: 300
37 type: userland
38- build_cmd: null
39 name: utah_tests
40 passes: 1
41 errors: 0
42 failures: 0
43 status: NOTRUN
44 tests:
45 - build_cmd: echo "building for test_one"
46 command: python test_one.py
47 description: A first sample test case.
48 name: test_one
49 path: utah_tests/test_one
50 status: NOTRUN
51 summary: PASS
52 tc_cleanup: echo "cleanup for test_one"
53 tc_setup: echo "setup for test_one"
54 timeout: 3
55 type: userland
56 - build_cmd: echo "building for test_two"
57 command: python test_two.py
58 description: A second sample test case.
59 name: test_two
60 path: utah_tests/test_two
61 status: NOTRUN
62 summary: PASS
63 tc_cleanup: echo "cleanup for test_two"
64 tc_setup: echo "setup for test_two"
65 timeout: 300
66 type: userland
67 timeout: 0
68 ts_cleanup: null
69 ts_setup: null
70- build_cmd: null
71 name: utah_tests_sample
72 passes: 0
73 errors: 0
74 failures: 1
75 status: NOTRUN
76 tests:
77 - build_cmd: echo "building for sample_one"
78 command: python sample.py
79 description: A sample test case.
80 name: sample_one
81 path: utah_tests_sample/sample_one
82 status: NOTRUN
83 summary: PASS
84 tc_cleanup: echo "cleanup for sample_one"
85 tc_setup: echo "setup for sample_one"
86 timeout: 200
87 type: userland
88 timeout: 0
89 ts_cleanup: null
90 ts_setup: null
091
=== modified file 'utah/client/runner.py'
--- utah/client/runner.py 2012-11-07 18:02:22 +0000
+++ utah/client/runner.py 2012-12-05 15:31:21 +0000
@@ -251,9 +251,9 @@
251 if not keep_going:251 if not keep_going:
252 return self.process_results()252 return self.process_results()
253253
254 self.errors += suite.errors254 self.errors += suite.errors
255 self.passes += suite.passes255 self.passes += suite.passes
256 self.failures += suite.failures256 self.failures += suite.failures
257257
258 self.status = "DONE"258 self.status = "DONE"
259 self.save_state()259 self.save_state()
@@ -443,14 +443,15 @@
443443
444 self.fetched_suites.append(name)444 self.fetched_suites.append(name)
445445
446 # Create a TestSuite446 # Create a TestSuite
447 s = TestSuite(name=name, runlist_file=suite_runlist,447 s = TestSuite(name=name, runlist_file=suite_runlist,
448 includes=includes, excludes=excludes,448 includes=includes, excludes=excludes,
449 result=self.result, path=self.testsuitedir,449 result=self.result, path=self.testsuitedir,
450 timeout=self.timeout,450 timeout=self.timeout,
451 _save_state_callback=self.save_state,451 _save_state_callback=self.save_state,
452 _reboot_callback=self.reboot)452 _reboot_callback=self.reboot)
453 self.add_suite(s)453 self.add_suite(s)
454
454455
455 def get_next_suite(self):456 def get_next_suite(self):
456 """457 """
457458
=== modified file 'utah/client/testcase.py'
--- utah/client/testcase.py 2012-10-17 10:22:00 +0000
+++ utah/client/testcase.py 2012-12-05 15:31:21 +0000
@@ -27,6 +27,7 @@
27 """27 """
2828
29 status = 'NOTRUN'29 status = 'NOTRUN'
30 summary = 'PASS' # 'PASS', 'FAIL', of 'ERROR'
30 build_cmd = None31 build_cmd = None
31 tc_setup = None32 tc_setup = None
32 tc_cleanup = None33 tc_cleanup = None
@@ -181,8 +182,7 @@
181 """182 """
182183
183 if self.is_done():184 if self.is_done():
184 self.run_status = 'PASS'185 return 'PASS'
185 return self.run_status
186186
187 # Do not proceed if we are missing data187 # Do not proceed if we are missing data
188 if (self.description is None188 if (self.description is None
@@ -203,7 +203,7 @@
203203
204 # if the build fails don't run the test command204 # if the build fails don't run the test command
205 if result.status != 'PASS':205 if result.status != 'PASS':
206 self.run_status = result.status206 self.summary = 'ERROR'
207207
208 # reset status208 # reset status
209 result.status = 'PASS'209 result.status = 'PASS'
@@ -213,7 +213,7 @@
213213
214 # if the setup fails don't run the test command214 # if the setup fails don't run the test command
215 if result.status != 'PASS':215 if result.status != 'PASS':
216 self.run_status = result.status216 self.summary = 'ERROR'
217217
218 # reset status218 # reset status
219 result.status = 'PASS'219 result.status = 'PASS'
@@ -237,6 +237,11 @@
237 ),237 ),
238 extra_info=extra_info)238 extra_info=extra_info)
239239
240 # only if we haven't failed or errored so far do
241 # we set the summary for the testcase.
242 if self.summary == 'PASS':
243 self.summary = result.status
244
240 # Clean up whether 'command' failed or not.245 # Clean up whether 'command' failed or not.
241 self.cleanup(result)246 self.cleanup(result)
242247
@@ -246,7 +251,6 @@
246 and result.status == 'PASS'):251 and result.status == 'PASS'):
247 need_reboot = True252 need_reboot = True
248253
249 self.run_status = result.status
250 result.status = 'PASS'254 result.status = 'PASS'
251255
252 if self.status == 'CLEANUP':256 if self.status == 'CLEANUP':
@@ -285,6 +289,7 @@
285 'command': self.command,289 'command': self.command,
286 'timeout': self.timeout,290 'timeout': self.timeout,
287 'status': self.status,291 'status': self.status,
292 'summary': self.summary,
288 'build_cmd': self.build_cmd,293 'build_cmd': self.build_cmd,
289 'tc_setup': self.tc_setup,294 'tc_setup': self.tc_setup,
290 'tc_cleanup': self.tc_cleanup,295 'tc_cleanup': self.tc_cleanup,
291296
=== modified file 'utah/client/tests/common.py'
--- utah/client/tests/common.py 2012-10-10 14:44:00 +0000
+++ utah/client/tests/common.py 2012-12-05 15:31:21 +0000
@@ -89,3 +89,30 @@
8989
90 if os.path.exists(examples_dir):90 if os.path.exists(examples_dir):
91 shutil.rmtree(examples_dir)91 shutil.rmtree(examples_dir)
92
93def _get_partial_state_file(filename):
94 """
95 Read a partial state file from disk.
96 """
97
98 state = None
99
100 with open(filename, 'r') as fp:
101 state = fp.read()
102
103 return state
104
105partial_state_file_content = _get_partial_state_file(
106 os.path.join(os.path.dirname(__file__), "..", "examples",
107 "test_state_partial_inprogress.yaml")
108)
109
110partial_state_file_content_run_all = _get_partial_state_file(
111 os.path.join(os.path.dirname(__file__), "..", "examples",
112 "test_state_partial_run_all.yaml")
113)
114
115partial_state_file_content_done_all_failed = _get_partial_state_file(
116 os.path.join(os.path.dirname(__file__), "..", "examples",
117 "test_state_partial_all_failed.yaml")
118)
92119
=== modified file 'utah/client/tests/test_state_agent.py'
--- utah/client/tests/test_state_agent.py 2012-10-03 09:07:18 +0000
+++ utah/client/tests/test_state_agent.py 2012-12-05 15:31:21 +0000
@@ -12,60 +12,11 @@
12 setUp, # Used by nosetests12 setUp, # Used by nosetests
13 tearDown, # Used by nosetests13 tearDown, # Used by nosetests
14 get_module_path,14 get_module_path,
15 partial_state_file_content,
16 partial_state_file_content_run_all,
17 partial_state_file_content_done_all_failed,
15 )18 )
1619
17partial_state_file_content = """master_runlist: /var/lib/utah/master.run
18status: RUN
19result_class: !!python/name:utah.client.result.ResultYAML ''
20fetched_suites:
21- utah_tests
22- utah_tests_sample
23suites:
24- build_cmd: null
25 name: utah_tests
26 status: INPROGRESS
27 tests:
28 - build_cmd: echo "building for test_one"
29 command: python test_one.py
30 description: A first sample test case.
31 name: test_one
32 path: utah_tests/test_one
33 status: DONE
34 tc_cleanup: echo "cleanup for test_one"
35 tc_setup: echo "setup for test_one"
36 timeout: 3
37 type: userland
38 - build_cmd: echo "building for test_two"
39 command: python test_two.py
40 description: A second sample test case.
41 name: test_two
42 path: utah_tests/test_two
43 status: SETUP
44 tc_cleanup: echo "cleanup for test_two"
45 tc_setup: echo "setup for test_two"
46 timeout: 300
47 type: userland
48 timeout: 0
49 ts_cleanup: null
50 ts_setup: null
51- build_cmd: null
52 name: utah_tests_sample
53 status: DONE
54 tests:
55 - build_cmd: echo "building for sample_one"
56 command: python sample.py
57 description: A sample test case.
58 name: sample_one
59 path: utah_tests_sample/sample_one
60 status: DONE
61 tc_cleanup: echo "cleanup for sample_one"
62 tc_setup: echo "setup for sample_one"
63 timeout: 200
64 type: userland
65 timeout: 0
66 ts_cleanup: null
67 ts_setup: null
68"""
6920
7021
71class TestStateAgentYAML(unittest.TestCase):22class TestStateAgentYAML(unittest.TestCase):
@@ -83,6 +34,8 @@
83 self.runner = Runner(install_type="desktop", result_class=ResultYAML,34 self.runner = Runner(install_type="desktop", result_class=ResultYAML,
84 state_agent=self.state_agent)35 state_agent=self.state_agent)
85 self.partial_state_file_content = partial_state_file_content36 self.partial_state_file_content = partial_state_file_content
37 self.partial_state_file_content_run_all = partial_state_file_content_run_all
38 self.partial_state_file_content_done_all_failed = partial_state_file_content_done_all_failed
8639
87 def tearDown(self):40 def tearDown(self):
88 """41 """
@@ -159,14 +112,108 @@
159 shutil.copytree(test_src, test_dir)112 shutil.copytree(test_src, test_dir)
160113
161 state_agent = StateAgentYAML(state_file=self.state_file)114 state_agent = StateAgentYAML(state_file=self.state_file)
162 runner = Runner(install_type="desktop", state_agent=state_agent,115 runner = Runner(install_type="desktop",
163 resume=True)116 state_agent=state_agent,
164 runner.load_state()117 result_class=ResultYAML,
118 resume=True)
165119
166 self.assertEqual(runner.status, 'RUN')120 self.assertEqual(runner.status, 'RUN')
121 self.assertEqual(runner.count_suites(), 3)
122 self.assertEqual(runner.count_tests(), 5)
167123
168 next_test = runner.get_next_test()124 next_test = runner.get_next_test()
169125
170 self.assertEqual(next_test.name, 'test_two')126 self.assertEqual(next_test.name, 'test_two')
171127
172 runner.run()128 runner.run()
129
130 self.assertEqual(runner.passes, 4)
131 self.assertEqual(runner.failures, 1)
132 self.assertEqual(runner.errors, 0)
133 self.assertEqual(runner.passes + runner.failures + runner.errors, 5)
134
135 def test_load_state_partial_run_all(self):
136 """
137 Test that a partially run state file can be resumed.
138 """
139 fp = open(self.state_file, 'w')
140 fp.write(self.partial_state_file_content_run_all)
141 fp.close()
142
143 # Need to set up utah_tests since we're simulating a restart
144 test_src = os.path.join(get_module_path(), 'client',
145 'examples', 'utah_tests')
146 test_dir = os.path.join(UTAH_DIR, 'testsuites',
147 'utah_tests', 'utah_tests')
148 if not os.path.exists(test_dir):
149 shutil.copytree(test_src, test_dir)
150
151 # Need to set up utah_tests_sample since we're simulating a restart
152 test_src = os.path.join(get_module_path(), 'client',
153 'examples', 'utah_tests_sample')
154 test_dir = os.path.join(UTAH_DIR, 'testsuites', 'utah_tests_sample',
155 'utah_tests_sample')
156 if not os.path.exists(test_dir):
157 shutil.copytree(test_src, test_dir)
158
159 state_agent = StateAgentYAML(state_file=self.state_file)
160 runner = Runner(install_type="desktop",
161 state_agent=state_agent,
162 result_class=ResultYAML,
163 resume=True)
164
165 self.assertEqual(runner.status, 'RUN')
166 self.assertEqual(runner.count_suites(), 3)
167 self.assertEqual(runner.count_tests(), 5)
168
169 next_test = runner.get_next_test()
170
171 self.assertEqual(next_test.name, 'test_one')
172
173 runner.run()
174
175 self.assertEqual(runner.passes, 3)
176 self.assertEqual(runner.failures, 0)
177 self.assertEqual(runner.errors, 2)
178 self.assertEqual(runner.passes + runner.failures + runner.errors, 5)
179
180 def test_load_state_partial_done_all_failed(self):
181 """
182 Test that a partially run state file can be resumed.
183 """
184 fp = open(self.state_file, 'w')
185 fp.write(self.partial_state_file_content_done_all_failed)
186 fp.close()
187
188 # Need to set up utah_tests since we're simulating a restart
189 test_src = os.path.join(get_module_path(), 'client',
190 'examples', 'utah_tests')
191 test_dir = os.path.join(UTAH_DIR, 'testsuites',
192 'utah_tests', 'utah_tests')
193 if not os.path.exists(test_dir):
194 shutil.copytree(test_src, test_dir)
195
196 # Need to set up utah_tests_sample since we're simulating a restart
197 test_src = os.path.join(get_module_path(), 'client',
198 'examples', 'utah_tests_sample')
199 test_dir = os.path.join(UTAH_DIR, 'testsuites', 'utah_tests_sample',
200 'utah_tests_sample')
201 if not os.path.exists(test_dir):
202 shutil.copytree(test_src, test_dir)
203
204 state_agent = StateAgentYAML(state_file=self.state_file)
205 runner = Runner(install_type="desktop",
206 state_agent=state_agent,
207 result_class=ResultYAML,
208 resume=True)
209
210 self.assertEqual(runner.status, 'RUN')
211 self.assertEqual(runner.count_suites(), 3)
212 self.assertEqual(runner.count_tests(), 5)
213
214 runner.run()
215
216 self.assertEqual(runner.passes, 0)
217 self.assertEqual(runner.failures, 5)
218 self.assertEqual(runner.errors, 0)
219 self.assertEqual(runner.passes + runner.failures + runner.errors, 5)
173220
=== modified file 'utah/client/testsuite.py'
--- utah/client/testsuite.py 2012-10-22 08:15:08 +0000
+++ utah/client/testsuite.py 2012-12-05 15:31:21 +0000
@@ -204,6 +204,9 @@
204 Run the test cases; including any build, setup, and cleanup commands.204 Run the test cases; including any build, setup, and cleanup commands.
205 """205 """
206206
207 # we gather this info from the testcases
208 self.passes = self.errors = self.failures = 0
209
207 # Return value to indicate whether processing of a Runner should210 # Return value to indicate whether processing of a Runner should
208 # continue. This is to avoid a shutdown race on reboot cases.211 # continue. This is to avoid a shutdown race on reboot cases.
209 keep_going = True212 keep_going = True
@@ -226,11 +229,11 @@
226 for test in self.tests:229 for test in self.tests:
227 keep_going = test.run()230 keep_going = test.run()
228231
229 if test.run_status == 'PASS':232 if test.summary == 'PASS':
230 self.passes += 1233 self.passes += 1
231 elif test.run_status == 'FAIL':234 elif test.summary == 'FAIL':
232 self.failures += 1235 self.failures += 1
233 elif test.run_status == 'ERROR':236 elif test.summary == 'ERROR':
234 self.errors += 1237 self.errors += 1
235238
236 if not keep_going:239 if not keep_going:

Subscribers

People subscribed via source and target branches