Beispiel #1
0
    def test_config_set_json(self):
        n = random.randint(1, len(self.redpanda.nodes))
        node = self.redpanda.get_node(n)
        rpk = RpkRemoteTool(self.redpanda, node)
        key = 'rpk'
        value = '{"tune_aio_events":true,"tune_cpu":true,"tune_disk_irq":true}'

        rpk.config_set(key, value, format='json')

        expected_config = yaml.load('''
coredump_dir: /var/lib/redpanda/coredump
enable_memory_locking: false
enable_usage_stats: false
tune_aio_events: true
tune_clocksource: false
tune_coredump: false
tune_cpu: true
tune_disk_irq: true
tune_disk_nomerges: false
tune_disk_scheduler: false
tune_fstrim: false
tune_network: false
tune_swappiness: false
''')

        with tempfile.TemporaryDirectory() as d:
            node.account.copy_from(RedpandaService.CONFIG_FILE, d)

            with open(os.path.join(d, 'redpanda.yaml')) as f:
                actual_config = yaml.load(f.read())

                assert actual_config['rpk'] == expected_config
Beispiel #2
0
    def test_config_set_yaml(self):
        n = random.randint(1, len(self.redpanda.nodes))
        node = self.redpanda.get_node(n)
        rpk = RpkRemoteTool(self.redpanda, node)
        path = '/etc/redpanda/redpanda.yaml'
        key = 'redpanda.seed_servers'
        value = '''                                                      
- node_id: 1
  host:
    address: 192.168.10.1
    port: 33145
- node_id: 2
  host:
    address: 192.168.10.2
    port: 33145
- node_id: 3
  host:
    address: 192.168.10.3
    port: 33145
'''
        rpk.config_set(key, value, format='yaml')

        with tempfile.TemporaryDirectory() as d:
            node.account.copy_from(RedpandaService.CONFIG_FILE, d)

            with open(os.path.join(d, 'redpanda.yaml')) as f:
                expected_config = yaml.load(value)
                actual_config = yaml.load(f.read())
                assert actual_config['redpanda'][
                    'seed_servers'] == expected_config
    def test_rpk_lint(self):
        """
        Verify that if a redpanda config contains a cluster config
        property, then running `lint` cleans out that value, as it
        is no longer used.
        """
        node = self.redpanda.nodes[0]

        # Put an old-style property in the config
        self.logger.info("Restarting with legacy property")
        self.redpanda.restart_nodes([node],
                                    override_cfg_params={
                                        "kafka_qdc_enable": True,
                                    })
        old_conf = node.account.ssh_output(
            "cat /etc/redpanda/redpanda.yaml").decode('utf-8')
        assert 'kafka_qdc_enable' in old_conf

        # Run lint
        self.logger.info("Linting config")
        rpk_remote = RpkRemoteTool(self.redpanda, node)
        rpk_remote.cluster_config_lint()

        # Check that the old style config property was removed
        new_conf = node.account.ssh_output(
            "cat /etc/redpanda/redpanda.yaml").decode('utf-8')
        assert 'kafka_qdc_enable' not in new_conf

        # Check that the linted config file is not corrupt (redpanda loads with it)
        self.logger.info("Restarting with linted config")
        self.redpanda.stop_node(node)
        self.redpanda.start_node(node, write_config=False)
    def test_rpk_force_reset(self):
        """
        Verify that RPK's `reset` command for disaster recovery works as
        expected: redpanda should start up and behave as if the property
        is its default value.
        """
        # Set some non-default config value
        pr = self.admin.patch_cluster_config(upsert={
            'kafka_qdc_enable': True,
            'append_chunk_size': 65536
        })
        self._wait_for_version_sync(pr['config_version'])
        self._check_value_everywhere("kafka_qdc_enable", True)

        # Reset the property on all nodes
        for node in self.redpanda.nodes:
            rpk_remote = RpkRemoteTool(self.redpanda, node)
            self.redpanda.stop_node(node)
            rpk_remote.cluster_config_force_reset("kafka_qdc_enable")
            self.redpanda.start_node(node)

        # Check that the reset property has reverted to its default
        self._check_value_everywhere("kafka_qdc_enable", False)

        # Check that the bystander config property was not reset
        self._check_value_everywhere("append_chunk_size", 65536)
    def test_config_init(self):
        n = random.randint(0, len(self.redpanda.nodes))
        node = self.redpanda.get_node(n)
        rpk = RpkRemoteTool(self.redpanda, node)
        path = './redpanda-test.yaml'

        rpk.config_init(path)

        with tempfile.TemporaryDirectory() as d:
            node.account.copy_from(path, d)
            with open(os.path.join(d, path)) as f:
                expected_out = '''config_file: /root/redpanda-test.yaml
# node_uuid: (the uuid is random so we don't compare it)
pandaproxy: {}
redpanda:
  admin:
  - address: 0.0.0.0
    port: 9644
  data_directory: /var/lib/redpanda/data
  developer_mode: true
  kafka_api:
  - address: 0.0.0.0
    port: 9092
  node_id: 0
  rpc_server:
    address: 0.0.0.0
    port: 33145
  seed_servers: []
rpk:
  coredump_dir: /var/lib/redpanda/coredump
  enable_memory_locking: false
  enable_usage_stats: false
  overprovisioned: false
  tune_aio_events: false
  tune_clocksource: false
  tune_coredump: false
  tune_cpu: false
  tune_disk_irq: false
  tune_disk_nomerges: false
  tune_disk_scheduler: false
  tune_disk_write_cache: false
  tune_fstrim: false
  tune_network: false
  tune_swappiness: false
  tune_transparent_hugepages: false
schema_registry: {}
'''

                expected_config = yaml.load(expected_out)
                actual_config = yaml.load(f.read())

                assert actual_config['node_uuid'] is not None

                # Delete 'node_uuid' so they can be compared (it's random so
                # it's probably gonna be different each time)
                del actual_config['node_uuid']

                assert actual_config == expected_config
