~blake-rouse/maas/action-styles-update-1.8

« back to all changes in this revision

Viewing changes to src/provisioningserver/rpc/tests/test_clusterservice.py

  • Committer: MAAS Lander
  • Author(s): Blake Rouse
  • Date: 2015-08-03 18:20:55 UTC
  • mfrom: (4032.1.1 1.8)
  • Revision ID: maas_lander-20150803182055-8boe370rdp99dskb
[r=blake-rouse][bug=1472707][author=blake-rouse] Add ListBootImagesV2 RPC command. Fallback to using ListBootImages RPC when the ListBootImagesV2 is not handled on the cluster.

The signature of the ListBootImages RPC call was changed to support more data in the response. This change will cause connected clusters that are not updated the same time as the region to stop communicating and error. This allows both methods to exist on the cluster where V2 will be called first then fallback to the older call in error.

Show diffs side-by-side

added added

removed removed

Lines of Context:
220
220
        return d.addCallback(check)
221
221
 
222
222
 
223
 
class TestClusterProtocol_ListBootImages(MAASTestCase):
 
223
class TestClusterProtocol_ListBootImages_and_ListBootImagesV2(MAASTestCase):
224
224
 
225
225
    run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
226
226
 
 
227
    scenarios = (
 
228
        ("ListBootImages", {"rpc_call": cluster.ListBootImages}),
 
229
        ("ListBootImagesV2", {"rpc_call": cluster.ListBootImagesV2}),
 
230
        )
 
231
 
227
232
    def test_list_boot_images_is_registered(self):
228
233
        protocol = Cluster()
229
234
        responder = protocol.locateResponder(
230
 
            cluster.ListBootImages.commandName)
 
235
            self.rpc_call.commandName)
231
236
        self.assertIsNotNone(responder)
232
237
 
233
238
    @inlineCallbacks
236
241
        list_boot_images = self.patch(tftppath, "list_boot_images")
237
242
        list_boot_images.return_value = []
238
243
 
239
 
        response = yield call_responder(Cluster(), cluster.ListBootImages, {})
 
244
        response = yield call_responder(Cluster(), self.rpc_call, {})
240
245
 
241
246
        self.assertEqual({"images": []}, response)
242
247
 
284
289
                expected_image['xinstall_path'] = ''
285
290
                expected_image['xinstall_type'] = ''
286
291
 
287
 
        response = yield call_responder(Cluster(), cluster.ListBootImages, {})
 
292
        response = yield call_responder(Cluster(), self.rpc_call, {})
288
293
 
289
294
        self.assertThat(response, KeysEqual("images"))
290
295
        self.assertItemsEqual(expected_images, response["images"])