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

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
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
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.
Revision history for this message
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
diff --git a/src/maasserver/rpc/regionservice.py b/src/maasserver/rpc/regionservice.py
index b622cfb..a68b038 100644
--- a/src/maasserver/rpc/regionservice.py
+++ b/src/maasserver/rpc/regionservice.py
@@ -965,11 +965,10 @@ class RegionService(service.Service, object):
965965
966 @asynchronous(timeout=FOREVER)966 @asynchronous(timeout=FOREVER)
967 def getAllClients(self):967 def getAllClients(self):
968 """Return a list of all connected :class:`common.Client`s."""968 """Return a list with one connection per rack controller."""
969 return [969 return [
970 common.Client(conn)970 common.Client(random.choice(list(conns)))
971 for conns in self.connections.values()971 for conns in self.connections.values()
972 for conn in conns
973 ]972 ]
974973
975 @asynchronous(timeout=FOREVER)974 @asynchronous(timeout=FOREVER)
diff --git a/src/maasserver/rpc/tests/test_regionservice.py b/src/maasserver/rpc/tests/test_regionservice.py
index 33b9678..e845b30 100644
--- a/src/maasserver/rpc/tests/test_regionservice.py
+++ b/src/maasserver/rpc/tests/test_regionservice.py
@@ -100,7 +100,9 @@ from testtools.matchers import (
100 Is,100 Is,
101 IsInstance,101 IsInstance,
102 MatchesAll,102 MatchesAll,
103 MatchesAny,
103 MatchesListwise,104 MatchesListwise,
105 MatchesSetwise,
104 MatchesStructure,106 MatchesStructure,
105 Not,107 Not,
106)108)
@@ -884,10 +886,16 @@ class TestRegionService(MAASTestCase):
884 c4 = DummyConnection()886 c4 = DummyConnection()
885 service.connections[uuid2].update({c3, c4})887 service.connections[uuid2].update({c3, c4})
886 clients = service.getAllClients()888 clients = service.getAllClients()
887 self.assertItemsEqual(clients, {889 self.assertThat(list(clients), MatchesAny(
888 common.Client(c1), common.Client(c2),890 MatchesSetwise(
889 common.Client(c3), common.Client(c4),891 Equals(common.Client(c1)), Equals(common.Client(c3))),
890 })892 MatchesSetwise(
893 Equals(common.Client(c1)), Equals(common.Client(c4))),
894 MatchesSetwise(
895 Equals(common.Client(c2)), Equals(common.Client(c3))),
896 MatchesSetwise(
897 Equals(common.Client(c2)), Equals(common.Client(c4))),
898 ))
891899
892 def test_addConnectionFor_adds_connection(self):900 def test_addConnectionFor_adds_connection(self):
893 service = RegionService(sentinel.advertiser)901 service = RegionService(sentinel.advertiser)

Subscribers

People subscribed via source and target branches