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
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_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)
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