Merge ~blake-rouse/maas:get-all-rack-conns-2.2 into maas:2.2

Proposed by Blake Rouse on 2017-07-18
Status: Merged
Approved by: Blake Rouse on 2017-07-18
Approved revision: 6c0a028aba6bbde1b613f6a28eeabc4f916ba148
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~blake-rouse/maas:get-all-rack-conns-2.2
Merge into: maas:2.2
Diff against target: 53 lines (+14/-7)
2 files modified
src/maasserver/rpc/regionservice.py (+2/-3)
src/maasserver/rpc/tests/test_regionservice.py (+12/-4)
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve on 2017-07-18
Review via email: mp+327623@code.launchpad.net

Commit message

Backport f0fa3535e30bf3d3a6a1c437e8f8199ac0bbfeb5: Return only one connection per rack controller from getAllClients. Fixes lp: #1704489.

To post a comment you must log in.
Blake Rouse (blake-rouse) wrote :

Self-approving backport.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/rpc/regionservice.py b/src/maasserver/rpc/regionservice.py
2index b622cfb..a68b038 100644
3--- a/src/maasserver/rpc/regionservice.py
4+++ b/src/maasserver/rpc/regionservice.py
5@@ -965,11 +965,10 @@ class RegionService(service.Service, object):
6
7 @asynchronous(timeout=FOREVER)
8 def getAllClients(self):
9- """Return a list of all connected :class:`common.Client`s."""
10+ """Return a list with one connection per rack controller."""
11 return [
12- common.Client(conn)
13+ common.Client(random.choice(list(conns)))
14 for conns in self.connections.values()
15- for conn in conns
16 ]
17
18 @asynchronous(timeout=FOREVER)
19diff --git a/src/maasserver/rpc/tests/test_regionservice.py b/src/maasserver/rpc/tests/test_regionservice.py
20index 33b9678..e845b30 100644
21--- a/src/maasserver/rpc/tests/test_regionservice.py
22+++ b/src/maasserver/rpc/tests/test_regionservice.py
23@@ -100,7 +100,9 @@ from testtools.matchers import (
24 Is,
25 IsInstance,
26 MatchesAll,
27+ MatchesAny,
28 MatchesListwise,
29+ MatchesSetwise,
30 MatchesStructure,
31 Not,
32 )
33@@ -884,10 +886,16 @@ class TestRegionService(MAASTestCase):
34 c4 = DummyConnection()
35 service.connections[uuid2].update({c3, c4})
36 clients = service.getAllClients()
37- self.assertItemsEqual(clients, {
38- common.Client(c1), common.Client(c2),
39- common.Client(c3), common.Client(c4),
40- })
41+ self.assertThat(list(clients), MatchesAny(
42+ MatchesSetwise(
43+ Equals(common.Client(c1)), Equals(common.Client(c3))),
44+ MatchesSetwise(
45+ Equals(common.Client(c1)), Equals(common.Client(c4))),
46+ MatchesSetwise(
47+ Equals(common.Client(c2)), Equals(common.Client(c3))),
48+ MatchesSetwise(
49+ Equals(common.Client(c2)), Equals(common.Client(c4))),
50+ ))
51
52 def test_addConnectionFor_adds_connection(self):
53 service = RegionService(sentinel.advertiser)

Subscribers

People subscribed via source and target branches

to all changes: