Merge lp:~doanac/utah/server-test-fixes into lp:utah

Proposed by Andy Doan
Status: Merged
Merged at revision: 998
Proposed branch: lp:~doanac/utah/server-test-fixes
Merge into: lp:utah
Diff against target: 95 lines (+16/-15)
4 files modified
tests/test_config.py (+1/-1)
tests/test_parser.py (+13/-4)
tests/test_run_utah_phablet.py (+2/-2)
tests/test_vm.py (+0/-8)
To merge this branch: bzr merge lp:~doanac/utah/server-test-fixes
Reviewer Review Type Date Requested Status
Max Brustkern (community) Needs Information
Review via email: mp+181086@code.launchpad.net

Description of the change

fix some unit-test breakages we've had for a couple of months

To post a comment you must log in.
Revision history for this message
Max Brustkern (nuclearbob) wrote :

Have you tested running test-vm repeatedly on the same system to verify that using the same log path doesn't generate permissions issues? I can if you haven't.

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

On 08/20/2013 12:53 PM, Max Brustkern wrote:
> Have you tested running test-vm repeatedly on the same system to
> verify that using the same log path doesn't generate permissions
> issues? I can if you haven't.

Not sure I understand. self.logpath was never actually used in
test_vm.py. It looks like dead code?

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

> On 08/20/2013 12:53 PM, Max Brustkern wrote:
> > Have you tested running test-vm repeatedly on the same system to
> > verify that using the same log path doesn't generate permissions
> > issues? I can if you haven't.
>
> Not sure I understand. self.logpath was never actually used in
> test_vm.py. It looks like dead code?

The idea was to verify that the log file for the VM was still writable after the thing occurred. That way, if we can't write to the log file, setUp will fail instead of the tests failing. Now that logpath isn't being changed by the previous test, that's probably not needed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_config.py'
2--- tests/test_config.py 2013-06-24 21:04:03 +0000
3+++ tests/test_config.py 2013-08-20 15:55:34 +0000
4@@ -97,5 +97,5 @@
5 config._process_config_file(config_filenames[1])
6
7 stderr.write.assert_called_with(
8- 'WARNING: {} was already set by {}'
9+ 'WARNING: {} was already set by {}\n'
10 .format(option_name, config_filenames[0]))
11
12=== modified file 'tests/test_parser.py'
13--- tests/test_parser.py 2013-06-24 21:13:27 +0000
14+++ tests/test_parser.py 2013-08-20 15:55:34 +0000
15@@ -93,19 +93,28 @@
16 """Verify that logpath from command line updates log file names."""
17 logpath = 'valid-logpath'
18 hostname = config.hostname
19+ orig_lp = config.logpath
20 with patch('utah.parser.directory_argument') as directory_argument:
21 directory_argument.return_value = logpath
22 args = self.parse_args_wrapper(['--logpath', logpath,
23 '<runlist_file>'])
24+ # reset values so other tests after this don't get messed up
25+ newlp = config.logpath
26+ newlf = config.logfile
27+ newdl = config.debuglog
28+ newsl = config.ssh_logfile
29+ config.logpath = orig_lp
30+ config._set_log_files()
31+
32 self.assertEqual(args.logpath, logpath)
33- self.assertEqual(config.logpath, logpath)
34- self.assertEqual(config.logfile,
35+ self.assertEqual(newlp, logpath)
36+ self.assertEqual(newlf,
37 os.path.join(logpath,
38 '{}.log'.format(hostname)))
39- self.assertEqual(config.debuglog,
40+ self.assertEqual(newdl,
41 os.path.join(logpath,
42 '{}-debug.log'.format(hostname)))
43- self.assertEqual(config.ssh_logfile,
44+ self.assertEqual(newsl,
45 os.path.join(logpath,
46 '{}-ssh.log'.format(hostname)))
47
48
49=== modified file 'tests/test_run_utah_phablet.py'
50--- tests/test_run_utah_phablet.py 2013-07-12 20:36:47 +0000
51+++ tests/test_run_utah_phablet.py 2013-08-20 15:55:34 +0000
52@@ -117,12 +117,12 @@
53 def test_install_utah(self, adbshell):
54 """ensure utah install logic is okay by ensure proper PPA is used."""
55 _install_utah(self.device, self.args.ppa, self.args.branch)
56- self.assertIn(self.args.ppa, adbshell.call_args_list[0][0][0])
57+ self.assertIn(self.args.ppa, adbshell.call_args_list[1][0][0])
58
59 adbshell.reset_mock()
60 args = _get_parser().parse_args(['--ppa', 'blah', '-b', 'blah'])
61 _install_utah(self.device, args.ppa, args.branch)
62- self.assertIn(args.ppa, adbshell.call_args_list[0][0][0])
63+ self.assertIn(args.ppa, adbshell.call_args_list[1][0][0])
64 self.assertIn('bzr branch blah', adbshell.call_args_list[-1][0][0])
65
66 @mock.patch('run_utah_phablet._flash')
67
68=== modified file 'tests/test_vm.py'
69--- tests/test_vm.py 2013-06-24 21:56:45 +0000
70+++ tests/test_vm.py 2013-08-20 15:55:34 +0000
71@@ -15,10 +15,6 @@
72
73 """Test virtual machine functionality."""
74
75-
76-import tempfile
77-import os
78-
79 import libvirt
80 import unittest
81
82@@ -35,13 +31,9 @@
83 def setUp(self):
84 """Create libvirt connection and verify VM is not present."""
85 self.vmname = 'utah-unittest'
86- self.logpath = tempfile.mkdtemp(prefix='/tmp/{}_'.format(self.vmname))
87 self.lv = libvirt.open(config.qemupath)
88 with self.assertRaisesRegexp(libvirt.libvirtError, 'Domain not found'):
89 self.lv.lookupByName(self.vmname)
90- with open(os.path.join(self.logpath,
91- '{}-install.log'.format(self.vmname)), 'w'):
92- pass
93
94 def cleanUp(self):
95 """Remove temporary resources."""

Subscribers

People subscribed via source and target branches

to all changes: