def test_live_migration_dest_raises_exception_no_volume(self): """Same as above test(input pattern is different) """ i_ref = self._get_dummy_instance() i_ref['volumes'] = [] c = context.get_admin_context() topic = db.queue_get_for(c, FLAGS.compute_topic, i_ref['host']) dbmock = self.mox.CreateMock(db) dbmock.instance_get(c, i_ref['id']).AndReturn(i_ref) dbmock.queue_get_for(c, FLAGS.compute_topic, i_ref['host']).\ AndReturn(topic) self.mox.StubOutWithMock(rpc, 'call') rpc.call(c, topic, {"method": "pre_live_migration", "args": {'instance_id': i_ref['id']}}).\ AndRaise(rpc.RemoteError('', '', '')) dbmock.instance_update( c, i_ref['id'], { 'state_description': 'running', 'state': power_state.RUNNING, 'host': i_ref['host'] }) self.compute.db = dbmock self.mox.ReplayAll() self.assertRaises(rpc.RemoteError, self.compute.live_migration, c, i_ref['id'], i_ref['host'])
def test_live_migration_dest_raises_exception(self): """Confirm exception when pre_live_migration fails.""" i_ref = self._get_dummy_instance() c = context.get_admin_context() topic = db.queue_get_for(c, FLAGS.compute_topic, i_ref['host']) dbmock = self.mox.CreateMock(db) dbmock.instance_get(c, i_ref['id']).AndReturn(i_ref) self.mox.StubOutWithMock(rpc, 'call') rpc.call(c, FLAGS.volume_topic, { "method": "check_for_export", "args": { 'instance_id': i_ref['id'] } }) dbmock.queue_get_for(c, FLAGS.compute_topic, i_ref['host']).\ AndReturn(topic) rpc.call(c, topic, {"method": "pre_live_migration", "args": {'instance_id': i_ref['id']}}).\ AndRaise(rpc.RemoteError('', '', '')) dbmock.instance_update( c, i_ref['id'], { 'state_description': 'running', 'state': power_state.RUNNING, 'host': i_ref['host'] }) for v in i_ref['volumes']: dbmock.volume_update(c, v['id'], {'status': 'in-use'}) self.compute.db = dbmock self.mox.ReplayAll() self.assertRaises(rpc.RemoteError, self.compute.live_migration, c, i_ref['id'], i_ref['host'])
def test_live_migration_common_check_checking_cpuinfo_fail(self): """Raise excetion when original host doen't have compatible cpu.""" dest = 'dummydest' instance_id = self._create_instance() i_ref = db.instance_get(self.context, instance_id) # compute service for destination s_ref = self._create_compute_service(host=i_ref['host']) # compute service for original host s_ref2 = self._create_compute_service(host=dest) # mocks driver = self.scheduler.driver self.mox.StubOutWithMock(driver, 'mounted_on_same_shared_storage') driver.mounted_on_same_shared_storage(mox.IgnoreArg(), i_ref, dest) self.mox.StubOutWithMock(rpc, 'call', use_mock_anything=True) rpc.call(mox.IgnoreArg(), mox.IgnoreArg(), {"method": 'compare_cpu', "args": {'cpu_info': s_ref2['compute_node'][0]['cpu_info']}}).\ AndRaise(rpc.RemoteError("doesn't have compatibility to", "", "")) self.mox.ReplayAll() try: self.scheduler.driver._live_migration_common_check( self.context, i_ref, dest) except rpc.RemoteError, e: c = (e.message.find(_("doesn't have compatibility to")) >= 0)
def fake_call(*args, **kwargs): raise (rpc.RemoteError('NoMoreFloatingIps', '', ''))