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:
|
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
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Albert Astals Cid (aacid) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Timo Jyrinki (timo-jyrinki) wrote : | # |
Submitted for Autopilot 1.5 (the current release branch) at https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Christopher Lee (veebers) wrote : | # |
Ugh, seems we're having jenkins/CI issues. Have pinged cihelp so hopefully it gets cleared out soon.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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 | 307 | while we're searching for it. | 307 | while we're searching for it. |
6 | 308 | 308 | ||
7 | 309 | """ | 309 | """ |
8 | 310 | seen_connections = [] | ||
9 | 311 | |||
10 | 312 | for _ in Timeout.default(): | 310 | for _ in Timeout.default(): |
11 | 313 | _get_child_pids.reset_cache() | 311 | _get_child_pids.reset_cache() |
12 | 314 | _raise_if_process_has_exited(process) | 312 | _raise_if_process_has_exited(process) |
13 | 315 | 313 | ||
19 | 316 | connections = _get_buses_unchecked_connection_names( | 314 | connections = bus.list_names() |
15 | 317 | bus, | ||
16 | 318 | seen_connections | ||
17 | 319 | ) | ||
18 | 320 | seen_connections.extend(connections) | ||
20 | 321 | 315 | ||
21 | 322 | valid_connections = [ | 316 | valid_connections = [ |
22 | 323 | c for c | 317 | c for c |
23 | @@ -345,17 +339,6 @@ | |||
24 | 345 | return process.poll() is None | 339 | return process.poll() is None |
25 | 346 | 340 | ||
26 | 347 | 341 | ||
27 | 348 | def _get_buses_unchecked_connection_names(dbus_bus, previous_connections=None): | ||
28 | 349 | """Return a list of connections found on dbus_bus. | ||
29 | 350 | |||
30 | 351 | If previous_connections is supplied then those connections are removed from | ||
31 | 352 | the returned list. | ||
32 | 353 | |||
33 | 354 | """ | ||
34 | 355 | all_conns = dbus_bus.list_names() | ||
35 | 356 | return list(set(all_conns).difference(set(previous_connections or []))) | ||
36 | 357 | |||
37 | 358 | |||
38 | 359 | def _dedupe_connections_on_pid(valid_connections, bus): | 342 | def _dedupe_connections_on_pid(valid_connections, bus): |
39 | 360 | seen_pids = [] | 343 | seen_pids = [] |
40 | 361 | deduped_connections = [] | 344 | deduped_connections = [] |
41 | 362 | 345 | ||
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 | 522 | ) | 522 | ) |
47 | 523 | 523 | ||
48 | 524 | 524 | ||
49 | 525 | class FindMatchingConnectionsTests(TestCase): | ||
50 | 526 | |||
51 | 527 | """Testing the behaviour of _find_matching_connections and helper methods | ||
52 | 528 | used within. | ||
53 | 529 | |||
54 | 530 | """ | ||
55 | 531 | |||
56 | 532 | def test_unchecked_connection_names_returns_all_buses_initially(self): | ||
57 | 533 | mock_connection_list = ['conn1', 'conn2', 'conn3'] | ||
58 | 534 | dbus_bus = Mock() | ||
59 | 535 | dbus_bus.list_names = Mock(return_value=mock_connection_list) | ||
60 | 536 | |||
61 | 537 | self.assertThat( | ||
62 | 538 | _s._get_buses_unchecked_connection_names(dbus_bus), | ||
63 | 539 | ListContainsOnly(mock_connection_list) | ||
64 | 540 | ) | ||
65 | 541 | |||
66 | 542 | def test_unchecked_connection_names_returns_only_unseen_connections(self): | ||
67 | 543 | mock_connection_list = ['conn1', 'conn2', 'conn3'] | ||
68 | 544 | dbus_bus = Mock() | ||
69 | 545 | dbus_bus.list_names = Mock(return_value=mock_connection_list) | ||
70 | 546 | |||
71 | 547 | self.assertThat( | ||
72 | 548 | _s._get_buses_unchecked_connection_names(dbus_bus, ['conn3']), | ||
73 | 549 | ListContainsOnly(['conn1', 'conn2']) | ||
74 | 550 | ) | ||
75 | 551 | |||
76 | 552 | def test_unchecked_connection_names_returns_empty_list_when_all_seen(self): | ||
77 | 553 | mock_connection_list = ['conn1', 'conn2', 'conn3'] | ||
78 | 554 | dbus_bus = Mock() | ||
79 | 555 | dbus_bus.list_names = Mock(return_value=mock_connection_list) | ||
80 | 556 | |||
81 | 557 | self.assertThat( | ||
82 | 558 | _s._get_buses_unchecked_connection_names( | ||
83 | 559 | dbus_bus, | ||
84 | 560 | mock_connection_list | ||
85 | 561 | ), | ||
86 | 562 | Equals([]) | ||
87 | 563 | ) | ||
88 | 564 | |||
89 | 565 | |||
90 | 566 | class ProcessAndPidErrorCheckingTests(TestCase): | 525 | class ProcessAndPidErrorCheckingTests(TestCase): |
91 | 567 | 526 | ||
92 | 568 | def test_raises_ProcessSearchError_when_process_is_not_running(self): | 527 | def test_raises_ProcessSearchError_when_process_is_not_running(self): |
93 | @@ -740,33 +699,34 @@ | |||
94 | 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): |
95 | 741 | _s._raise_if_not_single_result([1], "") | 700 | _s._raise_if_not_single_result([1], "") |
96 | 742 | 701 | ||
116 | 743 | @patch.object(_s, '_get_buses_unchecked_connection_names') | 702 | class FMCTest: |
117 | 744 | def test_find_matching_connections_calls_connection_matcher(self, gbycn): | 703 | def list_names(self): |
118 | 745 | gbycn.return_value = ["conn1"] | 704 | return ["conn1"] |
119 | 746 | connection_matcher = Mock(return_value=False) | 705 | |
120 | 747 | 706 | def test_find_matching_connections_calls_connection_matcher(self): | |
121 | 748 | with sleep.mocked(): | 707 | bus = ProxyObjectTests.FMCTest() |
122 | 749 | _s._find_matching_connections("bus", connection_matcher) | 708 | connection_matcher = Mock(return_value=False) |
123 | 750 | 709 | ||
124 | 751 | connection_matcher.assert_called_with(("bus", "conn1")) | 710 | with sleep.mocked(): |
125 | 752 | 711 | _s._find_matching_connections(bus, connection_matcher) | |
126 | 753 | @patch.object(_s, '_get_buses_unchecked_connection_names') | 712 | |
127 | 754 | def test_find_matching_connections_attempts_multiple_times(self, gbycn): | 713 | connection_matcher.assert_called_with((bus, "conn1")) |
128 | 755 | gbycn.return_value = ["conn1"] | 714 | |
129 | 756 | connection_matcher = Mock(return_value=False) | 715 | def test_find_matching_connections_attempts_multiple_times(self): |
130 | 757 | 716 | bus = ProxyObjectTests.FMCTest() | |
131 | 758 | with sleep.mocked(): | 717 | connection_matcher = Mock(return_value=False) |
132 | 759 | _s._find_matching_connections("bus", connection_matcher) | 718 | |
133 | 760 | 719 | with sleep.mocked(): | |
134 | 761 | connection_matcher.assert_called_with(("bus", "conn1")) | 720 | _s._find_matching_connections(bus, connection_matcher) |
135 | 721 | |||
136 | 722 | connection_matcher.assert_called_with((bus, "conn1")) | ||
137 | 762 | self.assertEqual(connection_matcher.call_count, 11) | 723 | self.assertEqual(connection_matcher.call_count, 11) |
138 | 763 | 724 | ||
142 | 764 | @patch.object(_s, '_get_buses_unchecked_connection_names') | 725 | def test_find_matching_connections_dedupes_results_on_pid(self): |
143 | 765 | def test_find_matching_connections_dedupes_results_on_pid(self, gbycn): | 726 | bus = ProxyObjectTests.FMCTest() |
141 | 766 | gbycn.return_value = ["conn1"] | ||
144 | 767 | 727 | ||
145 | 768 | with patch.object(_s, '_dedupe_connections_on_pid') as dedupe: | 728 | with patch.object(_s, '_dedupe_connections_on_pid') as dedupe: |
146 | 769 | with sleep.mocked(): | 729 | with sleep.mocked(): |
148 | 770 | _s._find_matching_connections("bus", lambda *args: True) | 730 | _s._find_matching_connections(bus, lambda *args: True) |
149 | 771 | 731 | ||
151 | 772 | dedupe.assert_called_once_with(["conn1"], "bus") | 732 | dedupe.assert_called_once_with(["conn1"], bus) |
semi-related to https:/ /bugs.launchpad .net/ubuntu/ +source/ unity8/ +bug/1421009