def test_monitor_cinder_volume(self): fake_cinder_client = fake_client.FakeCinderClient() fake_cinder_volume = fake_object.FakeCinderVolume(status='available') fake_desired_state = 'in-use' fake_transient_states = ('in-use', ) fake_time_limit = 0 fake_state_monitor = state_monitor.StateMonitor( fake_cinder_client, fake_cinder_volume, fake_desired_state, fake_transient_states, fake_time_limit) fake_desired_volume = fake_object.FakeCinderVolume(status='in-use') with mock.patch.object(fake_client.FakeCinderClient.Volumes, 'get', return_value=fake_desired_volume): self.assertEqual(fake_desired_volume, fake_state_monitor.monitor_cinder_volume())
def test_monitor_cinder_volume_unexpected_state(self): fake_cinder_client = fake_client.FakeCinderClient() fake_cinder_volume = fake_object.FakeCinderVolume(status='available') fake_desired_state = 'in-use' fake_transient_states = ('in-use', ) fake_time_limit = 0 fake_state_monitor = state_monitor.StateMonitor( fake_cinder_client, fake_cinder_volume, fake_desired_state, fake_transient_states, fake_time_limit) fake_desired_volume = fake_object.FakeCinderVolume(status='attaching') with mock.patch.object(fake_client.FakeCinderClient.Volumes, 'get', return_value=fake_desired_volume): self.assertRaises(exceptions.UnexpectedStateException, fake_state_monitor.monitor_cinder_volume)
def test_monitor_cinder_volume_get_failed(self): fake_cinder_client = fake_client.FakeCinderClient() fake_cinder_volume = fake_object.FakeCinderVolume(status='available') with mock.patch( 'fuxi.tests.unit.fake_client.FakeCinderClient.Volumes' '.get', side_effect=cinder_exception.ClientException(404)): fake_state_monitor = state_monitor.StateMonitor( fake_cinder_client, fake_cinder_volume, None, None, -1) self.assertRaises(exceptions.TimeoutException, fake_state_monitor.monitor_cinder_volume) with mock.patch( 'fuxi.tests.unit.fake_client.FakeCinderClient.Volumes' '.get', side_effect=cinder_exception.ClientException(404)): fake_state_monitor = state_monitor.StateMonitor( fake_cinder_client, fake_cinder_volume, None, None) self.assertRaises(cinder_exception.ClientException, fake_state_monitor.monitor_cinder_volume)
def setUp(self): base.TestCase.setUp(self) self.connector = openstack.CinderConnector() self.connector.cinderclient = fake_client.FakeCinderClient() self.connector.novaclient = fake_client.FakeNovaClient()
def setUp(self): base.TestCase.setUp(self) self.connector = osbrickconnector.CinderConnector() self.connector.cinderclient = fake_client.FakeCinderClient()
def setUp(self): base.TestCase.setUp(self) self.cinderprovider = cinder.Cinder() self.cinderprovider.cinderclient = fake_client.FakeCinderClient()