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
1=== modified file 'autopilot/introspection/_search.py'
2--- autopilot/introspection/_search.py 2014-07-31 20:02:49 +0000
3+++ autopilot/introspection/_search.py 2015-04-02 08:29:36 +0000
4@@ -307,17 +307,11 @@
5 while we're searching for it.
6
7 """
8- seen_connections = []
9-
10 for _ in Timeout.default():
11 _get_child_pids.reset_cache()
12 _raise_if_process_has_exited(process)
13
14- connections = _get_buses_unchecked_connection_names(
15- bus,
16- seen_connections
17- )
18- seen_connections.extend(connections)
19+ connections = bus.list_names()
20
21 valid_connections = [
22 c for c
23@@ -345,17 +339,6 @@
24 return process.poll() is None
25
26
27-def _get_buses_unchecked_connection_names(dbus_bus, previous_connections=None):
28- """Return a list of connections found on dbus_bus.
29-
30- If previous_connections is supplied then those connections are removed from
31- the returned list.
32-
33- """
34- all_conns = dbus_bus.list_names()
35- return list(set(all_conns).difference(set(previous_connections or [])))
36-
37-
38 def _dedupe_connections_on_pid(valid_connections, bus):
39 seen_pids = []
40 deduped_connections = []
41
42=== modified file 'autopilot/tests/unit/test_introspection_search.py'
43--- autopilot/tests/unit/test_introspection_search.py 2014-05-29 19:44:44 +0000
44+++ autopilot/tests/unit/test_introspection_search.py 2015-04-02 08:29:36 +0000
45@@ -522,47 +522,6 @@
46 )
47
48
49-class FindMatchingConnectionsTests(TestCase):
50-
51- """Testing the behaviour of _find_matching_connections and helper methods
52- used within.
53-
54- """
55-
56- def test_unchecked_connection_names_returns_all_buses_initially(self):
57- mock_connection_list = ['conn1', 'conn2', 'conn3']
58- dbus_bus = Mock()
59- dbus_bus.list_names = Mock(return_value=mock_connection_list)
60-
61- self.assertThat(
62- _s._get_buses_unchecked_connection_names(dbus_bus),
63- ListContainsOnly(mock_connection_list)
64- )
65-
66- def test_unchecked_connection_names_returns_only_unseen_connections(self):
67- mock_connection_list = ['conn1', 'conn2', 'conn3']
68- dbus_bus = Mock()
69- dbus_bus.list_names = Mock(return_value=mock_connection_list)
70-
71- self.assertThat(
72- _s._get_buses_unchecked_connection_names(dbus_bus, ['conn3']),
73- ListContainsOnly(['conn1', 'conn2'])
74- )
75-
76- def test_unchecked_connection_names_returns_empty_list_when_all_seen(self):
77- mock_connection_list = ['conn1', 'conn2', 'conn3']
78- dbus_bus = Mock()
79- dbus_bus.list_names = Mock(return_value=mock_connection_list)
80-
81- self.assertThat(
82- _s._get_buses_unchecked_connection_names(
83- dbus_bus,
84- mock_connection_list
85- ),
86- Equals([])
87- )
88-
89-
90 class ProcessAndPidErrorCheckingTests(TestCase):
91
92 def test_raises_ProcessSearchError_when_process_is_not_running(self):
93@@ -740,33 +699,34 @@
94 def test_raise_if_not_single_result_doesnt_raise_with_single_result(self):
95 _s._raise_if_not_single_result([1], "")
96
97- @patch.object(_s, '_get_buses_unchecked_connection_names')
98- def test_find_matching_connections_calls_connection_matcher(self, gbycn):
99- gbycn.return_value = ["conn1"]
100- connection_matcher = Mock(return_value=False)
101-
102- with sleep.mocked():
103- _s._find_matching_connections("bus", connection_matcher)
104-
105- connection_matcher.assert_called_with(("bus", "conn1"))
106-
107- @patch.object(_s, '_get_buses_unchecked_connection_names')
108- def test_find_matching_connections_attempts_multiple_times(self, gbycn):
109- gbycn.return_value = ["conn1"]
110- connection_matcher = Mock(return_value=False)
111-
112- with sleep.mocked():
113- _s._find_matching_connections("bus", connection_matcher)
114-
115- connection_matcher.assert_called_with(("bus", "conn1"))
116+ class FMCTest:
117+ def list_names(self):
118+ return ["conn1"]
119+
120+ def test_find_matching_connections_calls_connection_matcher(self):
121+ bus = ProxyObjectTests.FMCTest()
122+ connection_matcher = Mock(return_value=False)
123+
124+ with sleep.mocked():
125+ _s._find_matching_connections(bus, connection_matcher)
126+
127+ connection_matcher.assert_called_with((bus, "conn1"))
128+
129+ def test_find_matching_connections_attempts_multiple_times(self):
130+ bus = ProxyObjectTests.FMCTest()
131+ connection_matcher = Mock(return_value=False)
132+
133+ with sleep.mocked():
134+ _s._find_matching_connections(bus, connection_matcher)
135+
136+ connection_matcher.assert_called_with((bus, "conn1"))
137 self.assertEqual(connection_matcher.call_count, 11)
138
139- @patch.object(_s, '_get_buses_unchecked_connection_names')
140- def test_find_matching_connections_dedupes_results_on_pid(self, gbycn):
141- gbycn.return_value = ["conn1"]
142+ def test_find_matching_connections_dedupes_results_on_pid(self):
143+ bus = ProxyObjectTests.FMCTest()
144
145 with patch.object(_s, '_dedupe_connections_on_pid') as dedupe:
146 with sleep.mocked():
147- _s._find_matching_connections("bus", lambda *args: True)
148+ _s._find_matching_connections(bus, lambda *args: True)
149
150- dedupe.assert_called_once_with(["conn1"], "bus")
151+ dedupe.assert_called_once_with(["conn1"], bus)

Subscribers

People subscribed via source and target branches