Merge lp:~nskaggs/autopilot/catch-stateerror-printtree into lp:autopilot
- catch-stateerror-printtree
- Merge into trunk
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~nskaggs/autopilot/catch-stateerror-printtree | ||||
Merge into: | lp:autopilot | ||||
Diff against target: |
60 lines (+27/-6) 2 files modified
autopilot/introspection/dbus.py (+9/-6) autopilot/tests/unit/test_introspection_features.py (+18/-0) |
||||
To merge this branch: | bzr merge lp:~nskaggs/autopilot/catch-stateerror-printtree | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Needs Fixing | |
Max Brustkern (community) | Approve | ||
Thomi Richards (community) | Needs Fixing | ||
Chris Gagnon (community) | Needs Fixing | ||
Review via email:
|
This proposal has been superseded by a proposal from 2014-03-20.
Commit message
Ignore statenotfound errors in print_tree
Description of the change
Dumping the object tree with print_tree often fails to complete due to StateNotFound errors. This modifies the print call to catch these errors and continue to print the largest possible tree. Other errors could be considered as well to try and print as complete a dump as possible.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Chris Gagnon (chris.gagnon) wrote : | # |
This needs tests
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:424
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:425
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:426
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:427
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Nicholas Skaggs (nskaggs) wrote : | # |
@ChrisGagnon, I'll try playing with AssertRaises to add a test for this path.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Thomi Richards (thomir-deactivatedaccount) wrote : | # |
Setting this back to a WIP MP since we all agree that it needs tests before being merged.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:432
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:432
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:432
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:432
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:433
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Thomi Richards (thomir-deactivatedaccount) wrote : | # |
Hi
at the end of your test, could you please add an assertion for the error message you expect to see?
Please set this MP back to 'Needs review' when you want another review.
Thanks
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Nicholas Skaggs (nskaggs) wrote : | # |
Argh, bzr lost my changes I made.. they never pushed I see. I'll redo.
- 437. By Nicholas Skaggs
-
revert accidental whitespace removal
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:437
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:437
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:437
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Max Brustkern (nuclearbob) wrote : | # |
Seems reasonable to me.
- 438. By Nicholas Skaggs
-
leaving sorting alone, but otherwise dropping gettr for direct print from dict
- 439. By Nicholas Skaggs
-
%r for prints
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:438
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:439
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Nicholas Skaggs (nskaggs) wrote : | # |
I have concerns this may have introduced an issue with print_tree, which is not shown by the tests. The dump seems to get stuck in the regression loop. Namely the change from
for p in sorted(
to
for prop, value in sorted(
is the likely cause.
Can someone help setup a test object that contains a larger tree to vet these changes a bit better?
We create a fake object like so:
fake_object = DBusIntrospecti
Mock()
)
I tried making the dict larger but failed. I'm missing something basic; how can i make a tree like this?
== /some/path ==
id: 123
path: '/some/path'
text: 'Hello'
== /some/path/child ==
id: 456
== /some/path/child2 ==
id: 789
== /some/other/path ==
id: 542
path: '/some/other/path'
text: 'Hello'
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Thomi Richards (thomir-deactivatedaccount) wrote : | # |
Hi,
I doubt that turning this:
for p in sorted(
into this:
for prop, value in sorted(
Is the cause of your problems. You're correct though - we need a better way to create fake proxy objects. This is something I've been thinking about for a looong time.
I suggest that you merge in my branch, which already has many of the changes in here, and add your exception handling and test code.
- 440. By Nicholas Skaggs
-
merge thomi's tweaks
- 441. By Nicholas Skaggs
-
tweak merge
- 442. By Nicholas Skaggs
-
fix spacing :-)
Unmerged revisions
Preview Diff
1 | === modified file 'autopilot/introspection/dbus.py' |
2 | --- autopilot/introspection/dbus.py 2014-03-11 16:39:25 +0000 |
3 | +++ autopilot/introspection/dbus.py 2014-03-19 22:17:49 +0000 |
4 | @@ -651,12 +651,15 @@ |
5 | output.write("\n") |
6 | output.write("%s== %s ==\n" % (indent, self._path)) |
7 | # print properties |
8 | - for p in sorted(self.get_properties()): |
9 | - output.write("%s%s: %s\n" % (indent, p, repr(getattr(self, p)))) |
10 | - # print children |
11 | - if maxdepth is None or _curdepth < maxdepth: |
12 | - for c in self.get_children(): |
13 | - c.print_tree(output, maxdepth, _curdepth + 1) |
14 | + try: |
15 | + for prop, value in sorted(self.get_properties().items()): |
16 | + output.write("%s%s: %r\n" % (indent, prop, value)) |
17 | + # print children |
18 | + if maxdepth is None or _curdepth < maxdepth: |
19 | + for c in self.get_children(): |
20 | + c.print_tree(output, maxdepth, _curdepth + 1) |
21 | + except StateNotFoundError as error: |
22 | + output.write("%sError: %s\n" % (indent, error)) |
23 | |
24 | @contextmanager |
25 | def no_automatic_refreshing(self): |
26 | |
27 | === modified file 'autopilot/tests/unit/test_introspection_features.py' |
28 | --- autopilot/tests/unit/test_introspection_features.py 2014-03-11 17:36:53 +0000 |
29 | +++ autopilot/tests/unit/test_introspection_features.py 2014-03-19 22:17:49 +0000 |
30 | @@ -55,6 +55,7 @@ |
31 | _object_passes_filters, |
32 | CustomEmulatorBase, |
33 | DBusIntrospectionObject, |
34 | + StateNotFoundError, |
35 | ) |
36 | from autopilot.utilities import sleep |
37 | |
38 | @@ -305,6 +306,23 @@ |
39 | text: 'Hello' |
40 | """)) |
41 | |
42 | + def test_print_tree_exception(self): |
43 | + """print_tree with StateNotFound exception""" |
44 | + |
45 | + fake_object = self._print_test_fake_object() |
46 | + child = Mock() |
47 | + child.print_tree.side_effect = StateNotFoundError('child') |
48 | + |
49 | + with patch.object(fake_object, 'get_children', return_value=[child]): |
50 | + out = StringIO() |
51 | + print_func = lambda: fake_object.print_tree(out) |
52 | + self.assertThat(print_func, Not(Raises(StateNotFoundError))) |
53 | + self.assertEqual(out.getvalue(), dedent("""\ |
54 | + == /some/path == |
55 | + id: 123 |
56 | + Error: Object not found with name 'child'. |
57 | + """)) |
58 | + |
59 | def test_print_tree_fileobj(self): |
60 | """print_tree with file object output""" |
61 |
FAILED: Continuous integration, rev:421 /code.launchpad .net/~nskaggs/ autopilot/ catch-stateerro r-printtree/ +merge/ 204976/ +edit-commit- message
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http:// jenkins. qa.ubuntu. com/job/ autopilot- ci/462/ jenkins. qa.ubuntu. com/job/ autopilot- trusty- amd64-ci/ 188/console jenkins. qa.ubuntu. com/job/ autopilot- trusty- armhf-ci/ 188/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty/ 2917/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/2919/ console
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/autopilot- ci/462/ rebuild
http://