Merge lp:~allenap/maas/test-decompose-machine--bug-1663517 into lp:~maas-committers/maas/trunk

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 5713
Proposed branch: lp:~allenap/maas/test-decompose-machine--bug-1663517
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 71 lines (+16/-2)
1 file modified
src/provisioningserver/rpc/tests/test_clusterservice.py (+16/-2)
To merge this branch: bzr merge lp:~allenap/maas/test-decompose-machine--bug-1663517
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+316928@code.launchpad.net

Commit message

Run test_calls_decompose_machine in a Twisted-aware runner, and fix.

Run all other clusterservice tests in a Twisted-aware runner too.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/rpc/tests/test_clusterservice.py'
2--- src/provisioningserver/rpc/tests/test_clusterservice.py 2017-02-08 14:39:19 +0000
3+++ src/provisioningserver/rpc/tests/test_clusterservice.py 2017-02-10 09:05:22 +0000
4@@ -169,6 +169,8 @@
5
6 class TestClusterProtocol_Authenticate(MAASTestCase):
7
8+ run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
9+
10 def test_authenticate_is_registered(self):
11 protocol = Cluster()
12 responder = protocol.locateResponder(cluster.Authenticate.commandName)
13@@ -864,6 +866,8 @@
14 }),
15 )
16
17+ run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
18+
19 def make_inert_client_service(self):
20 service = ClusterClientService(Clock())
21 # ClusterClientService's superclass, TimerService, creates a
22@@ -2382,6 +2386,8 @@
23
24 class TestClusterProtocol_AddChassis(MAASTestCase):
25
26+ run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
27+
28 def test__is_registered(self):
29 protocol = Cluster()
30 responder = protocol.locateResponder(
31@@ -2760,6 +2766,8 @@
32
33 class TestClusterProtocol_DiscoverPod(MAASTestCase):
34
35+ run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
36+
37 def test__is_registered(self):
38 protocol = Cluster()
39 responder = protocol.locateResponder(
40@@ -2851,23 +2859,29 @@
41
42 class TestClusterProtocol_DecomposeMachine(MAASTestCase):
43
44+ run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
45+
46 def test__is_registered(self):
47 protocol = Cluster()
48 responder = protocol.locateResponder(
49 cluster.DecomposeMachine.commandName)
50 self.assertIsNotNone(responder)
51
52+ @inlineCallbacks
53 def test_calls_decompose_machine(self):
54 mock_decompose_machine = self.patch_autospec(
55 pods, 'decompose_machine')
56- mock_decompose_machine.return_value = succeed({})
57+ mock_decompose_machine.return_value = succeed({
58+ "hints": DiscoveredPodHints(
59+ cores=1, cpu_speed=2, memory=3, local_storage=4),
60+ })
61 pod_type = factory.make_name('pod_type')
62 context = {
63 "data": factory.make_name("data"),
64 }
65 pod_id = random.randint(1, 100)
66 name = factory.make_name('pod')
67- call_responder(Cluster(), cluster.DecomposeMachine, {
68+ yield call_responder(Cluster(), cluster.DecomposeMachine, {
69 'type': pod_type,
70 'context': context,
71 'pod_id': pod_id,