Skip to content

Commit 18c48c5

Browse files
committed
ct: add test config for fixtures
Some tests will want to start the Redpanda application with certain features turned off. Rather than exposing this abililty to users with a cluster property, this plumbs a struct through the application to be used by test fixtures. This is done in this commit to disable the flush loop when running replicated_metastore_test, which will exercise flushes of its own. Now that this is configurable and set appropriately for replicated_metastore_test, the default behavior is also switched to _not_ skipping the flush loop.
1 parent de2a5a9 commit 18c48c5

File tree

16 files changed

+92
-32
lines changed

16 files changed

+92
-32
lines changed

src/v/cloud_topics/BUILD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ redpanda_cc_library(
2424
],
2525
)
2626

27+
redpanda_cc_library(
28+
name = "test_fixture_cfg",
29+
hdrs = [
30+
"test_fixture_cfg.h",
31+
],
32+
visibility = [
33+
"//src/v/cloud_topics/tests:__pkg__",
34+
"//src/v/redpanda:__pkg__",
35+
"//src/v/redpanda/tests:__pkg__",
36+
],
37+
)
38+
2739
redpanda_cc_library(
2840
name = "types",
2941
srcs = [
@@ -80,6 +92,7 @@ redpanda_cc_library(
8092
":cluster_services_interface",
8193
":data_plane_impl",
8294
"//src/v/cloud_topics/housekeeper:manager",
95+
"//src/v/cloud_topics/level_one/metastore:flush_loop",
8396
"//src/v/cloud_topics/level_one/metastore:topic_purger",
8497
"//src/v/cloud_topics/level_zero/gc:level_zero_gc",
8598
"//src/v/cloud_topics/manager",

src/v/cloud_topics/app.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class app : public ssx::sharded_service_container {
6565
ss::sharded<rpc::connection_cache>*,
6666
cloud_storage_clients::bucket_name,
6767
ss::sharded<storage::api>*,
68-
bool skip_flush_loop = true);
68+
bool skip_flush_loop = false);
6969

7070
ss::future<> start();
7171

src/v/cloud_topics/level_one/metastore/tests/replicated_metastore_test.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,16 @@ class ReplicatedMetastoreTest
4141

4242
bool is_lsm_backend() const { return GetParam() == metastore_backend::lsm; }
4343

44+
cloud_topics::test_fixture_cfg fixture_cfg() const {
45+
return {
46+
.use_lsm_metastore = is_lsm_backend(),
47+
// Skip flushing since tests may exercise flushing.
48+
.skip_flush_loop = true,
49+
};
50+
}
4451
void SetUp() override {
4552
for (size_t i = 0; i < num_brokers; i++) {
46-
add_node(is_lsm_backend());
53+
add_node(fixture_cfg());
4754
}
4855
wait_for_all_members(5s).get();
4956
}
@@ -1007,7 +1014,7 @@ TEST_P(ReplicatedMetastoreTest, TestBasicFlushAndRestore) {
10071014
// Restart all nodes.
10081015
// NOTE: the added nodes get the same node IDs 0, 1, 2.
10091016
for (size_t i = 0; i < num_brokers; i++) {
1010-
add_node(is_lsm_backend());
1017+
add_node(fixture_cfg());
10111018
}
10121019
wait_for_all_members(5s).get();
10131020

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2025 Redpanda Data, Inc.
3+
*
4+
* Licensed as a Redpanda Enterprise file under the Redpanda Community
5+
* License (the "License"); you may not use this file except in compliance with
6+
* the License. You may obtain a copy of the License at
7+
*
8+
* https://github.com/redpanda-data/redpanda/blob/master/licenses/rcl.md
9+
*/
10+
11+
#pragma once
12+
13+
namespace cloud_topics {
14+
15+
// Configuration for cloud topics test fixtures.
16+
struct test_fixture_cfg {
17+
bool use_lsm_metastore{true};
18+
bool skip_flush_loop{false};
19+
};
20+
21+
} // namespace cloud_topics

src/v/cloud_topics/tests/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ redpanda_test_cc_library(
77
deps = [
88
"//src/v/cloud_io/tests:s3_imposter",
99
"//src/v/cloud_topics:app",
10+
"//src/v/cloud_topics:test_fixture_cfg",
1011
"//src/v/cloud_topics/level_one/metastore:simple_stm",
1112
"//src/v/cluster/tests:cluster_test_fixture",
1213
"//src/v/kafka/server/tests:kafka_test_utils",

src/v/cloud_topics/tests/cluster_fixture.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "cloud_topics/app.h"
1515
#include "cloud_topics/level_one/metastore/lsm/stm.h"
1616
#include "cloud_topics/level_one/metastore/simple_stm.h"
17+
#include "cloud_topics/test_fixture_cfg.h"
1718
#include "cluster/tests/cluster_test_fixture.h"
1819
#include "kafka/server/tests/produce_consume_utils.h"
1920
#include "model/fundamental.h"
@@ -39,7 +40,7 @@ class cluster_fixture
3940
remove_node_application(id);
4041
}
4142
}
42-
void add_node(bool use_lsm_metastore = true) {
43+
void add_node(cloud_topics::test_fixture_cfg ct_test_cfg = {}) {
4344
static constexpr int kafka_port_base = 9092;
4445
static constexpr int rpc_port_base = 11000;
4546
auto [s3_conf, a_conf, cs_conf] = get_cloud_storage_configurations(
@@ -60,7 +61,7 @@ class cluster_fixture
6061
/*cloud_topics_enabled=*/true,
6162
/*cluster_linking_enabled=*/false,
6263
/*seed_node_id=*/model::node_id{0},
63-
use_lsm_metastore);
64+
ct_test_cfg);
6465
}
6566

6667
ss::future<kafka_produce_transport*> make_producer(model::node_id id) {

src/v/cluster/tests/cluster_test_fixture.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class cluster_test_fixture {
122122
bool iceberg_enabled = false,
123123
bool cloud_topics_enabled = false,
124124
bool cluster_linking_enabled = false,
125-
bool use_lsm_metastore = false) {
125+
cloud_topics::test_fixture_cfg ct_test_cfg = {}) {
126126
return std::make_unique<redpanda_thread_fixture>(
127127
node_id,
128128
kafka_port,
@@ -142,7 +142,7 @@ class cluster_test_fixture {
142142
iceberg_enabled,
143143
cloud_topics_enabled,
144144
cluster_linking_enabled,
145-
use_lsm_metastore);
145+
ct_test_cfg);
146146
}
147147

148148
void add_node(
@@ -163,7 +163,7 @@ class cluster_test_fixture {
163163
bool iceberg_enabled = false,
164164
bool cloud_topics_enabled = false,
165165
bool cluster_linking_enabled = false,
166-
bool use_lsm_metastore = true) {
166+
cloud_topics::test_fixture_cfg ct_test_cfg = {}) {
167167
_instances.emplace(
168168
node_id,
169169
make_redpanda_fixture(
@@ -182,7 +182,7 @@ class cluster_test_fixture {
182182
iceberg_enabled,
183183
cloud_topics_enabled,
184184
cluster_linking_enabled,
185-
use_lsm_metastore));
185+
ct_test_cfg));
186186
}
187187

188188
application* get_node_application(model::node_id id) {
@@ -225,7 +225,7 @@ class cluster_test_fixture {
225225
bool cloud_topics_enabled = false,
226226
bool cluster_linking_enabled = false,
227227
model::node_id seed_node_id = model::node_id{0},
228-
bool use_lsm_metastore = true) {
228+
cloud_topics::test_fixture_cfg ct_test_cfg = {}) {
229229
std::vector<config::seed_server> seeds = {};
230230
if (!empty_seed_starts_cluster_val || node_id != 0) {
231231
seeds.push_back(
@@ -250,7 +250,7 @@ class cluster_test_fixture {
250250
iceberg_enabled,
251251
cloud_topics_enabled,
252252
cluster_linking_enabled,
253-
use_lsm_metastore);
253+
ct_test_cfg);
254254
return get_node_application(node_id);
255255
}
256256

src/v/redpanda/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ redpanda_cc_library(
3030
"//src/v/cloud_storage",
3131
"//src/v/cloud_storage_clients",
3232
"//src/v/cloud_topics:app",
33+
"//src/v/cloud_topics:test_fixture_cfg",
3334
"//src/v/cloud_topics/level_one/metastore:leader_router",
3435
"//src/v/cloud_topics/level_one/metastore:simple_stm",
3536
"//src/v/cloud_topics/level_one/metastore/lsm:stm",

src/v/redpanda/application.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "base/seastarx.h"
1515
#include "cloud_storage/fwd.h"
1616
#include "cloud_topics/app.h"
17+
#include "cloud_topics/test_fixture_cfg.h"
1718
#include "cluster/archival/fwd.h"
1819
#include "cluster/config_manager.h"
1920
#include "cluster/fwd.h"
@@ -97,7 +98,9 @@ class application : public ssx::sharded_service_container {
9798
std::optional<YAML::Node> audit_log_client_cfg = std::nullopt);
9899
void check_environment();
99100
void wire_up_and_start(
100-
::stop_signal&, bool test_mode = false, bool use_lsm_metastore = true);
101+
::stop_signal&,
102+
bool test_mode = false,
103+
cloud_topics::test_fixture_cfg ct_test_cfg = {});
101104
void post_start_tasks();
102105

103106
void init_crashtracker(::stop_signal& app_signal);
@@ -224,13 +227,16 @@ class application : public ssx::sharded_service_container {
224227
void start_bootstrap_services();
225228

226229
// Constructs services across shards meant for Redpanda runtime.
227-
void
228-
wire_up_runtime_services(model::node_id node_id, ::stop_signal& app_signal);
230+
void wire_up_runtime_services(
231+
model::node_id node_id,
232+
::stop_signal& app_signal,
233+
cloud_topics::test_fixture_cfg ct_test_cfg);
229234
void configure_admin_server(model::node_id);
230235
void wire_up_redpanda_services(
231236
model::node_id,
232237
::stop_signal& app_signal,
233-
std::optional<cloud_storage_clients::bucket_name>& bucket_name);
238+
std::optional<cloud_storage_clients::bucket_name>& bucket_name,
239+
cloud_topics::test_fixture_cfg ct_test_cfg);
234240

235241
void load_feature_table_snapshot();
236242

@@ -239,7 +245,9 @@ class application : public ssx::sharded_service_container {
239245
// Starts the services meant for Redpanda runtime. Must be called after
240246
// having constructed the subsystems via the corresponding `wire_up` calls.
241247
void start_runtime_services(
242-
cluster::cluster_discovery&, ::stop_signal&, bool use_lsm_metastore);
248+
cluster::cluster_discovery&,
249+
::stop_signal&,
250+
cloud_topics::test_fixture_cfg ct_test_cfg);
243251
void start_kafka(const model::node_id&, ::stop_signal&);
244252
void add_runtime_rpc_services(rpc::rpc_server&, bool start_raft_rpc_early);
245253

src/v/redpanda/application_bootstrap.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,9 @@ void application::start_bootstrap_services() {
385385
}
386386

387387
void application::wire_up_and_start(
388-
::stop_signal& app_signal, bool test_mode, bool use_lsm_metastore) {
388+
::stop_signal& app_signal,
389+
bool test_mode,
390+
cloud_topics::test_fixture_cfg ct_test_cfg) {
389391
// Setup the app level abort service
390392
construct_service(_as).get();
391393

@@ -510,7 +512,7 @@ void application::wire_up_and_start(
510512
node_id,
511513
storage.local().get_cluster_uuid());
512514

513-
wire_up_runtime_services(node_id, app_signal);
515+
wire_up_runtime_services(node_id, app_signal, ct_test_cfg);
514516

515517
if (test_mode) {
516518
// When running inside a unit test fixture, we may fast-forward
@@ -545,7 +547,7 @@ void application::wire_up_and_start(
545547
controller->set_ready().get();
546548
}
547549

548-
start_runtime_services(cd, app_signal, use_lsm_metastore);
550+
start_runtime_services(cd, app_signal, ct_test_cfg);
549551

550552
if (_proxy_config && !config::node().recovery_mode_enabled) {
551553
_proxy->start().get();

0 commit comments

Comments
 (0)