def test_get_hung_in_rebooting(self): fakes = [self.fake_instance(1), self.fake_instance(2)] dt = timeutils.isotime() self.mox.StubOutWithMock(db, "instance_get_all_hung_in_rebooting") db.instance_get_all_hung_in_rebooting(self.context, dt).AndReturn(fakes) self.mox.ReplayAll() inst_list = instance.InstanceList.get_hung_in_rebooting(self.context, dt) for i in range(0, len(fakes)): self.assertIsInstance(inst_list.objects[i], instance.Instance) self.assertEqual(inst_list.objects[i].uuid, fakes[i]["uuid"]) self.assertRemotes()
def test_get_hung_in_rebooting(self): fakes = [self.fake_instance(1), self.fake_instance(2)] dt = timeutils.isotime() self.mox.StubOutWithMock(db, 'instance_get_all_hung_in_rebooting') db.instance_get_all_hung_in_rebooting(self.context, dt).AndReturn(fakes) self.mox.ReplayAll() inst_list = instance.InstanceList.get_hung_in_rebooting( self.context, dt) for i in range(0, len(fakes)): self.assertIsInstance(inst_list.objects[i], instance.Instance) self.assertEqual(inst_list.objects[i].uuid, fakes[i]['uuid']) self.assertRemotes()
def get_hung_in_rebooting(cls, context, reboot_window, expected_attrs=None): db_inst_list = db.instance_get_all_hung_in_rebooting( context, reboot_window) return _make_instance_list(context, cls(), db_inst_list, expected_attrs)
def test_instance_get_all_hung_in_rebooting(self): ctxt = context.get_admin_context() # Ensure no instances are returned. results = db.instance_get_all_hung_in_rebooting(ctxt, 10) self.assertEqual(0, len(results)) # Ensure one rebooting instance with updated_at older than 10 seconds # is returned. updated_at = datetime.datetime(2000, 01, 01, 12, 00, 00) values = {"task_state": "rebooting", "updated_at": updated_at} instance = db.instance_create(ctxt, values) results = db.instance_get_all_hung_in_rebooting(ctxt, 10) self.assertEqual(1, len(results)) db.instance_update(ctxt, instance['uuid'], {"task_state": None}) # Ensure the newly rebooted instance is not returned. updated_at = timeutils.utcnow() values = {"task_state": "rebooting", "updated_at": updated_at} instance = db.instance_create(ctxt, values) results = db.instance_get_all_hung_in_rebooting(ctxt, 10) self.assertEqual(0, len(results)) db.instance_update(ctxt, instance['uuid'], {"task_state": None})
def test_instance_get_all_hung_in_rebooting(self): ctxt = context.get_admin_context() # Ensure no instances are returned. results = db.instance_get_all_hung_in_rebooting(ctxt, 10) self.assertEqual(0, len(results)) # Ensure one rebooting instance with updated_at older than 10 seconds # is returned. updated_at = datetime.datetime(2000, 01, 01, 12, 00, 00) values = {"task_state": "rebooting", "updated_at": updated_at} instance = db.instance_create(ctxt, values) results = db.instance_get_all_hung_in_rebooting(ctxt, 10) self.assertEqual(1, len(results)) db.instance_update(ctxt, instance.id, {"task_state": None}) # Ensure the newly rebooted instance is not returned. updated_at = datetime.datetime.utcnow() values = {"task_state": "rebooting", "updated_at": updated_at} instance = db.instance_create(ctxt, values) results = db.instance_get_all_hung_in_rebooting(ctxt, 10) self.assertEqual(0, len(results)) db.instance_update(ctxt, instance.id, {"task_state": None})
def test_instance_get_all_hung_in_rebooting(self): self.mox.StubOutWithMock(db, "instance_get_all_hung_in_rebooting") db.instance_get_all_hung_in_rebooting(self.context, 123) self.mox.ReplayAll() self.conductor.instance_get_all_hung_in_rebooting(self.context, 123)
def get_hung_in_rebooting(cls, context, reboot_window, expected_attrs=None): db_inst_list = db.instance_get_all_hung_in_rebooting(context, reboot_window) return _make_instance_list(context, cls(), db_inst_list, expected_attrs)
def test_instance_get_all_hung_in_rebooting(self): self.mox.StubOutWithMock(db, 'instance_get_all_hung_in_rebooting') db.instance_get_all_hung_in_rebooting(self.context, 123) self.mox.ReplayAll() self.conductor.instance_get_all_hung_in_rebooting(self.context, 123)