Merge lp:~aacid/autopilot/dbus_search_no_seen_connections into lp:autopilot
- dbus_search_no_seen_connections
- Merge into trunk
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 | ||||
Related bugs: |
|
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
Description of the change
Albert Astals Cid (aacid) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:549
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Timo Jyrinki (timo-jyrinki) wrote : | # |
Submitted for Autopilot 1.5 (the current release branch) at https:/
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.
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
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:551
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://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:551
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:551
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Christopher Lee (veebers) wrote : | # |
Ugh, seems we're having jenkins/CI issues. Have pinged cihelp so hopefully it gets cleared out soon.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:551
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
Preview Diff
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) |
semi-related to https:/ /bugs.launchpad .net/ubuntu/ +source/ unity8/ +bug/1421009