Merge lp:~nuclearbob/utah/reset-rc into lp:utah

Proposed by Max Brustkern
Status: Merged
Merged at revision: 1037
Proposed branch: lp:~nuclearbob/utah/reset-rc
Merge into: lp:utah
Diff against target: 80 lines (+29/-7)
2 files modified
utah/client/runner.py (+11/-7)
utah/client/tests/test_runner.py (+18/-0)
To merge this branch: bzr merge lp:~nuclearbob/utah/reset-rc
Reviewer Review Type Date Requested Status
Andy Doan (community) Approve
Max Brustkern (community) Needs Resubmitting
Review via email: mp+208246@code.launchpad.net

Commit message

Added --reset-rc option to client

Description of the change

This branch adds a --reset-rc option to the utah client. This option is written to rc.local when utah uses rc.local for reboots. In absence of this option, a reset of rc.local will no longer be automatically triggered. This should allow provisioned autorun to work with reboot test cases.

To post a comment you must log in.
lp:~nuclearbob/utah/reset-rc updated
1034. By Max Brustkern

Added test

1035. By Max Brustkern

Fixed flake8

Revision history for this message
Andy Doan (doanac) wrote :

I'm basically a +1. I was curious if you thought we could do this with out needing the new option and just auto-detecting how we were launched using logic like we have here:

 http://bazaar.launchpad.net/~nuclearbob/utah/reset-rc/view/head:/utah/client/runner.py#L592

I don't want to cause you a lot of effort doing more testing, but I'll give you bonus points if we could do it like that instead.

Revision history for this message
Max Brustkern (nuclearbob) wrote :

Doing that would be better, yeah. I'll look at it today and see if I can figure something out.

lp:~nuclearbob/utah/reset-rc updated
1036. By Max Brustkern

Converting _autorun_file to _launched_by

1037. By Max Brustkern

pep257 fix

Revision history for this message
Max Brustkern (nuclearbob) wrote :
Revision history for this message
Max Brustkern (nuclearbob) wrote :

We've completed several successful runs, so I'm happy with the testing of the new version. If you'd like to take a look at it again, we can verify it's good to go.

review: Needs Resubmitting
Revision history for this message
Andy Doan (doanac) wrote :

thanks max. this looks like it will be a lot easier to maintain.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utah/client/runner.py'
2--- utah/client/runner.py 2014-02-25 19:59:16 +0000
3+++ utah/client/runner.py 2014-02-26 17:55:31 +0000
4@@ -194,11 +194,14 @@
5
6 self.state_agent = state_agent or StateAgentYAML()
7
8+ # Only reset RC_LOCAL if we were invoked there
9+ if self._launched_by() == 'rc.local':
10+ self.reset_rc_local()
11+
12 # Cleanup the state file if this is supposed to be a fresh run.
13 if not resume:
14 self.state_agent.clean()
15 else:
16- self.reset_rc_local()
17 self.load_state()
18
19 chdir(self.testsuitedir)
20@@ -551,13 +554,15 @@
21 """
22 return self.get_next_suite().get_next_test()
23
24- def _autorun_file(self):
25- """Determine if this was launched via the autorun feature.
26+ def _launched_by(self):
27+ """Determine how this was launched (autorun, rc.local, neither).
28
29- :return: the autorun file or None
30+ :return: 'rc.local', the autorun file, or None
31
32 """
33 r = os.listdir('/var/cache/utah/autorun/inprogress')
34+ if '/usr/bin/utah --resume' in open(RC_LOCAL):
35+ return 'rc.local'
36 if len(r) == 1 and 'run-utah' in r[0]:
37 return r[0]
38 return None
39@@ -585,11 +590,10 @@
40
41 self.save_state()
42
43- f = self._autorun_file()
44- if f:
45+ f = self._launched_by()
46+ if f and f != 'rc.local':
47 logger.log('restarting client via autostart on reboot')
48 self.setup_rc_local(runlist=self.backup_runlist, rc_local=f)
49- logger.log('Renaming %s to /etc/utah/autorun/01_run-utah', f)
50 os.rename(f, '/etc/utah/autorun/01_run-utah')
51 else:
52 logger.log('restarting client via rc.local on reboot')
53
54=== modified file 'utah/client/tests/test_runner.py'
55--- utah/client/tests/test_runner.py 2013-06-11 17:12:07 +0000
56+++ utah/client/tests/test_runner.py 2014-02-26 17:55:31 +0000
57@@ -244,6 +244,24 @@
58 f.write('andy: blah\n')
59 Runner._fetch_and_parse(self.tmpfile)
60
61+ def test_reset_rc(self):
62+ """Test reset_rc_local is only called when the argument is True."""
63+ with patch('utah.client.runner.Runner.reset_rc_local') as reset:
64+ Runner(install_type='desktop',
65+ result=ResultYAML(filename=None,
66+ append_to_file=False),
67+ state_agent=self.state_agent,
68+ output=self.output_file,
69+ reset_rc=False)
70+ assert not reset.called
71+ Runner(install_type='desktop',
72+ result=ResultYAML(filename=None,
73+ append_to_file=False),
74+ state_agent=self.state_agent,
75+ output=self.output_file,
76+ reset_rc=True)
77+ assert reset.called
78+
79
80 class TestRunnerMasterRunlistSchema(unittest.TestCase):
81

Subscribers

People subscribed via source and target branches