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

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 646
Merged at revision: 640
Proposed branch: lp:~javier.collado/utah/static_analysis_4
Merge into: lp:utah
Diff against target: 611 lines (+91/-63)
21 files modified
examples/run_install_test.py (+2/-1)
examples/run_test_vm.py (+2/-1)
utah/client/common.py (+4/-1)
utah/client/result.py (+3/-1)
utah/client/runner.py (+5/-3)
utah/client/testcase.py (+6/-4)
utah/client/tests/common.py (+4/-1)
utah/client/tests/manual_privileges.py (+1/-1)
utah/client/tests/test_common.py (+2/-1)
utah/client/tests/test_jsonschema.py (+10/-7)
utah/client/tests/test_misc.py (+3/-1)
utah/client/tests/test_result.py (+1/-1)
utah/client/tests/test_runner.py (+4/-6)
utah/client/tests/test_state_agent.py (+5/-7)
utah/client/tests/test_testcase.py (+4/-3)
utah/client/tests/test_testsuite.py (+5/-3)
utah/client/tests/test_yaml.py (+8/-7)
utah/client/testsuite.py (+6/-4)
utah/provisioning/baremetal/cobbler.py (+2/-1)
utah/provisioning/provisioning.py (+11/-6)
utah/provisioning/vm/libvirtvm.py (+3/-3)
To merge this branch: bzr merge lp:~javier.collado/utah/static_analysis_4
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Javier Collado (community) Needs Resubmitting
Review via email: mp+118745@code.launchpad.net

Description of the change

One more round of static analysis changes

Please have a look at the commit messages for further information about the problems fixed

To post a comment you must log in.
Revision history for this message
Joe Talbott (joetalbott) wrote :
Download full text (21.5 KiB)

On Wed, Aug 08, 2012 at 01:31:34PM -0000, Javier Collado wrote:
> Javier Collado has proposed merging lp:~javier.collado/utah/static_analysis_4 into lp:utah/dev.
>
> Requested reviews:
> UTAH Dev (utah)

See my comments below. I'm pulling setUp and tearDown from
utah/client/tests/common.py into the tests namespace so that nosetests
will find them and run them on start and finish.

Joe
>
> For more details, see:
> https://code.launchpad.net/~javier.collado/utah/static_analysis_4/+merge/118745
>
> One more round of static analysis changes
>
> Please have a look at the commit messages for further information about the problems fixed
> --
> https://code.launchpad.net/~javier.collado/utah/static_analysis_4/+merge/118745
> Your team UTAH Dev is requested to review the proposed merge of lp:~javier.collado/utah/static_analysis_4 into lp:utah/dev.

> === modified file 'examples/run_install_test.py'
> --- examples/run_install_test.py 2012-07-31 20:54:45 +0000
> +++ examples/run_install_test.py 2012-08-08 13:30:26 +0000
> @@ -97,7 +97,8 @@
> try:
> inventory.destroy(machine.machineid)
> except UTAHException as error:
> - sys.stderr.write('Failed to update inventory: ' + str(error))
> + sys.stderr.write('Failed to update inventory: '
> + + str(error))
> finally:
> del machine
> if len(locallogs) != 0:
>
> === modified file 'examples/run_test_vm.py'
> --- examples/run_test_vm.py 2012-07-31 20:54:02 +0000
> +++ examples/run_test_vm.py 2012-08-08 13:30:26 +0000
> @@ -77,7 +77,8 @@
> try:
> inventory.destroy(machine.machineid)
> except UTAHException as error:
> - sys.stderr.write('Failed to update inventory: ' + str(error))
> + sys.stderr.write('Failed to update inventory: '
> + + str(error))
> finally:
> del machine
> if len(locallogs) != 0:
>
> === modified file 'utah/client/common.py'
> --- utah/client/common.py 2012-08-02 18:36:14 +0000
> +++ utah/client/common.py 2012-08-08 13:30:26 +0000
> @@ -48,6 +48,7 @@
> CMD_TS_SETUP = 'testsuite_setup'
> CMD_TS_CLEANUP = 'testsuite_cleanup'
>
> +
> def do_nothing(obj=None):
> """
> Do nothing method used a placeholder for save_state_callbacks.
> @@ -265,6 +266,7 @@
> fp.close()
> print("### End {} ###".format(artifact))
>
> +
> def get_media_info():
> """
> Get the contents of the media-info file if available.
> @@ -279,6 +281,7 @@
>
> return media_info
>
> +
> def get_host_info():
> """
> Get host info, useful for debugging.
> @@ -291,6 +294,7 @@
>
> return retval
>
> +
> def get_api_config():
> """
> Parse the client configuration file for API configuration data.
> @@ -303,4 +307,3 @@
> data = json.load(fp)
>
> return data['API']
> -
>
> === modified file 'utah/client/result.py'
> --- utah/client/result.py 2012-08-02 16:03:40 +0000
> +++ utah/client/resul...

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

That makes sense, I'll add again those imports then an resubmit. Thanks for your feedback.

607. By Max Brustkern

Added support for nested timeouts; outer timeout alwasy wins right
now

608. By Max Brustkern

Merged Javier's packaging fix

609. By Max Brustkern

Added debhelper tokens to scripts

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

@Joe
The imports that were mistakenly removed have been added again.

I wanted to verify if nosetests works fine and I got 20 errors mainly because:
- master.run file is missing
-/var/lib/utah/examples isn't found
- and ...
Traceback (most recent call last):
  File "/home/javi/code/bzr/utah/static_analysis_4/utah/client/tests/test_testsuite.py", line 30, in setUp
    self.assertTrue(os.path.exists(os.path.join(path, name)))
AssertionError: False is not true

I followed the instructions in utah_howto.txt, but something must be missing in my environment. Please could you let me know what did you do to set up yours? Thanks.

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

On Wed, Aug 08, 2012 at 04:30:27PM -0000, Javier Collado wrote:
> @Joe
> The imports that were mistakenly removed have been added again.
>
> I wanted to verify if nosetests works fine and I got 20 errors mainly because:
> - master.run file is missing
> -/var/lib/utah/examples isn't found
> - and ...
> Traceback (most recent call last):
> File "/home/javi/code/bzr/utah/static_analysis_4/utah/client/tests/test_testsuite.py", line 30, in setUp
> self.assertTrue(os.path.exists(os.path.join(path, name)))
> AssertionError: False is not true
>
> I followed the instructions in utah_howto.txt, but something must be missing in my environment. Please could you let me know what did you do to set up yours? Thanks.

Have a look at utah/client/tests/README. There's a list in there of the
required packages for testing. Also note that the recommended way is to
run the nosetests from the top-level of the repo. Also make sure you
clean out /var/lib/utah before running. If that fails let me know and
I'll pull your branch and check it out.

Thanks,
Joe
>
> --
> https://code.launchpad.net/~javier.collado/utah/static_analysis_4/+merge/118745
> Your team UTAH Dev is requested to review the proposed merge of lp:~javier.collado/utah/static_analysis_4 into lp:utah/dev.

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

On Wed, Aug 08, 2012 at 04:30:27PM -0000, Javier Collado wrote:
> @Joe
> The imports that were mistakenly removed have been added again.
>
> I wanted to verify if nosetests works fine and I got 20 errors mainly because:
> - master.run file is missing
> -/var/lib/utah/examples isn't found
> - and ...
> Traceback (most recent call last):
> File "/home/javi/code/bzr/utah/static_analysis_4/utah/client/tests/test_testsuite.py", line 30, in setUp
> self.assertTrue(os.path.exists(os.path.join(path, name)))
> AssertionError: False is not true
>
> I followed the instructions in utah_howto.txt, but something must be missing in my environment. Please could you let me know what did you do to set up yours? Thanks.

Also make sure that the global setUp and tearDown methods are getting
called because they do some setting up of the environment as well.
>
> --
> https://code.launchpad.net/~javier.collado/utah/static_analysis_4/+merge/118745
> Your team UTAH Dev is requested to review the proposed merge of lp:~javier.collado/utah/static_analysis_4 into lp:utah/dev.

610. By Joe Talbott

Support timeout overrides from master.run to ts_control to
tc_control

611. By Max Brustkern

Added exception for when client fails to install

612. By Joe Talbott

Merge Javier's LP URL work

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

I've run the test cases for both precise and quantal with the packaged version of python-jsonschema and they passed successfully.

review: Needs Resubmitting
613. By Max Brustkern

Check for correct error when New option is not set to True

614. By Joe Talbott

Download and run testsuites in UTAH_DIR/testsuites

615. By Joe Talbott

Merge Javier's python-jsonschema work

616. By Joe Talbott

Remove extra 'testsuites' directory

617. By Max Brustkern

Merged Javier's changes for propagating exit status so exceptions still show

618. By Max Brustkern

Merged Javier's client installation related exceptions

619. By Max Brustkern

Merged Javier's readability improvements

620. By Max Brustkern

Merged Javier's change that Fixes 1034348

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

@Joe

Please let me know if there's some other thing might be a concern. Thanks.

621. By Max Brustkern

Merged Javier's changes for clearer error reporting when file downloads fail

622. By Max Brustkern

Improved docstrings for non-provisioning modules

623. By Max Brustkern

This is in config.py now

624. By Max Brustkern

Removed old json files

625. By Max Brustkern

Improved documentation in provisioning

626. By Javier Collado

Merged lp:~nuclearbob/utah/packaging-changes

This fixes the problem of not being able to install both utah and utah-client
together.

627. By Max Brustkern

Added diskbus option for VM creation

628. By Max Brustkern

Cleaning up stop method of libvirtvm

629. By Max Brustkern

Testing package version change

630. By Max Brustkern

Fixed postinst typo

631. By Max Brustkern

Merged Javier's default test case fixes

632. By Max Brustkern

