Merge lp:~gmb/maas-test/report-machine-info into lp:maas-test

Proposed by Graham Binns
Status: Merged
Approved by: Graham Binns
Approved revision: 135
Merged at revision: 124
Proposed branch: lp:~gmb/maas-test/report-machine-info
Merge into: lp:maas-test
Diff against target: 49 lines (+24/-0)
2 files modified
maastest/maasfixture.py (+12/-0)
maastest/tests/test_maasfixture.py (+12/-0)
To merge this branch: bzr merge lp:~gmb/maas-test/report-machine-info
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+201395@code.launchpad.net

Commit message

Include a dump of lshw info from the commissioned node with the test log.

Description of the change

This branch adds a dump of the MAAS DB as an attachment to the blob generated by maas-test. We can use this to help us get more information about failures. In future we can extract data from this dump and use it in the bug report to help Launchpad de-dupe, but for now this is a good start.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) wrote :

I might be missing something but why didn't you do something similar to what we did with MAASFixture.collect_logs and leverage the addDetail/fixture cleanup combination… i.e. something along the lines of http://paste.ubuntu.com/6744843/ ? It seems a bit simpler to me.

Revision history for this message
Graham Binns (gmb) wrote :

You were quite right, Raphers; I've fixed it to use the fixture/cleanup route now.

132. By Graham Binns

Fixed a hack.

Revision history for this message
Gavin Panella (allenap) wrote :

Point [2] needs addressing, but it doesn't need re-review. Nice.

[1]

+    def dump_data(self, dump_dir=None):

Please be adding a docstring.

[2]

+    def dump_data(self, dump_dir=None):
+        if dump_dir is None:
+            dump_dir = utils.DEFAULT_LOG_DIR
+        return_code, stdout, _ = self.kvm_fixture.run_command([
+            'sudo', 'maas', 'dumpdata', 'metadataserver.NodeCommissionResult'
+            ])

dump_dir isn't being used for anything. Can it be dropped?

[3]

MAASFixture looks like it's gone all 2008-financial-crisis: too big to
fail, too big to test. It would be good to have a test that confirms
that the data is dumped during clean-up, but I suspect that the noise of
set-up (mocking, etc.) would smother the useful kernel of the test.

review: Approve
133. By Graham Binns

Removed reference to log dir from MAASFixture.dump_data(), since it's no longer used.

134. By Graham Binns

Added a docstring.

Revision history for this message
Gavin Panella (allenap) wrote :

[4]

     def dump_data(self, dump_dir=None):
-        if dump_dir is None:
-            dump_dir = utils.DEFAULT_LOG_DIR
+        """Dump the NodeCommissionResult table to stdout.
+
+        This allows us to capture the lshw results for commissioned
+        nodes. This method will be called when the fixture get cleaned
+        up.
+        """

You probably ought to remove the dump_dir argument too, and update the
test.

Revision history for this message
Graham Binns (gmb) wrote :

Damn.

Revision history for this message
Graham Binns (gmb) wrote :

Done.

135. By Graham Binns

Removed silliness.

Revision history for this message
Gavin Panella (allenap) wrote :

Looks good :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'maastest/maasfixture.py'
2--- maastest/maasfixture.py 2014-01-16 14:17:16 +0000
3+++ maastest/maasfixture.py 2014-01-17 10:48:57 +0000
4@@ -181,6 +181,17 @@
5
6 return username, password
7
8+ def dump_data(self):
9+ """Dump the NodeCommissionResult table to stdout.
10+
11+ This allows us to capture the lshw results for commissioned
12+ nodes. This method will be called when the fixture get cleaned
13+ up.
14+ """
15+ return_code, stdout, _ = self.kvm_fixture.run_command([
16+ 'sudo', 'maas', 'dumpdata', 'metadataserver.NodeCommissionResult'
17+ ])
18+
19 def import_maas_images(self, series, architecture):
20 """Import boot images into the MAAS instance.
21
22@@ -254,6 +265,7 @@
23 self.configure_cluster()
24 # Cleanups registration.
25 self.addCleanup(self.collect_logs)
26+ self.addCleanup(self.dump_data)
27 self.log_connection_details()
28
29 def log_connection_details(self):
30
31=== modified file 'maastest/tests/test_maasfixture.py'
32--- maastest/tests/test_maasfixture.py 2014-01-16 14:15:40 +0000
33+++ maastest/tests/test_maasfixture.py 2014-01-17 10:48:57 +0000
34@@ -728,3 +728,15 @@
35 ], check_call=True),
36 kvm_fixture.run_command.mock_calls[-1])
37 self.assertEqual([mock.call(arch)], mock_mipf_arch_list.mock_calls)
38+
39+ def test_dump_data_calls_dumpdata(self):
40+ maas_fixture = self.make_maas_fixture()
41+ self.patch(
42+ maas_fixture.kvm_fixture, 'run_command',
43+ mock.MagicMock(return_value=(0, '', '')))
44+ maas_fixture.dump_data()
45+ self.assertIn(
46+ mock.call([
47+ 'sudo', 'maas', 'dumpdata',
48+ 'metadataserver.NodeCommissionResult']),
49+ maas_fixture.kvm_fixture.run_command.mock_calls)

Subscribers

People subscribed via source and target branches