From cd580f0c807a9fa85b216051f0c90ab264afc0ca Mon Sep 17 00:00:00 2001 From: Nicolae Vartolomei Date: Sat, 22 Feb 2025 10:12:49 +0000 Subject: [PATCH 1/2] k/server/tests: use fixture restart method Remove duplicate code. --- .../kafka/server/tests/topic_recreate_test.cc | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/v/kafka/server/tests/topic_recreate_test.cc b/src/v/kafka/server/tests/topic_recreate_test.cc index c5c253489acca..b8227e0e96bb1 100644 --- a/src/v/kafka/server/tests/topic_recreate_test.cc +++ b/src/v/kafka/server/tests/topic_recreate_test.cc @@ -122,18 +122,6 @@ class recreate_test_fixture : public redpanda_thread_fixture { }); }); } - - void restart() { - shutdown(); - app_signal = std::make_unique<::stop_signal>(); - ss::smp::invoke_on_all([] { - auto& config = config::shard_local_cfg(); - config.get("disable_metrics").set_value(false); - }).get(); - app.initialize(proxy_config(), proxy_client_config()); - app.check_environment(); - app.wire_up_and_start(*app_signal, true); - } }; FIXTURE_TEST(test_topic_recreation, recreate_test_fixture) { @@ -184,7 +172,7 @@ FIXTURE_TEST(test_topic_recreation_recovery, recreate_test_fixture) { test_tp, kafka::error_code::unknown_topic_or_partition) .get(); info("Restarting redpanda, first time"); - restart(); + restart(should_wipe::no); wait_for_controller_leadership().get(); info("Creating {} with {} partitions", test_tp, 3); create_topic(test_tp(), 3, 1); @@ -197,7 +185,7 @@ FIXTURE_TEST(test_topic_recreation_recovery, recreate_test_fixture) { create_topic(test_tp(), 3, 1); wait_until_topic_status(test_tp, kafka::error_code::none).get(); info("Restarting redpanda, second time"); - restart(); + restart(should_wipe::no); info("Waiting for recovery"); wait_for_controller_leadership().get(); wait_until_topic_status(test_tp, kafka::error_code::none).get(); @@ -272,7 +260,7 @@ FIXTURE_TEST(test_recreated_topic_does_not_lose_data, recreate_test_fixture) { }) .get(); info("Restarting redpanda"); - restart(); + restart(should_wipe::no); // make sure we can read the same amount of data { From 4903befa58ae6943601d13e18f697add3497a6bc Mon Sep 17 00:00:00 2001 From: Nicolae Vartolomei Date: Sat, 22 Feb 2025 10:15:41 +0000 Subject: [PATCH 2/2] k/server/tests: reset leaders table on restart It seems that we keep running with old leaders table after restart otherwise and wait_for_controller_leadership succeeds before a leader is elected in the new post-restart term. Noticed this because test_topic_recreation_recovery keeps failing locally for me. --- src/v/kafka/server/tests/topic_recreate_test.cc | 1 + src/v/redpanda/tests/fixture.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/v/kafka/server/tests/topic_recreate_test.cc b/src/v/kafka/server/tests/topic_recreate_test.cc index b8227e0e96bb1..1da64428648e3 100644 --- a/src/v/kafka/server/tests/topic_recreate_test.cc +++ b/src/v/kafka/server/tests/topic_recreate_test.cc @@ -176,6 +176,7 @@ FIXTURE_TEST(test_topic_recreation_recovery, recreate_test_fixture) { wait_for_controller_leadership().get(); info("Creating {} with {} partitions", test_tp, 3); create_topic(test_tp(), 3, 1); + wait_until_topic_status(test_tp, kafka::error_code::none).get(); info("Deleting {}", test_tp); delete_topics({test_tp}); wait_until_topic_status( diff --git a/src/v/redpanda/tests/fixture.h b/src/v/redpanda/tests/fixture.h index d450894a23f3b..92b6813f262c3 100644 --- a/src/v/redpanda/tests/fixture.h +++ b/src/v/redpanda/tests/fixture.h @@ -280,6 +280,9 @@ class redpanda_thread_fixture { app.initialize(proxy_config(), proxy_client_config()); app.check_environment(); app.wire_up_and_start(*app_signal, true); + app.controller->get_partition_leaders() + .invoke_on_all([](cluster::partition_leaders_table& t) { t.reset(); }) + .get(); } config::configuration& lconf() { return config::shard_local_cfg(); }