Merged Javier's packaging changes

633. By Max Brustkern

Merged Javier's changes for new try blocks

634. By Max Brustkern

Merges Javier's gdebi changes

635. By Javier Collado

Merged fix from lp:~javier.collado/utah/bug1035231

Although package installation failures are reported, gdebi must be executed as
root for the succesful case.

646. By Javier Collado

Added again the imports needed by nosetests

Used NOQA to skip flake8 error on those imports and added a comment to mark
clearly that they are needed even if they aren't used directly.

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

I've rebased changes to make sure the merge is still easy to do (resolved one conflict).

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

Look good. Feel free to merge.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/run_install_test.py'
--- examples/run_install_test.py 2012-08-14 15:42:17 +0000
+++ examples/run_install_test.py 2012-08-16 12:03:20 +0000
@@ -100,7 +100,8 @@
100 try:100 try:
101 inventory.destroy(machine.machineid)101 inventory.destroy(machine.machineid)
102 except UTAHException as error:102 except UTAHException as error:
103 sys.stderr.write('Failed to update inventory: ' + str(error))103 sys.stderr.write('Failed to update inventory: '
104 + str(error))
104 finally:105 finally:
105 del machine106 del machine
106 if len(locallogs) != 0:107 if len(locallogs) != 0:
107108
=== modified file 'examples/run_test_vm.py'
--- examples/run_test_vm.py 2012-07-31 20:54:02 +0000
+++ examples/run_test_vm.py 2012-08-16 12:03:20 +0000
@@ -77,7 +77,8 @@
77 try:77 try:
78 inventory.destroy(machine.machineid)78 inventory.destroy(machine.machineid)
79 except UTAHException as error:79 except UTAHException as error:
80 sys.stderr.write('Failed to update inventory: ' + str(error))80 sys.stderr.write('Failed to update inventory: '
81 + str(error))
81 finally:82 finally:
82 del machine83 del machine
83 if len(locallogs) != 0:84 if len(locallogs) != 0:
8485
=== modified file 'utah/client/common.py'
--- utah/client/common.py 2012-08-09 20:14:54 +0000
+++ utah/client/common.py 2012-08-16 12:03:20 +0000
@@ -49,6 +49,7 @@
49CMD_TS_SETUP = 'testsuite_setup'49CMD_TS_SETUP = 'testsuite_setup'
50CMD_TS_CLEANUP = 'testsuite_cleanup'50CMD_TS_CLEANUP = 'testsuite_cleanup'
5151
52
52def do_nothing(obj=None):53def do_nothing(obj=None):
53 """54 """
54 Do nothing method used a placeholder for save_state_callbacks.55 Do nothing method used a placeholder for save_state_callbacks.
@@ -266,6 +267,7 @@
266 fp.close()267 fp.close()
267 print("### End {} ###".format(artifact))268 print("### End {} ###".format(artifact))
268269
270
269def get_media_info():271def get_media_info():
270 """272 """
271 Get the contents of the media-info file if available.273 Get the contents of the media-info file if available.
@@ -280,6 +282,7 @@
280282
281 return media_info283 return media_info
282284
285
283def get_host_info():286def get_host_info():
284 """287 """
285 Get host info, useful for debugging.288 Get host info, useful for debugging.
@@ -292,6 +295,7 @@
292295
293 return retval296 return retval
294297
298
295def get_api_config():299def get_api_config():
296 """300 """
297 Parse the client configuration file for API configuration data.301 Parse the client configuration file for API configuration data.
@@ -304,4 +308,3 @@
304 data = json.load(fp)308 data = json.load(fp)
305309
306 return data['API']310 return data['API']
307
308311
=== modified file 'utah/client/result.py'
--- utah/client/result.py 2012-08-02 16:03:40 +0000
+++ utah/client/result.py 2012-08-16 12:03:20 +0000
@@ -4,6 +4,7 @@
44
5from .common import get_host_info5from .common import get_host_info
66
7
7class Result(object):8class Result(object):
8 """9 """
9 Result collection class.10 Result collection class.
@@ -132,7 +133,8 @@
132 'uname': list(host_info['uname']),133 'uname': list(host_info['uname']),
133 'media-info': host_info['media-info'],134 'media-info': host_info['media-info'],
134 }135 }
135 yaml.dump(data, sys.stdout, explicit_start='---', default_flow_style=False)136 yaml.dump(data, sys.stdout, explicit_start='---',
137 default_flow_style=False)
136138
137 status = self.status139 status = self.status
138 self.clear_results()140 self.clear_results()
139141
=== modified file 'utah/client/runner.py'
--- utah/client/runner.py 2012-08-09 20:14:54 +0000
+++ utah/client/runner.py 2012-08-16 12:03:20 +0000
@@ -270,7 +270,8 @@
270270
271 self.backup_runlist = os.path.join(self.testdir, 'master.run-reboot')271 self.backup_runlist = os.path.join(self.testdir, 'master.run-reboot')
272272
273 if os.path.exists(self.master_runlist) and self.master_runlist != self.backup_runlist:273 if (os.path.exists(self.master_runlist)
274 and self.master_runlist != self.backup_runlist):
274 shutil.copyfile(self.master_runlist, self.backup_runlist)275 shutil.copyfile(self.master_runlist, self.backup_runlist)
275276
276 state = {277 state = {
@@ -326,7 +327,7 @@
326 # local filename if needed (it might be a local file already or cached)327 # local filename if needed (it might be a local file already or cached)
327 try:328 try:
328 local_filename = urllib.urlretrieve(runlist)[0]329 local_filename = urllib.urlretrieve(runlist)[0]
329 except IOError as e:330 except IOError:
330 raise exceptions.MissingFile(runlist)331 raise exceptions.MissingFile(runlist)
331332
332 data = parse_yaml_file(local_filename)333 data = parse_yaml_file(local_filename)
@@ -372,7 +373,8 @@
372373
373 if name not in self.fetched_suites:374 if name not in self.fetched_suites:
374 if fetch_cmd is not None:375 if fetch_cmd is not None:
375 self.result.add_result(run_cmd(fetch_cmd, cwd=name, cmd_type=CMD_TS_FETCH))376 self.result.add_result(run_cmd(fetch_cmd, cwd=name,
377 cmd_type=CMD_TS_FETCH))
376 self.fetched_suites.append(name)378 self.fetched_suites.append(name)
377379
378 # If fetch_cmd failed move on to the next testsuite.380 # If fetch_cmd failed move on to the next testsuite.
379381
=== modified file 'utah/client/testcase.py'
--- utah/client/testcase.py 2012-08-10 17:12:13 +0000
+++ utah/client/testcase.py 2012-08-16 12:03:20 +0000
@@ -5,7 +5,6 @@
5from common import run_cmd, parse_control_file5from common import run_cmd, parse_control_file
6from common import do_nothing6from common import do_nothing
7from common import CMD_TC_BUILD, CMD_TC_SETUP, CMD_TC_TEST, CMD_TC_CLEANUP7from common import CMD_TC_BUILD, CMD_TC_SETUP, CMD_TC_TEST, CMD_TC_CLEANUP
8from result import Result
9from exceptions import MissingFile8from exceptions import MissingFile
109
1110
@@ -113,7 +112,8 @@
113 """112 """
114 if self.status == 'NOTRUN':113 if self.status == 'NOTRUN':
115 self.set_status('BUILD')114 self.set_status('BUILD')
116 result.add_result(run_cmd(self.build_cmd, cwd=self.working_dir, cmd_type=CMD_TC_BUILD))115 result.add_result(run_cmd(self.build_cmd, cwd=self.working_dir,
116 cmd_type=CMD_TC_BUILD))
117117
118 def setup(self, result):118 def setup(self, result):
119 """119 """
@@ -121,7 +121,8 @@
121 """121 """
122 if self.status == 'BUILD' and result.status == 'PASS':122 if self.status == 'BUILD' and result.status == 'PASS':
123 self.set_status('SETUP')123 self.set_status('SETUP')
124 result.add_result(run_cmd(self.tc_setup, cwd=self.working_dir, cmd_type=CMD_TC_SETUP))124 result.add_result(run_cmd(self.tc_setup, cwd=self.working_dir,
125 cmd_type=CMD_TC_SETUP))
125126
126 def cleanup(self, result):127 def cleanup(self, result):
127 """128 """
@@ -129,7 +130,8 @@
129 """130 """
130 if self.status == 'RUN':131 if self.status == 'RUN':
131 self.set_status('CLEANUP')132 self.set_status('CLEANUP')
132 result.add_result(run_cmd(self.tc_cleanup, cwd=self.working_dir, cmd_type=CMD_TC_CLEANUP))133 result.add_result(run_cmd(self.tc_cleanup, cwd=self.working_dir,
134 cmd_type=CMD_TC_CLEANUP))
133135
134 def run(self):136 def run(self):
135 """137 """
136138
=== modified file 'utah/client/tests/common.py'
--- utah/client/tests/common.py 2012-08-09 20:14:54 +0000
+++ utah/client/tests/common.py 2012-08-16 12:03:20 +0000
@@ -1,7 +1,8 @@
1import os1import os
2import shutil2import shutil
33
4from utah.client.common import UTAH_DIR, MASTER_RUNLIST, UTAH_CLIENT4from utah.client.common import UTAH_DIR, MASTER_RUNLIST
5
56
6def get_module_path():7def get_module_path():
7 """8 """
@@ -39,6 +40,7 @@
39#examples_source = os.path.join(UTAH_CLIENT, 'examples')40#examples_source = os.path.join(UTAH_CLIENT, 'examples')
40examples_source = os.path.join(get_module_path(), 'client', 'examples')41examples_source = os.path.join(get_module_path(), 'client', 'examples')
4142
43
42def setUp():44def setUp():
43 """45 """
44 Set up a master.run file that will copy our 'examples' directory to the46 Set up a master.run file that will copy our 'examples' directory to the
@@ -61,6 +63,7 @@
61 fp.write(master_runlist_content)63 fp.write(master_runlist_content)
62 fp.close()64 fp.close()
6365
66
64def tearDown():67def tearDown():
65 """68 """
66 Cleanup after ourselves.69 Cleanup after ourselves.
6770
=== modified file 'utah/client/tests/manual_privileges.py'
--- utah/client/tests/manual_privileges.py 2012-08-01 17:25:20 +0000
+++ utah/client/tests/manual_privileges.py 2012-08-16 12:03:20 +0000
@@ -116,6 +116,7 @@
116 print_priv("after")116 print_priv("after")
117 _do_cmd("id")117 _do_cmd("id")
118118
119
119class TestPriv(baseTestPriv):120class TestPriv(baseTestPriv):
120 def test_drop_priv(self):121 def test_drop_priv(self):
121 """122 """
@@ -170,4 +171,3 @@
170 })171 })
171172
172 _do_cmd("id")173 _do_cmd("id")
173
174174
=== modified file 'utah/client/tests/test_common.py'
--- utah/client/tests/test_common.py 2012-07-31 19:40:18 +0000
+++ utah/client/tests/test_common.py 2012-08-16 12:03:20 +0000
@@ -10,6 +10,7 @@
10 CONFIG,10 CONFIG,
11 )11 )
1212
13
13class TestCommon(unittest.TestCase):14class TestCommon(unittest.TestCase):
14 """15 """
15 Tests for utah.client.common.16 Tests for utah.client.common.
@@ -35,7 +36,7 @@
35 host_info = get_host_info()36 host_info = get_host_info()
3637
37 print("host_info: {}".format(host_info))38 print("host_info: {}".format(host_info))
38 39
39 self.assertTrue(host_info is not None)40 self.assertTrue(host_info is not None)
4041
41 def test_run_cmd(self):42 def test_run_cmd(self):
4243
=== modified file 'utah/client/tests/test_jsonschema.py'
--- utah/client/tests/test_jsonschema.py 2012-08-06 19:16:38 +0000
+++ utah/client/tests/test_jsonschema.py 2012-08-16 12:03:20 +0000
@@ -27,22 +27,23 @@
27testsuties:27testsuties:
28 - name: testsuite128 - name: testsuite1
29 fetch_cmd: fetch129 fetch_cmd: fetch1
30""", # typo30""", # typo
31"""---31"""---
32timeout: 10132timeout: 101
33repeat_count: 9933repeat_count: 99
34""", # missing testsuites34""", # missing testsuites
35"""---35"""---
36- name: blah36- name: blah
37- name: blip37- name: blip
38""", # missing fetch_cmds38""", # missing fetch_cmds
39"""---39"""---
40testsuites:40testsuites:
41 - name: blah41 - name: blah
42 - name: blip42 - name: blip
43""", # missing fetch_cmds43""", # missing fetch_cmds
44]44]
4545
46
46class TestJSONSchema(unittest.TestCase):47class TestJSONSchema(unittest.TestCase):
4748
48 def test_orig_schema(self):49 def test_orig_schema(self):
@@ -64,7 +65,8 @@
64 jsonschema.validate(data_new, Runner.MASTER_RUNLIST_SCHEMA)65 jsonschema.validate(data_new, Runner.MASTER_RUNLIST_SCHEMA)
6566
66 def test_example_runlist(self):67 def test_example_runlist(self):
67 example_runlist = os.path.join(os.path.dirname(__file__), "../examples/master.run")68 example_runlist = os.path.join(os.path.dirname(__file__),
69 "../examples/master.run")
6870
69 self.assertTrue(os.path.exists(example_runlist))71 self.assertTrue(os.path.exists(example_runlist))
7072
@@ -74,7 +76,6 @@
74 jsonschema.validate(data, Runner.MASTER_RUNLIST_SCHEMA)76 jsonschema.validate(data, Runner.MASTER_RUNLIST_SCHEMA)
75 fp.close()77 fp.close()
7678
77
78 def test_bad_schemas(self):79 def test_bad_schemas(self):
79 """80 """
80 Test that required fields are enforced by the schema.81 Test that required fields are enforced by the schema.
@@ -83,4 +84,6 @@
83 for content in yaml_content_bad:84 for content in yaml_content_bad:
84 data = yaml.load(content)85 data = yaml.load(content)
85 print("data: {}".format(data))86 print("data: {}".format(data))
86 self.assertRaises(jsonschema.ValidationError, jsonschema.validate, data, Runner.MASTER_RUNLIST_SCHEMA)87 self.assertRaises(jsonschema.ValidationError,
88 jsonschema.validate,
89 data, Runner.MASTER_RUNLIST_SCHEMA)
8790
=== modified file 'utah/client/tests/test_misc.py'
--- utah/client/tests/test_misc.py 2012-08-06 19:40:22 +0000
+++ utah/client/tests/test_misc.py 2012-08-16 12:03:20 +0000
@@ -3,11 +3,13 @@
33
4from .common import get_module_path4from .common import get_module_path
55
6
6class TestMisc(unittest.TestCase):7class TestMisc(unittest.TestCase):
7 def test_get_module_path(self):8 def test_get_module_path(self):
89
9 print("__file__: {}".format(__file__))10 print("__file__: {}".format(__file__))
1011
11 # assumes this file is in 'utah/client/tests'12 # assumes this file is in 'utah/client/tests'
12 file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))13 file_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
14 "../../"))
13 self.assertEqual(file_path, get_module_path())15 self.assertEqual(file_path, get_module_path())
1416
=== modified file 'utah/client/tests/test_result.py'
--- utah/client/tests/test_result.py 2012-07-30 14:27:12 +0000
+++ utah/client/tests/test_result.py 2012-08-16 12:03:20 +0000
@@ -6,6 +6,7 @@
6 ResultYAML,6 ResultYAML,
7 )7 )
88
9
9class TestResult(unittest.TestCase):10class TestResult(unittest.TestCase):
10 def setUp(self):11 def setUp(self):
11 self.result_yaml = ResultYAML("result_yaml")12 self.result_yaml = ResultYAML("result_yaml")
@@ -118,4 +119,3 @@
118 self.assertEqual(result['returncode'], self.result['returncode'])119 self.assertEqual(result['returncode'], self.result['returncode'])
119 self.assertEqual(result['stdout'], self.result['stdout'])120 self.assertEqual(result['stdout'], self.result['stdout'])
120 self.assertEqual(result['stderr'], self.result['stderr'])121 self.assertEqual(result['stderr'], self.result['stderr'])
121
122122
=== modified file 'utah/client/tests/test_runner.py'
--- utah/client/tests/test_runner.py 2012-08-09 20:14:54 +0000
+++ utah/client/tests/test_runner.py 2012-08-16 12:03:20 +0000
@@ -8,15 +8,13 @@
8from utah.client.common import RETURN_CODES8from utah.client.common import RETURN_CODES
9from utah.client import exceptions9from utah.client import exceptions
1010
11from .common import setUp, tearDown11from .common import ( # NOQA
12from .common import (12 setUp, # Used by nosetests
13 tearDown, # Used by nosetests
13 master_runlist_content,14 master_runlist_content,
14 master_runlist,
15 master_runlist_bak,
16 examples_dir,
17 examples_source,
18 )15 )
1916
17
20class TestRunner(unittest.TestCase):18class TestRunner(unittest.TestCase):
21 def setUp(self):19 def setUp(self):
22 self.result_class = ResultYAML20 self.result_class = ResultYAML
2321
=== modified file 'utah/client/tests/test_state_agent.py'
--- utah/client/tests/test_state_agent.py 2012-08-09 20:14:54 +0000
+++ utah/client/tests/test_state_agent.py 2012-08-16 12:03:20 +0000
@@ -6,14 +6,11 @@
6from utah.client.state_agent import StateAgentYAML6from utah.client.state_agent import StateAgentYAML
7from utah.client.runner import Runner7from utah.client.runner import Runner
8from utah.client.result import ResultYAML8from utah.client.result import ResultYAML
9from utah.client.common import (9from utah.client.common import UTAH_DIR
10 run_cmd,
11 UTAH_DIR,
12 )
1310
14from .common import (11from .common import ( # NOQA
15 setUp,12 setUp, # Used by nosetests
16 tearDown,13 tearDown, # Used by nosetests
17 get_module_path,14 get_module_path,
18 )15 )
1916
@@ -70,6 +67,7 @@
70 ts_setup: null67 ts_setup: null
71"""68"""
7269
70
73class TestStateAgentYAML(unittest.TestCase):71class TestStateAgentYAML(unittest.TestCase):
74 def setUp(self):72 def setUp(self):
75 """73 """
7674
=== modified file 'utah/client/tests/test_testcase.py'
--- utah/client/tests/test_testcase.py 2012-08-09 20:14:54 +0000
+++ utah/client/tests/test_testcase.py 2012-08-16 12:03:20 +0000
@@ -7,11 +7,12 @@
7 )7 )
8from utah.client import testcase8from utah.client import testcase
99
10from .common import (10from .common import ( # NOQA
11 setUp,11 setUp, # Used by nosetests
12 tearDown,12 tearDown, # Used by nosetests
13 )13 )
1414
15
15class TestTestCase(unittest.TestCase):16class TestTestCase(unittest.TestCase):
16 """17 """
17 Tests for the TestCase class.18 Tests for the TestCase class.
1819
=== modified file 'utah/client/tests/test_testsuite.py'
--- utah/client/tests/test_testsuite.py 2012-08-09 20:14:54 +0000
+++ utah/client/tests/test_testsuite.py 2012-08-16 12:03:20 +0000
@@ -7,14 +7,16 @@
7from utah.client.result import ResultYAML7from utah.client.result import ResultYAML
8from utah.client import testsuite8from utah.client import testsuite
99
10from .common import (10from .common import ( # NOQA
11 setUp,11 setUp, # Used by nosetests
12 tearDown,12 tearDown, # Used by nosetests
13 )13 )
1414
15
15def state_saver():16def state_saver():
16 debug_print("Saving state", force=True)17 debug_print("Saving state", force=True)
1718
19
18class TestTestSuite(unittest.TestCase):20class TestTestSuite(unittest.TestCase):
19 """21 """
20 Tests for the TestSuite class.22 Tests for the TestSuite class.
2123
=== modified file 'utah/client/tests/test_yaml.py'
--- utah/client/tests/test_yaml.py 2012-07-27 19:42:26 +0000
+++ utah/client/tests/test_yaml.py 2012-08-16 12:03:20 +0000
@@ -1,18 +1,19 @@
1import unittest1import unittest
2import yaml2import yaml
33
4
4class TestYAML(unittest.TestCase):5class TestYAML(unittest.TestCase):
5 def test_parts(self):6 def test_parts(self):
6 content = {}7 content = {}
7 content['metadata'] = {8 content['metadata'] = {
8 'runlist' : '/tmp/master.run',9 'runlist': '/tmp/master.run',
9 'host' : 'Ubuntu 12.04 LTS',10 'host': 'Ubuntu 12.04 LTS',
10 }11 }
11 content['commands'] = [12 content['commands'] = [
12 {13 {
13 'command' : 'rm -f blah',14 'command': 'rm -f blah',
14 'stdout' : '',15 'stdout': '',
15 'stderr' : '',16 'stderr': '',
16 }17 }
17 ]18 ]
1819
@@ -26,7 +27,7 @@
2627
27 def test_parts_2(self):28 def test_parts_2(self):
28 content = {29 content = {
29 'file' : '/tmp/file'30 'file': '/tmp/file'
30 }31 }
3132
32 extra_args = {33 extra_args = {
@@ -63,7 +64,7 @@
63 extra_args = {}64 extra_args = {}
64 content = [65 content = [
65 {66 {
66 'file' : '/tmp/file',67 'file': '/tmp/file',
67 },68 },
68 [69 [
69 {70 {
7071
=== modified file 'utah/client/testsuite.py'
--- utah/client/testsuite.py 2012-08-08 21:10:05 +0000
+++ utah/client/testsuite.py 2012-08-16 12:03:20 +0000
@@ -6,7 +6,6 @@
6from common import DEFAULT_TSLIST, DEFAULT_TSCONTROL6from common import DEFAULT_TSLIST, DEFAULT_TSCONTROL
7from common import CMD_TS_BUILD, CMD_TS_SETUP, CMD_TS_CLEANUP7from common import CMD_TS_BUILD, CMD_TS_SETUP, CMD_TS_CLEANUP
8from common import do_nothing8from common import do_nothing
9from result import Result
10import jsonschema9import jsonschema
1110
12import os11import os
@@ -166,7 +165,8 @@
166 """165 """
167 if self.status == 'NOTRUN':166 if self.status == 'NOTRUN':
168 self.set_status('BUILD')167 self.set_status('BUILD')
169 result.add_result(run_cmd(self.build_cmd, cwd=self.name, cmd_type=CMD_TS_BUILD))168 result.add_result(run_cmd(self.build_cmd, cwd=self.name,
169 cmd_type=CMD_TS_BUILD))
170170
171 def setup(self, result):171 def setup(self, result):
172 """172 """
@@ -174,7 +174,8 @@
174 """174 """
175 if self.status == 'BUILD' and result.status == 'PASS':175 if self.status == 'BUILD' and result.status == 'PASS':
176 self.set_status('SETUP')176 self.set_status('SETUP')
177 result.add_result(run_cmd(self.ts_setup, cwd=self.name, cmd_type=CMD_TS_SETUP))177 result.add_result(run_cmd(self.ts_setup, cwd=self.name,
178 cmd_type=CMD_TS_SETUP))
178179
179 def cleanup(self, result):180 def cleanup(self, result):
180 """181 """
@@ -182,7 +183,8 @@
182 """183 """
183 if self.status == 'INPROGRESS':184 if self.status == 'INPROGRESS':
184 self.set_status('CLEANUP')185 self.set_status('CLEANUP')
185 result.add_result(run_cmd(self.ts_cleanup, cwd=self.name, cmd_type=CMD_TS_CLEANUP))186 result.add_result(run_cmd(self.ts_cleanup, cwd=self.name,
187 cmd_type=CMD_TS_CLEANUP))
186188
187 def run(self):189 def run(self):
188 """190 """
189191
=== modified file 'utah/provisioning/baremetal/cobbler.py'
--- utah/provisioning/baremetal/cobbler.py 2012-08-03 21:44:39 +0000
+++ utah/provisioning/baremetal/cobbler.py 2012-08-16 12:03:20 +0000
@@ -132,7 +132,8 @@
132 for name in (dirnames + filenames):132 for name in (dirnames + filenames):
133 filename = os.path.join(dirpath, name)133 filename = os.path.join(dirpath, name)
134 if not os.path.islink(filename):134 if not os.path.islink(filename):
135 self.logger.debug('Changing permissions of ' + filename)135 self.logger.debug('Changing permissions of '
136 + filename)
136 os.chmod(filename, 0775)137 os.chmod(filename, 0775)
137 shutil.rmtree(self.tmpdir)138 shutil.rmtree(self.tmpdir)
138139
139140
=== modified file 'utah/provisioning/provisioning.py'
--- utah/provisioning/provisioning.py 2012-08-15 09:35:14 +0000
+++ utah/provisioning/provisioning.py 2012-08-16 12:03:20 +0000
@@ -504,14 +504,16 @@
504 self.logger.info('Uploading ' + localpath504 self.logger.info('Uploading ' + localpath
505 + ' from the host to ' + target505 + ' from the host to ' + target
506 + ' on the machine')506 + ' on the machine')
507 remotepath = os.path.join(target, os.path.basename(localpath))507 remotepath = os.path.join(target,
508 os.path.basename(localpath))
508 sftp_client.put(localpath, remotepath)509 sftp_client.put(localpath, remotepath)
509 else:510 else:
510 failed.append(localpath)511 failed.append(localpath)
511 finally:512 finally:
512 sftp_client.close()513 sftp_client.close()
513 if len(failed) > 0:514 if len(failed) > 0:
514 err = UTAHProvisioningException('Files do not exist: ' + ' '.join(failed))515 err = UTAHProvisioningException('Files do not exist: '
516 + ' '.join(failed))
515 err.files = failed517 err.files = failed
516 raise err518 raise err
517519
@@ -554,7 +556,8 @@
554 self.ssh_client.connect(self.name,556 self.ssh_client.connect(self.name,
555 key_filename=config.sshprivatekey)557 key_filename=config.sshprivatekey)
556 sftp_client = self.ssh_client.open_sftp()558 sftp_client = self.ssh_client.open_sftp()
557 files = [os.path.join(dirname, myfile) for myfile in sftp_client.listdir(dirname)]559 files = [os.path.join(dirname, myfile)
560 for myfile in sftp_client.listdir(dirname)]
558 self.downloadfiles(files, target)561 self.downloadfiles(files, target)
559562
560 def destroy(self, *args, **kw):563 def destroy(self, *args, **kw):
@@ -605,13 +608,15 @@
605 except socket.error as err:608 except socket.error as err:
606 raise UTAHProvisioningException(str(err), retry=True)609 raise UTAHProvisioningException(str(err), retry=True)
607610
608 def sshpoll(self, timeout=config.boottimeout, checktimeout=config.checktimeout, logmethod=None):611 def sshpoll(self, timeout=config.boottimeout,
612 checktimeout=config.checktimeout, logmethod=None):
609 """613 """
610 Run sshcheck over and over until timeout expires.614 Run sshcheck over and over until timeout expires.
611 """615 """
612 if logmethod is None:616 if logmethod is None:
613 logmethod=self.logger.debug617 logmethod = self.logger.debug
614 utah.timeout.timeout(timeout, retry, self.sshcheck, checktimeout, logmethod=logmethod)618 utah.timeout.timeout(timeout, retry, self.sshcheck, checktimeout,
619 logmethod=logmethod)
615620
616621
617class CustomInstallMixin(object):622class CustomInstallMixin(object):
618623
=== modified file 'utah/provisioning/vm/libvirtvm.py'
--- utah/provisioning/vm/libvirtvm.py 2012-08-14 16:50:47 +0000
+++ utah/provisioning/vm/libvirtvm.py 2012-08-16 12:03:20 +0000
@@ -6,7 +6,6 @@
6import string6import string
7import subprocess7import subprocess
8import tempfile8import tempfile
9import time
109
11from xml.etree import ElementTree10from xml.etree import ElementTree
1211
@@ -24,7 +23,6 @@
24 )23 )
25from utah import config24from utah import config
26from utah.process import ProcessChecker25from utah.process import ProcessChecker
27import utah.timeout
2826
2927
30class LibvirtVM(VM):28class LibvirtVM(VM):
@@ -336,7 +334,9 @@
336 for myfile in files:334 for myfile in files:
337 self.logger.info('Uploading ' + myfile335 self.logger.info('Uploading ' + myfile
338 + ' from the host to ' + target + ' on the VM')336 + ' from the host to ' + target + ' on the VM')
339 if self._runargs(['vm-scp', '-f', '-p', self.name, myfile, target]) != 0:337 returncode = self._runargs(['vm-scp', '-f', '-p',
338 self.name, myfile, target])
339 if returncode != 0:
340 success = False340 success = False
341 return success341 return success
342342

Subscribers

People subscribed via source and target branches