Esempio n. 1
0
    def test_fallback_to_ListBootImages_on_old_clusters(self):
        rack_1 = factory.make_RackController()
        rack_2 = factory.make_RackController()
        rack_3 = factory.make_RackController()

        images = [make_rpc_boot_image() for _ in range(3)]

        # Limit the region's event loop to only the "rpc" service.
        self.useFixture(RegionEventLoopFixture("rpc"))
        # Now start the region's event loop.
        self.useFixture(RunningEventLoopFixture())
        # This fixture allows us to simulate mock clusters.
        rpc = self.useFixture(MockLiveRegionToClusterRPCFixture())

        # This simulates an older cluster, one without ListBootImagesV2.
        rack_1 = rpc.makeCluster(rack_1, ListBootImages)
        rack_1.ListBootImages.return_value = succeed({"images": images})

        # This simulates a newer cluster, one with ListBootImagesV2.
        rack_2 = rpc.makeCluster(rack_2, ListBootImagesV2)
        rack_2.ListBootImagesV2.return_value = succeed({"images": images})

        # This simulates a broken cluster.
        rack_3 = rpc.makeCluster(rack_3, ListBootImagesV2)
        rack_3.ListBootImagesV2.side_effect = ZeroDivisionError

        self.assertItemsEqual(images, self.get())
Esempio n. 2
0
 def setUp(self):
     super().setUp()
     # Limit the region's event loop to only the "rpc" service.
     self.useFixture(RegionEventLoopFixture("rpc"))
     # Now start the region's event loop.
     self.useFixture(RunningEventLoopFixture())
     # This fixture allows us to simulate mock clusters.
     self.rpc = self.useFixture(MockLiveRegionToClusterRPCFixture())
Esempio n. 3
0
    def prepare_rack_rpc(self):
        rack_controller = factory.make_RackController()
        self.useFixture(RegionEventLoopFixture('rpc'))
        self.useFixture(RunningEventLoopFixture())

        fixture = self.useFixture(MockLiveRegionToClusterRPCFixture())
        protocol = fixture.makeCluster(rack_controller)
        return protocol
Esempio n. 4
0
    def prepare_rack_rpc(self):
        rack_controller = factory.make_RackController()
        self.useFixture(RegionEventLoopFixture('rpc'))
        self.useFixture(RunningEventLoopFixture())

        fixture = self.useFixture(MockLiveRegionToClusterRPCFixture())
        protocol = fixture.makeCluster(rack_controller, DescribePowerTypes)
        self.power_types = PowerDriverRegistry.get_schema()
        protocol.DescribePowerTypes.side_effect = always_succeed_with(
            {'power_types': self.power_types})
        return protocol
Esempio n. 5
0
 def setUp(self):
     super(PreseedRPCMixin, self).setUp()
     self.useFixture(RegionEventLoopFixture("rpc"))
     self.useFixture(RunningEventLoopFixture())
     self.rpc_fixture = MockLiveRegionToClusterRPCFixture()
     self.useFixture(self.rpc_fixture)
     # Create a cluster that's connected by RPC that responds to the
     # GetPreseedData call with a simple NotImplementedError.
     self.rpc_rack_controller = factory.make_RackController()
     self.rpc_cluster = self.rpc_fixture.makeCluster(
         self.rpc_rack_controller, GetPreseedData)
     self.rpc_cluster.GetPreseedData.side_effect = (NotImplementedError())
Esempio n. 6
0
 def prepare_live_rpc(self):
     self.useFixture(RegionEventLoopFixture("rpc"))
     self.useFixture(RunningEventLoopFixture())
     return self.useFixture(MockLiveRegionToClusterRPCFixture())
Esempio n. 7
0
 def setUp(self):
     super().setUp()
     self.useFixture(RegionEventLoopFixture("rpc"))
     self.useFixture(RunningEventLoopFixture())
     self.useFixture(MockRegionToClusterRPCFixture())
Esempio n. 8
0
 def setUp(self):
     super(RunningClusterRPCFixture, self).setUp()
     self.useFixture(RegionEventLoopFixture("rpc"))
     self.useFixture(RunningEventLoopFixture())
     self.useFixture(ClusterRPCFixture())
Esempio n. 9
0
    def get_rack_rpc_protocol(self, rack_controller, *commands):
        self.useFixture(RegionEventLoopFixture("rpc"))
        self.useFixture(RunningEventLoopFixture())

        fixture = self.useFixture(MockLiveRegionToClusterRPCFixture())
        return fixture.makeCluster(rack_controller, *commands)