示例#1
0
    def run(cls, args, cluster_config):
        # Setup the Kafka client
        client = KafkaToolClient(cluster_config.broker_list)
        client.load_metadata_for_topics()

        topics_dict = cls.preprocess_args(
            args.groupid,
            args.topic,
            args.partitions,
            cluster_config,
            client,
            force=args.force,
        )
        try:
            rewind_consumer_offsets(
                client,
                args.groupid,
                topics_dict,
                args.storage,
            )
        except TypeError:
            print(
                "Error: Badly formatted input, please re-run command "
                "with --help option.", file=sys.stderr
            )
            raise

        client.close()
示例#2
0
 def test_rewind_consumer_offsets(self, kafka_client_mock):
     topics = {
         'topic1': [0, 1, 2],
         'topic2': [0, 1],
     }
     status = rewind_consumer_offsets(kafka_client_mock, "group", topics)
     status == []
     assert kafka_client_mock.group_offsets == self.low_offsets
示例#3
0
 def test_rewind_consumer_offsets(self, kafka_client_mock):
     topics = {
         'topic1': [0, 1, 2],
         'topic2': [0, 1],
     }
     status = rewind_consumer_offsets(
         kafka_client_mock,
         "group",
         topics
     )
     status == []
     assert kafka_client_mock.group_offsets == self.low_offsets
示例#4
0
    def test_rewind_consumer_offsets_fail(self, kafka_client_mock):
        kafka_client_mock.set_commit_error()
        topics = {
            'topic1': [0, 1, 2],
            'topic2': [0, 1],
        }
        expected_status = [
            OffsetCommitError("topic1", 0, RequestTimedOutError.message),
            OffsetCommitError("topic1", 1, RequestTimedOutError.message),
            OffsetCommitError("topic1", 2, RequestTimedOutError.message),
            OffsetCommitError("topic2", 0, RequestTimedOutError.message),
            OffsetCommitError("topic2", 1, RequestTimedOutError.message),
        ]

        status = rewind_consumer_offsets(kafka_client_mock, "group", topics)
        assert len(status) == len(expected_status)
        for expected in expected_status:
            assert any(actual == expected for actual in status)
        assert kafka_client_mock.group_offsets == self.group_offsets
示例#5
0
    def test_rewind_consumer_offsets_fail(self, kafka_client_mock):
        kafka_client_mock.set_commit_error()
        topics = {
            'topic1': [0, 1, 2],
            'topic2': [0, 1],
        }
        expected_status = [
            OffsetCommitError("topic1", 0, RequestTimedOutError.message),
            OffsetCommitError("topic1", 1, RequestTimedOutError.message),
            OffsetCommitError("topic1", 2, RequestTimedOutError.message),
            OffsetCommitError("topic2", 0, RequestTimedOutError.message),
            OffsetCommitError("topic2", 1, RequestTimedOutError.message),
        ]

        status = rewind_consumer_offsets(
            kafka_client_mock,
            "group",
            topics
        )
        assert len(status) == len(expected_status)
        for expected in expected_status:
            assert any(actual == expected for actual in status)
        assert kafka_client_mock.group_offsets == self.group_offsets