Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
 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()
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
    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})
Exemplo n.º 5
0
    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})
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
 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)