def test_should_fail_kafka_unavailable(self, kafka_client):
        kafka = mock.Mock()
        kafka_client.side_effect = client.KafkaUnavailableError()
        kafka_client.return_value = kafka

        kafka_health = kc.KafkaHealthCheck()
        result = kafka_health.health_check()

        self.assertFalse(result.healthy)
        kafka.close.assert_not_called()
    def test_should_fail_missing_topic(self, kafka_client):
        kafka = mock.Mock()
        kafka.topics = ['topic1']
        kafka_client.return_value = kafka

        kafka_health = kc.KafkaHealthCheck()
        result = kafka_health.health_check()

        self.assertFalse(result.healthy)
        kafka.close.assert_called_once()
Пример #3
0
    def test_should_pass(self, kafka_client):
        kafka = mock.Mock()
        kafka.topic_partitions = (self.mocked_topics,
                                  self.mocked_event_topic,
                                  self.mocked_alarm_state_topic)
        kafka_client.return_value = kafka

        kafka_health = kc.KafkaHealthCheck()
        result = kafka_health.health_check()

        self.assertTrue(result.healthy)
        kafka.close.assert_called_once()
Пример #4
0
 def __init__(self):
     super(HealthChecks, self).__init__()
     self._kafka_check = kafka_check.KafkaHealthCheck()
     self._alarm_db_check = alarms_db_check.AlarmsDbHealthCheck()
     self._metrics_db_check = metrics_db_check.MetricsDbCheck()