def test_reset_service_replication(self, mock_update): cluster = fake_cluster.fake_cluster_ovo(self.context) cluster.reset_service_replication() mock_update.assert_called_with(self.context, models.Service, {'replication_status': 'enabled', 'active_backend_id': None}, {'cluster_name': cluster.name})
def test_reset_service_replication(self, mock_update): cluster = fake_cluster.fake_cluster_ovo(self.context) cluster.reset_service_replication() mock_update.assert_called_with(self.context, models.Service, { 'replication_status': 'enabled', 'active_backend_id': None }, {'cluster_name': cluster.name})
def test_is_up_limit(self): limit_expired = (utils.service_expired_time(True) + timeutils.datetime.timedelta(seconds=1)) cluster = fake_cluster.fake_cluster_ovo(self.context, last_heartbeat=limit_expired) self.assertTrue(cluster.is_up)
def test_is_up(self): cluster = fake_cluster.fake_cluster_ovo( self.context, last_heartbeat=timeutils.utcnow(with_timezone=True)) self.assertTrue(cluster.is_up)
def test_is_up_no_last_hearbeat(self): cluster = fake_cluster.fake_cluster_ovo(self.context, last_heartbeat=None) self.assertFalse(cluster.is_up)
def test_refresh(self, cluster_get_mock): cluster = fake_cluster.fake_cluster_ovo(self.context) cluster.refresh() cluster_get_mock.assert_called_once_with(self.context, cluster.id)
def test_destroy(self, cluster_destroy_mock): cluster = fake_cluster.fake_cluster_ovo(self.context) cluster.destroy() cluster_destroy_mock.assert_called_once_with(mock.ANY, cluster.id)
def test_save(self, cluster_update_mock): cluster = fake_cluster.fake_cluster_ovo(self.context) cluster.disabled = True cluster.save() cluster_update_mock.assert_called_once_with(self.context, cluster.id, {'disabled': True})
def test_is_up_down(self): expired_time = (utils.service_expired_time(True) - timeutils.datetime.timedelta(seconds=1)) cluster = fake_cluster.fake_cluster_ovo(self.context, last_heartbeat=expired_time) self.assertFalse(cluster.is_up)
def test_is_up_no_last_hearbeat(self): cluster = fake_cluster.fake_cluster_ovo(self.context, last_heartbeat=None) self.assertFalse(bool(cluster.is_up))