Merge lp:~aacid/autopilot/dbus_search_no_seen_connections into lp:autopilot

Proposed by Albert Astals Cid
Status: Merged
Merged at revision: 550
Proposed branch: lp:~aacid/autopilot/dbus_search_no_seen_connections
Merge into: lp:autopilot
Diff against target: 151 lines (+26/-83)
2 files modified
autopilot/introspection/_search.py (+1/-18)
autopilot/tests/unit/test_introspection_search.py (+25/-65)
To merge this branch: bzr merge lp:~aacid/autopilot/dbus_search_no_seen_connections
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Christopher Lee (community) Needs Fixing
Review via email: mp+254109@code.launchpad.net

Commit message

Do not store seen_connections

Paths can appear later than the bus has been created, so storing a bus to ignore it in the next loop can
make it ignore a bus that did not have the match previously but now does

To post a comment you must log in.
Revision history for this message
Albert Astals Cid (aacid) wrote :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:549
http://jenkins.qa.ubuntu.com/job/autopilot-ci/1033/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-amd64-ci/96
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-amd64-ci/96/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-armhf-ci/96
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-armhf-ci/96/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-i386-ci/96
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-i386-ci/96/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/1972
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-vivid-autopilot/141
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/1739
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/1970
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/1970/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/19156
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-vivid-autopilot/143
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-amd64/892
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-amd64/892/artifact/work/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :
Revision history for this message
Christopher Lee (veebers) wrote :

Good catch, this may make the search for a process take a little longer but I can't see another solution off the top of my head.

Generally looking good, have one concern listed inline with the diff.

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

Done, not a python devel myself so the way i sorted the tests cases may not be the best, suggestions welcome

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Christopher Lee (veebers) wrote :

Ugh, seems we're having jenkins/CI issues. Have pinged cihelp so hopefully it gets cleared out soon.

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

