Esempio n. 1
0
    def test_get_offsets(self, client):
        consumer_group = 'group1'
        topics = {'topic1': {0: 100}}

        with mock.patch(
            'kafka_utils.util.offsets._verify_topics_and_partitions',
            return_value=topics,
            autospec=True,
        ):
            OffsetGet.get_offsets(
                client,
                consumer_group,
                topics,
            )

            assert client.load_metadata_for_topics.call_count == 1
            assert client.send_offset_fetch_request_kafka.call_count == 1
Esempio n. 2
0
    def test_get_offsets(self, client):
        consumer_group = 'group1'
        topics = {'topic1': {0: 100}}

        with mock.patch(
                'kafka_utils.util.offsets._verify_topics_and_partitions',
                return_value=topics,
                autospec=True,
        ):
            OffsetGet.get_offsets(
                client,
                consumer_group,
                topics,
            )

            assert client.load_metadata_for_topics.call_count == 1
            assert client.send_offset_fetch_request_kafka.call_count == 1
Esempio n. 3
0
    def test_output_sorting_parcentage(self):
        offsets = OrderedDict(
            [("topic1", [ConsumerPartitionOffsets("t1", 0, 1, 10, 0),
                         ConsumerPartitionOffsets("t1", 1, 2, 10, 0)]),
             ("topic2", [ConsumerPartitionOffsets("t2", 0, 900, 1000, 0)])])

        sorted_dict = OffsetGet.sort_by_distance_percentage(offsets)
        assert sorted_dict.keys()[0] == "topic2"
        assert sorted_dict.keys()[1] == "topic1"
Esempio n. 4
0
    def test_output_sorting_parcentage(self):
        offsets = OrderedDict(
            [("topic1", [ConsumerPartitionOffsets("t1", 0, 1, 10, 0),
                         ConsumerPartitionOffsets("t1", 1, 2, 10, 0)]),
             ("topic2", [ConsumerPartitionOffsets("t2", 0, 900, 1000, 0)])])

        sorted_dict = OffsetGet.sort_by_distance_percentage(offsets)
        assert list(sorted_dict.keys())[0] == "topic2"
        assert list(sorted_dict.keys())[1] == "topic1"
Esempio n. 5
0
    def test_output_sorting(self):
        offsets = OrderedDict([("topic2",
                                [ConsumerPartitionOffsets("t2", 0, 0, 10, 0)]),
                               ("topic1", [
                                   ConsumerPartitionOffsets("t1", 0, 5, 10, 0),
                                   ConsumerPartitionOffsets("t1", 1, 9, 10, 0)
                               ])])

        sorted_dict = OffsetGet.sort_by_distance(offsets)
        assert list(sorted_dict.keys())[0] == "topic1"
        assert list(sorted_dict.keys())[1] == "topic2"