Merge lp:~nskaggs/autopilot/catch-stateerror-printtree into lp:autopilot

Proposed by Nicholas Skaggs
Status: Superseded
Proposed branch: lp:~nskaggs/autopilot/catch-stateerror-printtree
Merge into: lp:autopilot
Prerequisite: lp:~thomir-deactivatedaccount/autopilot/trunk-make-print-tree-faster
Diff against target: 68 lines (+28/-6)
2 files modified
autopilot/introspection/dbus.py (+10/-6)
autopilot/tests/unit/test_introspection_features.py (+18/-0)
To merge this branch: bzr merge lp:~nskaggs/autopilot/catch-stateerror-printtree
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Chris Gagnon Pending
Thomi Richards Pending
Max Brustkern Pending
Review via email: mp+212053@code.launchpad.net

This proposal supersedes a proposal from 2014-02-05.

Commit message

Add support to complete dump even if a StateNotFound error occurs.

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.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Gagnon (chris.gagnon) wrote : Posted in a previous version of this proposal

This needs tests

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote : Posted in a previous version of this proposal

@ChrisGagnon, I'll try playing with AssertRaises to add a test for this path.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote : Posted in a previous version of this proposal

Setting this back to a WIP MP since we all agree that it needs tests before being merged.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote : Posted in a previous version of this proposal

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

review: Needs Fixing
Revision history for this message
Nicholas Skaggs (nskaggs) wrote : Posted in a previous version of this proposal

Argh, bzr lost my changes I made.. they never pushed I see. I'll redo.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Max Brustkern (nuclearbob) wrote : Posted in a previous version of this proposal

Seems reasonable to me.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote : Posted in a previous version of this proposal

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(self.get_properties()):

to

for prop, value in sorted(self.get_properties().items()):

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 = DBusIntrospectionObject(
            dict(id=[0, 123], path=[0, '/some/path'], text=[0, 'Hello']),
            '/some/path',
            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
               path: '/some/path/child'
               text: 'Hello Child'
                == /some/path/child2 ==
               id: 789
               path: '/some/path/child2'
               text: 'Hello Child2'
            == /some/other/path ==
            id: 542
            path: '/some/other/path'
            text: 'Hello'

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote : Posted in a previous version of this proposal

Hi,

I doubt that turning this:

for p in sorted(self.get_properties()):

into this:

for prop, value in sorted(self.get_properties().items()):

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 :-)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Something in the tweaks breaks things:

Checkout this branch

lp:~nskaggs/ubuntu-calendar-app/test-print-tree

Running calendar_app.tests.test_calendar.TestMainView.test_dump takes about 100 seconds to do a good print. Under the proposed changes it seems to get stuck reexamining objects again and again, never finishing.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:442
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://code.launchpad.net/~nskaggs/autopilot/catch-stateerror-printtree/+merge/212053/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/autopilot-ci/608/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-trusty-amd64-ci/334
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-trusty-amd64-ci/334/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-trusty-armhf-ci/334
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-trusty-armhf-ci/334/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-trusty-i386-ci/243
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-trusty-i386-ci/243/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-autopilot/60
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty-autopilot/57
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4200
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4200/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/autopilot-ci/608/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Thomi says I'm dreaming and it works for him, so +1.

review: Approve

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'autopilot/introspection/dbus.py'
--- autopilot/introspection/dbus.py 2014-03-20 21:26:27 +0000
+++ autopilot/introspection/dbus.py 2014-03-20 21:26:27 +0000
@@ -262,6 +262,7 @@
262 # Thomi: 2014-03-20: There used to be a call to 'self.refresh_state()'262 # Thomi: 2014-03-20: There used to be a call to 'self.refresh_state()'
263 # here. That's not needed, since the only thing we use is the proxy263 # here. That's not needed, since the only thing we use is the proxy
264 # path, which isn't affected by the current state.264 # path, which isn't affected by the current state.
265
265 query = self.get_class_query_string() + "/*"266 query = self.get_class_query_string() + "/*"
266 state_dicts = self.get_state_by_path(query)267 state_dicts = self.get_state_by_path(query)
267 children = [self.make_introspection_object(i) for i in state_dicts]268 children = [self.make_introspection_object(i) for i in state_dicts]
@@ -661,12 +662,15 @@
661 else:662 else:
662 properties = self.get_properties()663 properties = self.get_properties()
663 # print properties664 # print properties
664 for key in sorted(properties.keys()):665 try:
665 output.write("%s%s: %r\n" % (indent, key, properties[key]))666 for key in sorted(properties.keys()):
666 # print children667 output.write("%s%s: %r\n" % (indent, key, properties[key]))
667 if maxdepth is None or _curdepth < maxdepth:668 # print children
668 for c in self.get_children():669 if maxdepth is None or _curdepth < maxdepth:
669 c.print_tree(output, maxdepth, _curdepth + 1)670 for c in self.get_children():
671 c.print_tree(output, maxdepth, _curdepth + 1)
672 except StateNotFoundError as error:
673 output.write("%sError: %s\n" % (indent, error))
670674
671 @contextmanager675 @contextmanager
672 def no_automatic_refreshing(self):676 def no_automatic_refreshing(self):
673677
=== modified file 'autopilot/tests/unit/test_introspection_features.py'
--- autopilot/tests/unit/test_introspection_features.py 2014-03-11 17:36:53 +0000
+++ autopilot/tests/unit/test_introspection_features.py 2014-03-20 21:26:27 +0000
@@ -55,6 +55,7 @@
55 _object_passes_filters,55 _object_passes_filters,
56 CustomEmulatorBase,56 CustomEmulatorBase,
57 DBusIntrospectionObject,57 DBusIntrospectionObject,
58 StateNotFoundError,
58)59)
59from autopilot.utilities import sleep60from autopilot.utilities import sleep
6061
@@ -305,6 +306,23 @@
305 text: 'Hello'306 text: 'Hello'
306 """))307 """))
307308
309 def test_print_tree_exception(self):
310 """print_tree with StateNotFound exception"""
311
312 fake_object = self._print_test_fake_object()
313 child = Mock()
314 child.print_tree.side_effect = StateNotFoundError('child')
315
316 with patch.object(fake_object, 'get_children', return_value=[child]):
317 out = StringIO()
318 print_func = lambda: fake_object.print_tree(out)
319 self.assertThat(print_func, Not(Raises(StateNotFoundError)))
320 self.assertEqual(out.getvalue(), dedent("""\
321 == /some/path ==
322 id: 123
323 Error: Object not found with name 'child'.
324 """))
325
308 def test_print_tree_fileobj(self):326 def test_print_tree_fileobj(self):
309 """print_tree with file object output"""327 """print_tree with file object output"""
310328

Subscribers

People subscribed via source and target branches