예제 #1
0
    def test_should_pass(self, kafka_client):
        kafka = mock.Mock()
        kafka.topic_partitions = self.mocked_topics
        kafka_client.return_value = kafka

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

        self.assertTrue(result)

        # ensure client was closed
        self.assertTrue(kafka.close.called)
예제 #2
0
    def test_should_fail_topic_missing(self, kafka_client):
        kafka = mock.Mock()
        kafka.topic_partitions = [self.mocked_topics[0]]
        kafka_client.return_value = kafka

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

        # verify result
        self.assertFalse(result.healthy)

        # ensure client was closed
        self.assertTrue(kafka.close.called)
예제 #3
0
    def test_should_fail_kafka_unavailable(self, kafka_client):
        kafka_client.side_effect = client.KafkaUnavailableError()
        kafka_health = kc.KafkaHealthCheck()
        result = kafka_health.healthcheck()

        self.assertFalse(result.healthy)
예제 #4
0
 def __init__(self):
     self._kafka_check = kafka_check.KafkaHealthCheck()
     super(HealthChecks, self).__init__()