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())
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())
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
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
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())
def prepare_live_rpc(self): self.useFixture(RegionEventLoopFixture("rpc")) self.useFixture(RunningEventLoopFixture()) return self.useFixture(MockLiveRegionToClusterRPCFixture())
def setUp(self): super().setUp() self.useFixture(RegionEventLoopFixture("rpc")) self.useFixture(RunningEventLoopFixture()) self.useFixture(MockRegionToClusterRPCFixture())
def setUp(self): super(RunningClusterRPCFixture, self).setUp() self.useFixture(RegionEventLoopFixture("rpc")) self.useFixture(RunningEventLoopFixture()) self.useFixture(ClusterRPCFixture())
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)