From 1ca7098311f25642ee76b68d9446223f93403efc Mon Sep 17 00:00:00 2001 From: Rogger Vasquez Date: Wed, 29 Jun 2022 16:09:29 -0500 Subject: [PATCH 1/3] tests: add rpk redpanda mode test We want to make sure that the start/installation path that we guide the user to follow is covered in our CI, running rpk redpanda mode prod is a crucial step before running the tuners. --- tests/rptest/clients/rpk_remote.py | 3 ++ tests/rptest/tests/rpk_config_test.py | 49 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/tests/rptest/clients/rpk_remote.py b/tests/rptest/clients/rpk_remote.py index 6b93906e8a2e..a20ac8893e3b 100644 --- a/tests/rptest/clients/rpk_remote.py +++ b/tests/rptest/clients/rpk_remote.py @@ -47,6 +47,9 @@ def cluster_config_force_reset(self, property_name): def cluster_config_lint(self): return self._execute([self._rpk_binary(), 'cluster', 'config', 'lint']) + def mode_set(self, mode): + return self._execute([self._rpk_binary(), 'redpanda', 'mode', mode]) + def _run_config(self, cmd, path=None, timeout=30): cmd = [self._rpk_binary(), 'redpanda', 'config'] + cmd diff --git a/tests/rptest/tests/rpk_config_test.py b/tests/rptest/tests/rpk_config_test.py index 18047df74fa5..78711b6f8c4a 100644 --- a/tests/rptest/tests/rpk_config_test.py +++ b/tests/rptest/tests/rpk_config_test.py @@ -234,3 +234,52 @@ def test_config_change_then_restart_node(self): rpk.config_set(key, value) self.redpanda.restart_nodes(node) + + @cluster(num_nodes=1) + def test_config_change_mode_prod(self): + """ + Verify that after running rpk redpanda mode prod, the + configuration values of the tuners change accordingly. + """ + node = self.redpanda.nodes[0] + rpk = RpkRemoteTool(self.redpanda, node) + rpk.mode_set("prod") + expected_config = yaml.full_load(''' + enable_usage_stats: false + tune_network: true + tune_disk_scheduler: true + tune_disk_nomerges: true + tune_disk_write_cache: true + tune_disk_irq: true + tune_fstrim: false + tune_cpu: true + tune_aio_events: true + tune_clocksource: true + tune_swappiness: true + tune_transparent_hugepages: false + enable_memory_locking: false + tune_coredump: false + coredump_dir: /var/lib/redpanda/coredump + tune_ballast_file: true + overprovisioned: false +''') + with tempfile.TemporaryDirectory() as d: + node.account.copy_from(RedpandaService.NODE_CONFIG_FILE, d) + + with open(os.path.join(d, 'redpanda.yaml')) as f: + actual_config = yaml.full_load(f.read()) + + # Delete 'admin_api' and 'kafka_api' since they are not + # needed for this test and the brokers change depending + # on the container it's running. + del actual_config['rpk']['kafka_api'] + del actual_config['rpk']['admin_api'] + + if actual_config['rpk'] != expected_config: + self.logger.error("Configs differ") + self.logger.error( + f"Expected: {yaml.dump(expected_config)}") + self.logger.error( + f"Actual: {yaml.dump(actual_config['rpk'])}") + assert actual_config['rpk'] == expected_config + assert actual_config['redpanda']['developer_mode'] == False From 0ca57b5d9799d7bbbdba5108352a908abe49e186 Mon Sep 17 00:00:00 2001 From: Rogger Vasquez Date: Wed, 6 Jul 2022 10:42:15 -0500 Subject: [PATCH 2/3] tests: add rpk tuner tests Tests will be only available in CDT since they rely on the environment and can't be run in a container. --- tests/rptest/clients/rpk_remote.py | 3 ++ tests/rptest/test_suite_quick.yml | 1 + tests/rptest/test_suite_rpk.yml | 1 + tests/rptest/tests/rpk_tuner_test.py | 54 ++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 tests/rptest/tests/rpk_tuner_test.py diff --git a/tests/rptest/clients/rpk_remote.py b/tests/rptest/clients/rpk_remote.py index a20ac8893e3b..c124374cc93c 100644 --- a/tests/rptest/clients/rpk_remote.py +++ b/tests/rptest/clients/rpk_remote.py @@ -47,6 +47,9 @@ def cluster_config_force_reset(self, property_name): def cluster_config_lint(self): return self._execute([self._rpk_binary(), 'cluster', 'config', 'lint']) + def tune(self, tuner): + return self._execute([self._rpk_binary(), 'redpanda', 'tune', tuner]) + def mode_set(self, mode): return self._execute([self._rpk_binary(), 'redpanda', 'mode', mode]) diff --git a/tests/rptest/test_suite_quick.yml b/tests/rptest/test_suite_quick.yml index 51ff6beb922c..f8fcdd94938f 100644 --- a/tests/rptest/test_suite_quick.yml +++ b/tests/rptest/test_suite_quick.yml @@ -17,3 +17,4 @@ quick: - tests/wasm_identity_test.py - tests/wasm_partition_movement_test.py - tests/wasm_redpanda_failure_recovery_test.py + - tests/rpk_tuner_test.py diff --git a/tests/rptest/test_suite_rpk.yml b/tests/rptest/test_suite_rpk.yml index 07041744ba82..4a2e5159ed6a 100644 --- a/tests/rptest/test_suite_rpk.yml +++ b/tests/rptest/test_suite_rpk.yml @@ -12,3 +12,4 @@ quick: - tests/rpk_topic_test.py - tests/rpk_cluster_test.py - tests/rpk_config_test.py + - tests/rpk_tuner_test.py diff --git a/tests/rptest/tests/rpk_tuner_test.py b/tests/rptest/tests/rpk_tuner_test.py new file mode 100644 index 000000000000..ae4d69f30409 --- /dev/null +++ b/tests/rptest/tests/rpk_tuner_test.py @@ -0,0 +1,54 @@ +# Copyright 2022 Redpanda Data, Inc. +# +# Use of this software is governed by the Business Source License +# included in the file licenses/BSL.md +# +# As of the Change Date specified in that file, in accordance with +# the Business Source License, use of this software will be governed +# by the Apache License, Version 2.0 + +from rptest.services.cluster import cluster +from rptest.tests.redpanda_test import RedpandaTest +from rptest.clients.rpk_remote import RpkRemoteTool + + +class RpkTunerTest(RedpandaTest): + def __init__(self, ctx): + super(RpkTunerTest, self).__init__(test_context=ctx) + self._ctx = ctx + + @cluster(num_nodes=1) + def test_tune_prod_all(self): + """ + Test will set production mode and execute rpk redpanda tune all, + we expect the command to exit with 1 if an error happens. + """ + node = self.redpanda.nodes[0] + rpk = RpkRemoteTool(self.redpanda, node) + rpk.mode_set("prod") + + rpk.tune("all") + + @cluster(num_nodes=1) + def test_tune_fstrim(self): + """ + Validate fstrim tuner execution, + fstrim was disabled in production mode https://github.com/redpanda-data/redpanda/issues/3068 + """ + node = self.redpanda.nodes[0] + rpk = RpkRemoteTool(self.redpanda, node) + rpk.config_set('rpk.tune_fstrim', 'true') + + rpk.tune("fstrim") + + @cluster(num_nodes=1) + def test_tune_transparent_hugepages(self): + """ + Validate transparent hugepage tuner execution. + THP tuner is disabled in production mode + """ + node = self.redpanda.nodes[0] + rpk = RpkRemoteTool(self.redpanda, node) + rpk.config_set('rpk.tune_transparent_hugepages', 'true') + + rpk.tune("transparent_hugepages") From 4224dc8d89832a1eeb69ad92efead8b604c1c460 Mon Sep 17 00:00:00 2001 From: Rogger Vasquez Date: Fri, 8 Jul 2022 09:16:16 -0500 Subject: [PATCH 3/3] tests: add rpk tune list ducktape test This golden test will allow us to catch when a new tuner is either added or removed from production mode --- tests/rptest/tests/rpk_tuner_test.py | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/rptest/tests/rpk_tuner_test.py b/tests/rptest/tests/rpk_tuner_test.py index ae4d69f30409..b0d40c197eaa 100644 --- a/tests/rptest/tests/rpk_tuner_test.py +++ b/tests/rptest/tests/rpk_tuner_test.py @@ -52,3 +52,37 @@ def test_tune_transparent_hugepages(self): rpk.config_set('rpk.tune_transparent_hugepages', 'true') rpk.tune("transparent_hugepages") + + @cluster(num_nodes=1) + def test_tune_list(self): + """ + Forward compatible test, the purpose is to check if available + tuners match our current setup, if a new tuner gets added we + will catch it here. + """ + node = self.redpanda.nodes[0] + rpk = RpkRemoteTool(self.redpanda, node) + # Set all tuners: + rpk.mode_set("prod") + rpk.config_set('rpk.tune_fstrim', 'true') + rpk.config_set('rpk.tune_transparent_hugepages', 'true') + rpk.config_set('rpk.tune_coredump', 'true') + + expected = '''TUNER ENABLED SUPPORTED UNSUPPORTED-REASON +aio_events true true +ballast_file true true +clocksource true true +coredump true true +cpu true true +disk_irq true true +disk_nomerges true true +disk_scheduler true true +disk_write_cache true false Disk write cache tuner is only supported in GCP +fstrim true true +net true true +swappiness true true +transparent_hugepages true true +''' + output = rpk.tune("list") + + assert output == expected