PASSED: Continuous integration, rev:551
http://jenkins.qa.ubuntu.com/job/autopilot-ci/1037/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-amd64-ci/100
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-amd64-ci/100/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-armhf-ci/100
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-armhf-ci/100/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-i386-ci/104
        deb: http://jenkins.qa.ubuntu.com/job/autopilot-vivid-i386-ci/104/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/2134
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-vivid-autopilot/147
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/1880
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/2132
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/2132/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/19457
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-vivid-autopilot/149
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-amd64/930
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-amd64/930/artifact/work/output/*zip*/output.zip

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

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'autopilot/introspection/_search.py'
--- autopilot/introspection/_search.py 2014-07-31 20:02:49 +0000
+++ autopilot/introspection/_search.py 2015-04-02 08:29:36 +0000
@@ -307,17 +307,11 @@
307 while we're searching for it.307 while we're searching for it.
308308
309 """309 """
310 seen_connections = []
311
312 for _ in Timeout.default():310 for _ in Timeout.default():
313 _get_child_pids.reset_cache()311 _get_child_pids.reset_cache()
314 _raise_if_process_has_exited(process)312 _raise_if_process_has_exited(process)
315313
316 connections = _get_buses_unchecked_connection_names(314 connections = bus.list_names()
317 bus,
318 seen_connections
319 )
320 seen_connections.extend(connections)
321315
322 valid_connections = [316 valid_connections = [
323 c for c317 c for c
@@ -345,17 +339,6 @@
345 return process.poll() is None339 return process.poll() is None
346340
347341
348def _get_buses_unchecked_connection_names(dbus_bus, previous_connections=None):
349 """Return a list of connections found on dbus_bus.
350
351 If previous_connections is supplied then those connections are removed from
352 the returned list.
353
354 """
355 all_conns = dbus_bus.list_names()
356 return list(set(all_conns).difference(set(previous_connections or [])))
357
358
359def _dedupe_connections_on_pid(valid_connections, bus):342def _dedupe_connections_on_pid(valid_connections, bus):
360 seen_pids = []343 seen_pids = []
361 deduped_connections = []344 deduped_connections = []
362345
=== modified file 'autopilot/tests/unit/test_introspection_search.py'
--- autopilot/tests/unit/test_introspection_search.py 2014-05-29 19:44:44 +0000
+++ autopilot/tests/unit/test_introspection_search.py 2015-04-02 08:29:36 +0000
@@ -522,47 +522,6 @@
522 )522 )
523523
524524
525class FindMatchingConnectionsTests(TestCase):
526
527 """Testing the behaviour of _find_matching_connections and helper methods
528 used within.
529
530 """
531
532 def test_unchecked_connection_names_returns_all_buses_initially(self):
533 mock_connection_list = ['conn1', 'conn2', 'conn3']
534 dbus_bus = Mock()
535 dbus_bus.list_names = Mock(return_value=mock_connection_list)
536
537 self.assertThat(
538 _s._get_buses_unchecked_connection_names(dbus_bus),
539 ListContainsOnly(mock_connection_list)
540 )
541
542 def test_unchecked_connection_names_returns_only_unseen_connections(self):
543 mock_connection_list = ['conn1', 'conn2', 'conn3']
544 dbus_bus = Mock()
545 dbus_bus.list_names = Mock(return_value=mock_connection_list)
546
547 self.assertThat(
548 _s._get_buses_unchecked_connection_names(dbus_bus, ['conn3']),
549 ListContainsOnly(['conn1', 'conn2'])
550 )
551
552 def test_unchecked_connection_names_returns_empty_list_when_all_seen(self):
553 mock_connection_list = ['conn1', 'conn2', 'conn3']
554 dbus_bus = Mock()
555 dbus_bus.list_names = Mock(return_value=mock_connection_list)
556
557 self.assertThat(
558 _s._get_buses_unchecked_connection_names(
559 dbus_bus,
560 mock_connection_list
561 ),
562 Equals([])
563 )
564
565
566class ProcessAndPidErrorCheckingTests(TestCase):525class ProcessAndPidErrorCheckingTests(TestCase):
567526
568 def test_raises_ProcessSearchError_when_process_is_not_running(self):527 def test_raises_ProcessSearchError_when_process_is_not_running(self):
@@ -740,33 +699,34 @@
740 def test_raise_if_not_single_result_doesnt_raise_with_single_result(self):699 def test_raise_if_not_single_result_doesnt_raise_with_single_result(self):
741 _s._raise_if_not_single_result([1], "")700 _s._raise_if_not_single_result([1], "")
742701
743 @patch.object(_s, '_get_buses_unchecked_connection_names')702 class FMCTest:
744 def test_find_matching_connections_calls_connection_matcher(self, gbycn):703 def list_names(self):
745 gbycn.return_value = ["conn1"]704 return ["conn1"]
746 connection_matcher = Mock(return_value=False)705
747706 def test_find_matching_connections_calls_connection_matcher(self):
748 with sleep.mocked():707 bus = ProxyObjectTests.FMCTest()
749 _s._find_matching_connections("bus", connection_matcher)708 connection_matcher = Mock(return_value=False)
750709
751 connection_matcher.assert_called_with(("bus", "conn1"))710 with sleep.mocked():
752711 _s._find_matching_connections(bus, connection_matcher)
753 @patch.object(_s, '_get_buses_unchecked_connection_names')712
754 def test_find_matching_connections_attempts_multiple_times(self, gbycn):713 connection_matcher.assert_called_with((bus, "conn1"))
755 gbycn.return_value = ["conn1"]714
756 connection_matcher = Mock(return_value=False)715 def test_find_matching_connections_attempts_multiple_times(self):
757716 bus = ProxyObjectTests.FMCTest()
758 with sleep.mocked():717 connection_matcher = Mock(return_value=False)
759 _s._find_matching_connections("bus", connection_matcher)718
760719 with sleep.mocked():
761 connection_matcher.assert_called_with(("bus", "conn1"))720 _s._find_matching_connections(bus, connection_matcher)
721
722 connection_matcher.assert_called_with((bus, "conn1"))
762 self.assertEqual(connection_matcher.call_count, 11)723 self.assertEqual(connection_matcher.call_count, 11)
763724
764 @patch.object(_s, '_get_buses_unchecked_connection_names')725 def test_find_matching_connections_dedupes_results_on_pid(self):
765 def test_find_matching_connections_dedupes_results_on_pid(self, gbycn):726 bus = ProxyObjectTests.FMCTest()
766 gbycn.return_value = ["conn1"]
767727
768 with patch.object(_s, '_dedupe_connections_on_pid') as dedupe:728 with patch.object(_s, '_dedupe_connections_on_pid') as dedupe:
769 with sleep.mocked():729 with sleep.mocked():
770 _s._find_matching_connections("bus", lambda *args: True)730 _s._find_matching_connections(bus, lambda *args: True)
771731
772 dedupe.assert_called_once_with(["conn1"], "bus")732 dedupe.assert_called_once_with(["conn1"], bus)

Subscribers

People subscribed via source and target branches