Exemplo n.º 1
0
    def test_get_topic_partition_metadata_empty(self, mock_get_metadata):
        mock_get_metadata.return_value = {}

        actual = get_topic_partition_with_error(self.cluster_config, 5)
        expected = set([])
        assert actual == expected
        mock_get_metadata.asserd_called_wity('some_list')
Exemplo n.º 2
0
    def test_get_topic_partition_metadata_leader_not_available(
            self, mock_get_metadata):
        mock_get_metadata.return_value = METADATA_RESPONSE_WITH_ERRORS

        actual = get_topic_partition_with_error(self.cluster_config,
                                                LEADER_NOT_AVAILABLE_ERROR)
        expected = set([('topic0', 1)])
        assert actual == expected
Exemplo n.º 3
0
    def test_get_topic_partition_metadata_leader_not_available(self, mock_get_metadata):
        mock_get_metadata.return_value = METADATA_RESPONSE_WITH_ERRORS

        with mock.patch(
            'kafka_utils.util.metadata.ZK',
        ):
            actual = get_topic_partition_with_error(self.cluster_config, LEADER_NOT_AVAILABLE_ERROR)
        expected = set([('topic0', 1)])
        assert actual == expected
Exemplo n.º 4
0
    def test_get_topic_partition_metadata_replica_not_available(self, mock_get_metadata):
        mock_get_metadata.return_value = METADATA_RESPONSE_WITH_ERRORS

        with mock.patch(
            'kafka_utils.util.metadata.ZK',
        ):
            actual = get_topic_partition_with_error(self.cluster_config, REPLICA_NOT_AVAILABLE_ERROR)
        expected = {('topic0', 0), ('topic1', 1)}
        assert actual == expected
Exemplo n.º 5
0
    def test_get_topic_partition_metadata_no_errors(self, mock_get_metadata):
        mock_get_metadata.return_value = METADATA_RESPONSE_ALL_FINE

        with mock.patch(
            'kafka_utils.util.metadata.ZK',
        ):
            actual = get_topic_partition_with_error(self.cluster_config, 5)
        expected = set([])
        assert actual == expected
Exemplo n.º 6
0
    def run_command(self):
        """Checks the number of offline partitions"""
        offline = get_topic_partition_with_error(
            self.cluster_config,
            LEADER_NOT_AVAILABLE_ERROR,
        )

        errcode = status_code.OK if not offline else status_code.CRITICAL
        out = _prepare_output(offline, self.args.verbose, self.args.head)
        return errcode, out
Exemplo n.º 7
0
    def run_command(self):
        """Checks the number of offline partitions"""
        offline = get_topic_partition_with_error(
            self.cluster_config,
            LEADER_NOT_AVAILABLE_ERROR,
        )

        errcode = status_code.OK if not offline else status_code.CRITICAL
        out = _prepare_output(offline, self.args.verbose)
        return errcode, out
Exemplo n.º 8
0
    def test_get_topic_partition_metadata_empty(self, mock_get_metadata):
        mock_get_metadata.return_value = {}

        with mock.patch(
            'kafka_utils.util.metadata.ZK',
        ):
            actual = get_topic_partition_with_error(self.cluster_config, 5)
        expected = set([])
        assert actual == expected
        mock_get_metadata.asserd_called_wity('some_list')
    def run_command(self):
        """replica_unavailability command, checks number of replicas not available
        for communication over all brokers in the Kafka cluster."""
        replica_unavailability = get_topic_partition_with_error(
            self.cluster_config,
            REPLICA_NOT_AVAILABLE_ERROR,
        )

        errcode = status_code.OK if not replica_unavailability else status_code.CRITICAL
        out = _prepare_output(replica_unavailability, self.args.verbose)
        return errcode, out
Exemplo n.º 10
0
    def run_command(self):
        """replica_unavailability command, checks number of replicas not available
        for communication over all brokers in the Kafka cluster."""
        fetch_unavailable_brokers = True
        result = get_topic_partition_with_error(
            self.cluster_config,
            REPLICA_NOT_AVAILABLE_ERROR,
            fetch_unavailable_brokers=fetch_unavailable_brokers,
        )
        if fetch_unavailable_brokers:
            replica_unavailability, unavailable_brokers = result
        else:
            replica_unavailability = result

        errcode = status_code.OK if not replica_unavailability else status_code.CRITICAL
        out = _prepare_output(replica_unavailability, unavailable_brokers, self.args.verbose)
        return errcode, out