Beispiel #6
0
    def test_config_change_then_restart_node(self):
        for node in self.redpanda.nodes:
            rpk = RpkRemoteTool(self.redpanda, node)
            key = 'redpanda.admin.port'
            value = '9641'  # The default is 9644, so we will change it

            rpk.config_set(key, value)

            self.redpanda.restart_nodes(node)
Beispiel #7
0
    def test_debug_bundle(self):
        # The main RpkTool helper runs rpk on the test runner machine -- debug
        # commands are run on redpanda nodes.

        working_dir = "/tmp"
        node = self.redpanda.nodes[0]

        rpk_remote = RpkRemoteTool(self.redpanda, node)
        output = rpk_remote.debug_bundle(working_dir)
        lines = output.split("\n")

        # On error, rpk bundle returns 0 but writes error description to stdout
        output_file = None
        error_lines = []
        any_errs = False
        for l in lines:
            self.logger.info(l)
            if l.strip().startswith("* "):
                error_lines.append(l)
            elif 'errors occurred' in l:
                any_errs = True
            else:
                m = re.match("^Debug bundle saved to '(.+)'$", l)
                if m:
                    output_file = m.group(1)

        # Avoid false passes if our error line scraping gets broken
        # by a format change.
        if any_errs:
            assert error_lines

        filtered_errors = []
        for l in error_lines:
            if "dmidecode" in l:
                # dmidecode doesn't work in ducktape containers, ignore
                # errors about it.
                continue
            if re.match(r".* error querying .*\.ntp\..* i\/o timeout", l):
                self.logger.error(f"Non-fatal transitory NTP error: {l}")
            else:
                self.logger.error(f"Bad output line: {l}")
                filtered_errors.append(l)

        assert not filtered_errors
        assert output_file is not None

        output_path = os.path.join(working_dir, output_file)
        node.account.copy_from(output_path, working_dir)

        zf = zipfile.ZipFile(output_path)
        files = zf.namelist()
        assert 'redpanda.yaml' in files
        assert 'redpanda.log' in files
        assert 'prometheus-metrics.txt' in files
Beispiel #8
0
    def test_config_set_single_number(self):
        n = random.randint(1, len(self.redpanda.nodes))
        node = self.redpanda.get_node(n)
        rpk = RpkRemoteTool(self.redpanda, node)
        config_file = 'redpanda.yaml'
        key = 'redpanda.admin.port'
        value = '9641'  # The default is 9644, so we will change it

        rpk.config_set(key, value, path=RedpandaService.CONFIG_FILE)

        with tempfile.TemporaryDirectory() as d:
            node.account.copy_from(RedpandaService.CONFIG_FILE, d)

            with open(os.path.join(d, config_file)) as f:
                actual_config = yaml.load(f.read())
                assert f"{actual_config['redpanda']['admin']['port']}" == value