Esempio n. 1
0
    def process_arguments(cls, cmd_args):
        if len(cmd_args) < 3:
            raise ArgumentError(
                "At least one topic definition must be provided")
        if not cmd_args[0] in ('true', 'false'):
            raise ArgumentError("The first argument may only be true or false")
        if not cmd_args[1].isdigit():
            raise ArgumentError("The second argument must be an integer")

        values = {
            'validate_only': cmd_args[0] == 'true',
            'topics': [],
            'timeout': int(cmd_args[1])
        }
        for topic_def in cmd_args[2:]:
            tparts = topic_def.split(",")
            topic = {
                'topic': tparts[0],
                'num_partitions': -1,
                'replication_factor': -1,
                'replica_assignment': [],
                'configs': []
            }

            _parse_remaining_args(topic, tparts[1:])
            values['topics'].append(topic)

        return values
    def test_parse_remaining_args_count_and_factor(self):
        _parse_remaining_args(self.topic, ["8", "3", "configkey=configvalue"])

        self.target_topic['num_partitions'] = 8
        self.target_topic['replication_factor'] = 3
        self.target_topic['configs'] = [{
            'config_key': 'configkey',
            'config_value': 'configvalue'
        }]
        assert self.topic == self.target_topic
    def test_parse_remaining_args_replica_list(self):
        _parse_remaining_args(self.topic, ["1=3|4", "configkey=configvalue"])

        self.target_topic['replica_assignment'] = [{
            'partition_id': 1,
            'replicas': [3, 4]
        }]
        self.target_topic['configs'] = [{
            'config_key': 'configkey',
            'config_value': 'configvalue'
        }]
        assert self.topic == self.target_topic
Esempio n. 4
0
    def process_arguments(cls, cmd_args):
        if len(cmd_args) < 3:
            raise ArgumentError("At least one topic definition must be provided")
        if not cmd_args[0] in ('true', 'false'):
            raise ArgumentError("The first argument may only be true or false")
        if not cmd_args[1].isdigit():
            raise ArgumentError("The second argument must be an integer")

        values = {'validate_only': cmd_args[0] == 'true', 'topics': [], 'timeout': int(cmd_args[1])}
        for topic_def in cmd_args[2:]:
            tparts = topic_def.split(",")
            topic = {'topic': tparts[0],
                     'num_partitions': -1,
                     'replication_factor': -1,
                     'replica_assignment': [],
                     'configs': []}

            _parse_remaining_args(topic, tparts[1:])
            values['topics'].append(topic)

        return values