def test_begin_install(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.begin_install() self.assertEqual(self.baseDbStatus.status, rd_instance.ServiceStatuses.BUILDING)
def test_begin_restart(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.restart_mode = False self.baseDbStatus.begin_restart() self.assertTrue(self.baseDbStatus.restart_mode)
def test_wait_for_real_status_to_change_to_timeout(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus._get_actual_db_status = Mock( return_value=rd_instance.ServiceStatuses.RUNNING) dbaas.time.sleep = Mock() self.assertFalse(self.baseDbStatus. wait_for_real_status_to_change_to (rd_instance.ServiceStatuses.SHUTDOWN, 10))
def test_wait_for_real_status_to_change_to(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus._get_actual_db_status = Mock( return_value=rd_instance.ServiceStatuses.RUNNING) time.sleep = Mock() self.assertTrue( self.baseDbStatus.wait_for_real_status_to_change_to( rd_instance.ServiceStatuses.RUNNING, 10))
def test_end_install_or_restart(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus._get_actual_db_status = Mock( return_value=rd_instance.ServiceStatuses.SHUTDOWN) self.baseDbStatus.end_install_or_restart() self.assertEqual(rd_instance.ServiceStatuses.SHUTDOWN, self.baseDbStatus.status) self.assertFalse(self.baseDbStatus.restart_mode)
def test_wait_for_real_status_to_change_to(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus._get_actual_db_status = Mock( return_value=rd_instance.ServiceStatuses.RUNNING) time.sleep = Mock() self.assertTrue(self.baseDbStatus. wait_for_real_status_to_change_to (rd_instance.ServiceStatuses.RUNNING, 10))
class BaseDbStatusTest(testtools.TestCase): def setUp(self): super(BaseDbStatusTest, self).setUp() util.init_db() self.orig_dbaas_time_sleep = dbaas.time.sleep self.FAKE_ID = randint(1, 10000) InstanceServiceStatus.create(instance_id=self.FAKE_ID, status=rd_instance.ServiceStatuses.NEW) dbaas.CONF.guest_id = self.FAKE_ID def tearDown(self): super(BaseDbStatusTest, self).tearDown() dbaas.time.sleep = self.orig_dbaas_time_sleep InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete() dbaas.CONF.guest_id = None def test_begin_install(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.begin_install() self.assertEqual(self.baseDbStatus.status, rd_instance.ServiceStatuses.BUILDING) def test_begin_restart(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.restart_mode = False self.baseDbStatus.begin_restart() self.assertTrue(self.baseDbStatus.restart_mode) def test_end_install_or_restart(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus._get_actual_db_status = Mock( return_value=rd_instance.ServiceStatuses.SHUTDOWN) self.baseDbStatus.end_install_or_restart() self.assertEqual(rd_instance.ServiceStatuses.SHUTDOWN, self.baseDbStatus.status) self.assertFalse(self.baseDbStatus.restart_mode) def test_is_installed(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.status = rd_instance.ServiceStatuses.RUNNING self.assertTrue(self.baseDbStatus.is_installed) def test_is_installed_none(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.status = None self.assertFalse(self.baseDbStatus.is_installed) def test_is_installed_building(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.status = rd_instance.ServiceStatuses.BUILDING self.assertFalse(self.baseDbStatus.is_installed) def test_is_installed_new(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.status = rd_instance.ServiceStatuses.NEW self.assertFalse(self.baseDbStatus.is_installed) def test_is_installed_failed(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.status = rd_instance.ServiceStatuses.FAILED self.assertFalse(self.baseDbStatus.is_installed) def test_is_restarting(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.restart_mode = True self.assertTrue(self.baseDbStatus._is_restarting) def test_is_running(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.status = rd_instance.ServiceStatuses.RUNNING self.assertTrue(self.baseDbStatus.is_running) def test_is_running_not(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.status = rd_instance.ServiceStatuses.SHUTDOWN self.assertFalse(self.baseDbStatus.is_running) def test_wait_for_real_status_to_change_to(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus._get_actual_db_status = Mock( return_value=rd_instance.ServiceStatuses.RUNNING) dbaas.time.sleep = Mock() self.assertTrue(self.baseDbStatus. wait_for_real_status_to_change_to (rd_instance.ServiceStatuses.RUNNING, 10)) def test_wait_for_real_status_to_change_to_timeout(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus._get_actual_db_status = Mock( return_value=rd_instance.ServiceStatuses.RUNNING) dbaas.time.sleep = Mock() self.assertFalse(self.baseDbStatus. wait_for_real_status_to_change_to (rd_instance.ServiceStatuses.SHUTDOWN, 10))
def test_is_running_not(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.status = rd_instance.ServiceStatuses.SHUTDOWN self.assertFalse(self.baseDbStatus.is_running)
def test_is_running(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.status = rd_instance.ServiceStatuses.RUNNING self.assertTrue(self.baseDbStatus.is_running)
def test_is_restarting(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.restart_mode = True self.assertTrue(self.baseDbStatus._is_restarting)
def test_is_installed_failed(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.status = rd_instance.ServiceStatuses.FAILED self.assertFalse(self.baseDbStatus.is_installed)
def test_is_installed_new(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.status = rd_instance.ServiceStatuses.NEW self.assertFalse(self.baseDbStatus.is_installed)
def test_is_installed_building(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.status = rd_instance.ServiceStatuses.BUILDING self.assertFalse(self.baseDbStatus.is_installed)
def test_is_installed_none(self): self.baseDbStatus = BaseDbStatus() self.baseDbStatus.status = None self.assertFalse(self.baseDbStatus.is_installed)