From f820b60db3118acef410a8119f961b079dcae588 Mon Sep 17 00:00:00 2001 From: Oren Leiman Date: Sun, 17 Nov 2024 12:24:51 -0800 Subject: [PATCH 1/7] k/client: test fixture public visibility (bazel) Signed-off-by: Oren Leiman --- src/v/kafka/client/test/BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/src/v/kafka/client/test/BUILD b/src/v/kafka/client/test/BUILD index c0a376ec7730..87089b2badbd 100644 --- a/src/v/kafka/client/test/BUILD +++ b/src/v/kafka/client/test/BUILD @@ -8,6 +8,7 @@ redpanda_test_cc_library( implementation_deps = [ ], include_prefix = "kafka/client/test", + visibility = ["//visibility:public"], deps = [ "//src/v/kafka/client", "//src/v/redpanda/tests:fixture", From 7df1de67adb21bdd31a06e33756d1c51f3055d6e Mon Sep 17 00:00:00 2001 From: Oren Leiman Date: Sun, 17 Nov 2024 12:26:27 -0800 Subject: [PATCH 2/7] audit: bazelize audit_log_test.cc CORE-7596 Signed-off-by: Oren Leiman --- src/v/security/audit/tests/BUILD | 19 +++++++++++++++++++ src/v/security/audit/tests/audit_log_test.cc | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/v/security/audit/tests/BUILD diff --git a/src/v/security/audit/tests/BUILD b/src/v/security/audit/tests/BUILD new file mode 100644 index 000000000000..193a3557d14f --- /dev/null +++ b/src/v/security/audit/tests/BUILD @@ -0,0 +1,19 @@ +load("//bazel:test.bzl", "redpanda_cc_btest") + +redpanda_cc_btest( + name = "audit_test", + timeout = "short", + srcs = ["audit_log_test.cc"], + cpu = 1, + memory = "256MiB", + deps = [ + "//src/v/cluster", + "//src/v/kafka/client/test:fixture", + "//src/v/redpanda/tests:fixture", + "//src/v/security/audit", + "//src/v/security/audit:types", + "//src/v/test_utils:seastar_boost", + "@boost//:test", + "@seastar", + ], +) diff --git a/src/v/security/audit/tests/audit_log_test.cc b/src/v/security/audit/tests/audit_log_test.cc index 7f430a3d85ee..952f243fe0fd 100644 --- a/src/v/security/audit/tests/audit_log_test.cc +++ b/src/v/security/audit/tests/audit_log_test.cc @@ -95,8 +95,8 @@ FIXTURE_TEST(test_audit_init_phase, kafka_client_fixture) { /// with auditing disabled, calls to enqueue should be no-ops const auto n_events = pending_audit_events(audit_mgr.local()).get(); audit_mgr - .invoke_on_all([](sa::audit_log_manager& m) { - for (auto i = 0; i < 20; ++i) { + .invoke_on_all([]([[maybe_unused]] sa::audit_log_manager& m) { + for ([[maybe_unused]] int i = 0; i < 20; ++i) { BOOST_ASSERT(m.enqueue_authn_event(make_random_authn_options())); } }) From 9010fe29387a414770e583decb94cc19b02e0f10 Mon Sep 17 00:00:00 2001 From: Oren Leiman Date: Sun, 17 Nov 2024 15:34:20 -0800 Subject: [PATCH 3/7] kafka: bazelize alter_config_test And fix some includes CORE-7492 Signed-off-by: Oren Leiman --- src/v/kafka/server/tests/BUILD | 30 +++++++++++++++++++ src/v/kafka/server/tests/alter_config_test.cc | 4 --- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/v/kafka/server/tests/BUILD b/src/v/kafka/server/tests/BUILD index 73682fa115d9..2dfa7a796698 100644 --- a/src/v/kafka/server/tests/BUILD +++ b/src/v/kafka/server/tests/BUILD @@ -658,3 +658,33 @@ redpanda_cc_btest( "@seastar//:testing", ], ) + +redpanda_cc_btest( + name = "alter_config_test", + timeout = "short", + srcs = [ + "alter_config_test.cc", + ], + cpu = "1", + tags = ["exclusive"], + deps = [ + "//src/v/config", + "//src/v/container:fragmented_vector", + "//src/v/kafka/client", + "//src/v/kafka/protocol", + "//src/v/kafka/protocol:alter_configs", + "//src/v/kafka/protocol:create_topics", + "//src/v/kafka/protocol:describe_configs", + "//src/v/kafka/protocol:incremental_alter_configs", + "//src/v/kafka/protocol:metadata", + "//src/v/kafka/server", + "//src/v/kafka/server/tests:topic_properties_helpers", + "//src/v/model", + "//src/v/test_utils:scoped_config", + "//src/v/test_utils:seastar_boost", + "@abseil-cpp//absl/container:flat_hash_map", + "@boost//:test", + "@seastar", + "@seastar//:testing", + ], +) diff --git a/src/v/kafka/server/tests/alter_config_test.cc b/src/v/kafka/server/tests/alter_config_test.cc index 13ca8a540bc8..4dedd765a9fe 100644 --- a/src/v/kafka/server/tests/alter_config_test.cc +++ b/src/v/kafka/server/tests/alter_config_test.cc @@ -16,10 +16,6 @@ #include "kafka/protocol/errors.h" #include "kafka/protocol/incremental_alter_configs.h" #include "kafka/protocol/metadata.h" -#include "kafka/protocol/schemata/alter_configs_request.h" -#include "kafka/protocol/schemata/describe_configs_request.h" -#include "kafka/protocol/schemata/describe_configs_response.h" -#include "kafka/protocol/schemata/incremental_alter_configs_request.h" #include "kafka/server/handlers/topics/types.h" #include "kafka/server/rm_group_frontend.h" #include "kafka/server/tests/topic_properties_helpers.h" From 6f30a8cc01313eab2f099b1ce246fdcf83be9da4 Mon Sep 17 00:00:00 2001 From: Oren Leiman Date: Sun, 17 Nov 2024 17:23:44 -0800 Subject: [PATCH 4/7] kafka: bazelize produce_consume_test And fix up some includes CORE-7519 Signed-off-by: Oren Leiman --- src/v/kafka/server/tests/BUILD | 27 +++++++++++++++++++ .../server/tests/produce_consume_test.cc | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/v/kafka/server/tests/BUILD b/src/v/kafka/server/tests/BUILD index 2dfa7a796698..7fdb923a29c4 100644 --- a/src/v/kafka/server/tests/BUILD +++ b/src/v/kafka/server/tests/BUILD @@ -688,3 +688,30 @@ redpanda_cc_btest( "@seastar//:testing", ], ) + +redpanda_cc_btest( + name = "produce_consume_test", + timeout = "moderate", + srcs = [ + "produce_consume_test.cc", + ], + cpu = "1", + tags = ["exclusive"], + deps = [ + ":kafka_test_utils", + "//src/v/container:fragmented_vector", + "//src/v/kafka/client", + "//src/v/kafka/protocol", + "//src/v/kafka/protocol:fetch", + "//src/v/kafka/protocol:produce", + "//src/v/kafka/server", + "//src/v/model", + "//src/v/random:generators", + "//src/v/redpanda/tests:fixture", + "//src/v/storage:record_batch_builder", + "//src/v/test_utils:seastar_boost", + "@boost//:test", + "@seastar", + "@seastar//:testing", + ], +) diff --git a/src/v/kafka/server/tests/produce_consume_test.cc b/src/v/kafka/server/tests/produce_consume_test.cc index 13940b25e029..e0034463541d 100644 --- a/src/v/kafka/server/tests/produce_consume_test.cc +++ b/src/v/kafka/server/tests/produce_consume_test.cc @@ -11,12 +11,12 @@ #include "kafka/client/transport.h" #include "kafka/protocol/errors.h" #include "kafka/protocol/fetch.h" -#include "kafka/protocol/offset_for_leader_epoch.h" #include "kafka/protocol/produce.h" #include "kafka/protocol/wire.h" #include "kafka/server/handlers/produce.h" #include "kafka/server/snc_quota_manager.h" #include "kafka/server/tests/delete_records_utils.h" +#include "kafka/server/tests/offset_for_leader_epoch_utils.h" #include "kafka/server/tests/produce_consume_utils.h" #include "model/fundamental.h" #include "model/timeout_clock.h" From 26e0c750ea9a2e3110175825fe2716a26bc791de Mon Sep 17 00:00:00 2001 From: Oren Leiman Date: Sun, 17 Nov 2024 22:49:02 -0800 Subject: [PATCH 5/7] bazel: Refactor test fixture rules to support gtest Signed-off-by: Oren Leiman --- src/v/redpanda/tests/BUILD | 32 +++++++++++++++++++++++++++++--- src/v/test_utils/BUILD | 27 +++++++++++++++++++++------ 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/v/redpanda/tests/BUILD b/src/v/redpanda/tests/BUILD index 0dc6976738f6..2bb48afb8f6e 100644 --- a/src/v/redpanda/tests/BUILD +++ b/src/v/redpanda/tests/BUILD @@ -1,5 +1,18 @@ load("//bazel:test.bzl", "redpanda_test_cc_library") +redpanda_test_cc_library( + name = "fixture_base", + implementation_deps = [ + ], + include_prefix = "redpanda/tests", + visibility = ["//visibility:private"], + deps = [ + "//src/v/redpanda:application", + "//src/v/storage/tests:disk_log_builder", + "//src/v/test_utils:fixture", + ], +) + redpanda_test_cc_library( name = "fixture", hdrs = [ @@ -10,9 +23,22 @@ redpanda_test_cc_library( include_prefix = "redpanda/tests", visibility = ["//visibility:public"], deps = [ + ":fixture_base", "//src/v/cloud_storage/tests:s3_imposter", - "//src/v/redpanda:application", - "//src/v/storage/tests:disk_log_builder", - "//src/v/test_utils:seastar_boost", + ], +) + +redpanda_test_cc_library( + name = "fixture_gtest", + hdrs = [ + "fixture.h", + ], + implementation_deps = [ + ], + include_prefix = "redpanda/tests", + visibility = ["//visibility:public"], + deps = [ + ":fixture_base", + "//src/v/cloud_storage/tests:s3_imposter_gtest", ], ) diff --git a/src/v/test_utils/BUILD b/src/v/test_utils/BUILD index 52c26192fef8..f89e830dfae8 100644 --- a/src/v/test_utils/BUILD +++ b/src/v/test_utils/BUILD @@ -1,5 +1,24 @@ load("//bazel:test.bzl", "redpanda_test_cc_library") +redpanda_test_cc_library( + name = "fixture", + hdrs = [ + "async.h", + "fixture.h", + "logs.h", + "test_macros.h", + "tmp_dir.h", + ], + include_prefix = "test_utils", + visibility = ["//visibility:public"], + deps = [ + "//src/v/base", + "//src/v/model", + "//src/v/storage", + "@seastar//:testing", + ], +) + redpanda_test_cc_library( name = "gtest", srcs = [ @@ -16,9 +35,7 @@ redpanda_test_cc_library( include_prefix = "test_utils", visibility = ["//visibility:public"], deps = [ - "//src/v/base", - "//src/v/model", - "//src/v/storage", + ":fixture", "@fmt", "@googletest//:gtest", "@seastar", @@ -41,9 +58,7 @@ redpanda_test_cc_library( include_prefix = "test_utils", visibility = ["//visibility:public"], deps = [ - "//src/v/base", - "//src/v/model", - "//src/v/storage", + "//src/v/test_utils:fixture", "@seastar//:testing", ], ) From ad06c7a0132b960e40b7229b5e693b4dee506a8c Mon Sep 17 00:00:00 2001 From: Oren Leiman Date: Sun, 17 Nov 2024 22:51:45 -0800 Subject: [PATCH 6/7] kafka: Bazelize group_tx_compaction_test CORE-7510 Signed-off-by: Oren Leiman --- src/v/kafka/server/tests/BUILD | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/v/kafka/server/tests/BUILD b/src/v/kafka/server/tests/BUILD index 7fdb923a29c4..1c10b268e006 100644 --- a/src/v/kafka/server/tests/BUILD +++ b/src/v/kafka/server/tests/BUILD @@ -715,3 +715,22 @@ redpanda_cc_btest( "@seastar//:testing", ], ) + +redpanda_cc_gtest( + name = "group_tx_compaction_test", + timeout = "moderate", + srcs = [ + "group_tx_compaction_test.cc", + ], + cpu = 1, + deps = [ + "//src/v/config", + "//src/v/kafka/server", + "//src/v/model/tests:random", + "//src/v/raft", + "//src/v/redpanda/tests:fixture_gtest", + "//src/v/test_utils:gtest", + "//src/v/test_utils:scoped_config", + "@googletest//:gtest", + ], +) From c3bdc5bbfb747ae9c2aa3d1941e10b69aa6d8f7b Mon Sep 17 00:00:00 2001 From: Oren Leiman Date: Sun, 17 Nov 2024 23:12:08 -0800 Subject: [PATCH 7/7] kafka: bazelize fetch_test CORE-7505 Signed-off-by: Oren Leiman --- src/v/kafka/server/tests/BUILD | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/v/kafka/server/tests/BUILD b/src/v/kafka/server/tests/BUILD index 1c10b268e006..a4310adef5dd 100644 --- a/src/v/kafka/server/tests/BUILD +++ b/src/v/kafka/server/tests/BUILD @@ -734,3 +734,25 @@ redpanda_cc_gtest( "@googletest//:gtest", ], ) + +redpanda_cc_gtest( + name = "fetch_test", + timeout = "short", + srcs = [ + "fetch_test.cc", + ], + cpu = 1, + deps = [ + "//src/v/kafka/protocol", + "//src/v/kafka/server", + "//src/v/model", + "//src/v/redpanda/tests:fixture", + "//src/v/resource_mgmt:io_priority", + "//src/v/test_utils:gtest", + "//src/v/test_utils:seastar_boost", + "@boost//:test", + "@fmt", + "@seastar", + "@seastar//:testing", + ], +)