Skip to content

Commit

Permalink
storage: build tests with bazel
Browse files Browse the repository at this point in the history
Signed-off-by: Noah Watkins <[email protected]>
  • Loading branch information
dotnwat committed Jan 7, 2025
1 parent 9e7fe8c commit d41e950
Show file tree
Hide file tree
Showing 8 changed files with 680 additions and 12 deletions.
61 changes: 61 additions & 0 deletions src/v/storage/mvlog/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
load("//bazel:build.bzl", "redpanda_cc_library")

package(
default_visibility = [
"//src/v/storage/mvlog/tests:__pkg__",
],
)

redpanda_cc_library(
name = "mvlog",
srcs = [
"batch_collecting_stream_utils.cc",
"batch_collector.cc",
"entry.cc",
"entry_stream.cc",
"entry_stream_utils.cc",
"file.cc",
"logger.cc",
"readable_segment.cc",
"segment_appender.cc",
"segment_reader.cc",
"skipping_data_source.cc",
"versioned_log.cc",
],
hdrs = [
"batch_collecting_stream_utils.h",
"batch_collector.h",
"entry.h",
"entry_stream.h",
"entry_stream_utils.h",
"errc.h",
"file.h",
"file_gap.h",
"logger.h",
"readable_segment.h",
"reader_outcome.h",
"segment_appender.h",
"segment_identifier.h",
"segment_reader.h",
"skipping_data_source.h",
"versioned_log.h",
],
include_prefix = "storage/mvlog",
deps = [
"//src/v/base",
"//src/v/bytes:iobuf",
"//src/v/bytes:iostream",
"//src/v/container:fragmented_vector",
"//src/v/container:interval_set",
"//src/v/hashing:crc32c",
"//src/v/io",
"//src/v/model",
"//src/v/serde",
"//src/v/storage",
"//src/v/storage:record_batch_utils",
"//src/v/utils:mutex",
"//src/v/utils:named_type",
"@fmt",
"@seastar",
],
)
161 changes: 161 additions & 0 deletions src/v/storage/mvlog/tests/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
load("//bazel:test.bzl", "redpanda_cc_gtest")

redpanda_cc_gtest(
name = "active_segment_test",
timeout = "short",
srcs = [
"active_segment_test.cc",
],
deps = [
"//src/v/base",
"//src/v/model/tests:random",
"//src/v/random:generators",
"//src/v/storage",
"//src/v/storage/mvlog",
"//src/v/test_utils:gtest",
"@googletest//:gtest",
"@seastar",
"@seastar//:testing",
],
)

redpanda_cc_gtest(
name = "batch_collecting_stream_utils_test",
timeout = "short",
srcs = [
"batch_collecting_stream_utils_test.cc",
],
deps = [
"//src/v/bytes:iostream",
"//src/v/hashing:crc32",
"//src/v/model",
"//src/v/model/tests:random",
"//src/v/storage",
"//src/v/storage:record_batch_utils",
"//src/v/storage/mvlog",
"//src/v/test_utils:gtest",
"@googletest//:gtest",
"@seastar",
"@seastar//:testing",
],
)

redpanda_cc_gtest(
name = "batch_collector_test",
timeout = "short",
srcs = [
"batch_collector_test.cc",
],
deps = [
"//src/v/model",
"//src/v/storage",
"//src/v/storage/mvlog",
"//src/v/test_utils:gtest",
"@googletest//:gtest",
"@seastar",
"@seastar//:testing",
],
)

redpanda_cc_gtest(
name = "entry_stream_utils_test",
timeout = "short",
srcs = [
"entry_stream_utils_test.cc",
],
deps = [
"//src/v/bytes:iostream",
"//src/v/bytes:random",
"//src/v/random:generators",
"//src/v/storage/mvlog",
"//src/v/test_utils:gtest",
"@googletest//:gtest",
"@seastar//:testing",
],
)

redpanda_cc_gtest(
name = "file_test",
timeout = "short",
srcs = [
"file_test.cc",
],
deps = [
"//src/v/bytes:random",
"//src/v/container:fragmented_vector",
"//src/v/storage/mvlog",
"//src/v/test_utils:gtest",
"@googletest//:gtest",
"@seastar",
"@seastar//:testing",
],
)

redpanda_cc_gtest(
name = "segment_appender_test",
timeout = "short",
srcs = [
"segment_appender_test.cc",
],
deps = [
"//src/v/model",
"//src/v/model/tests:random",
"//src/v/storage:record_batch_utils",
"//src/v/storage/mvlog",
"//src/v/test_utils:gtest",
"@googletest//:gtest",
"@seastar",
"@seastar//:testing",
],
)

redpanda_cc_gtest(
name = "segment_io_test",
timeout = "short",
srcs = [
"segment_io_test.cc",
],
deps = [
"//src/v/model/tests:random",
"//src/v/storage/mvlog",
"//src/v/test_utils:gtest",
"@googletest//:gtest",
"@seastar",
"@seastar//:testing",
],
)

redpanda_cc_gtest(
name = "segment_reader_test",
timeout = "short",
srcs = [
"segment_reader_test.cc",
],
deps = [
"//src/v/random:generators",
"//src/v/storage/mvlog",
"//src/v/test_utils:gtest",
"@googletest//:gtest",
"@seastar",
"@seastar//:testing",
],
)

redpanda_cc_gtest(
name = "skipping_data_source_test",
timeout = "short",
srcs = [
"skipping_data_source_test.cc",
],
deps = [
"//src/v/base",
"//src/v/bytes:iostream",
"//src/v/bytes:random",
"//src/v/random:generators",
"//src/v/storage/mvlog",
"//src/v/test_utils:gtest",
"@googletest//:gtest",
"@seastar",
"@seastar//:testing",
],
)
137 changes: 136 additions & 1 deletion src/v/storage/mvlog/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,132 @@ rp_test(
BINARY_NAME mvlog
SOURCES
active_segment_test.cc
LIBRARIES
v::gtest_main
v::hashing
v::model
v::model_test_utils
v::mvlog
v::random
v::storage
ARGS "-- -c1"
)

rp_test(
UNIT_TEST
GTEST
USE_CWD
BINARY_NAME mvlog
SOURCES
batch_collecting_stream_utils_test.cc
LIBRARIES
v::gtest_main
v::hashing
v::model
v::model_test_utils
v::mvlog
v::random
v::storage
ARGS "-- -c1"
)

rp_test(
UNIT_TEST
GTEST
USE_CWD
BINARY_NAME mvlog
SOURCES
batch_collector_test.cc
LIBRARIES
v::gtest_main
v::hashing
v::model
v::model_test_utils
v::mvlog
v::random
v::storage
ARGS "-- -c1"
)

rp_test(
UNIT_TEST
GTEST
USE_CWD
BINARY_NAME mvlog
SOURCES
entry_stream_utils_test.cc
LIBRARIES
v::gtest_main
v::hashing
v::model
v::model_test_utils
v::mvlog
v::random
v::storage
ARGS "-- -c1"
)

rp_test(
UNIT_TEST
GTEST
USE_CWD
BINARY_NAME mvlog
SOURCES
file_test.cc
LIBRARIES
v::gtest_main
v::hashing
v::model
v::model_test_utils
v::mvlog
v::random
v::storage
ARGS "-- -c1"
)

rp_test(
UNIT_TEST
GTEST
USE_CWD
BINARY_NAME mvlog
SOURCES
segment_appender_test.cc
LIBRARIES
v::gtest_main
v::hashing
v::model
v::model_test_utils
v::mvlog
v::random
v::storage
ARGS "-- -c1"
)

rp_test(
UNIT_TEST
GTEST
USE_CWD
BINARY_NAME mvlog
SOURCES
segment_io_test.cc
LIBRARIES
v::gtest_main
v::hashing
v::model
v::model_test_utils
v::mvlog
v::random
v::storage
ARGS "-- -c1"
)

rp_test(
UNIT_TEST
GTEST
USE_CWD
BINARY_NAME mvlog
SOURCES
segment_reader_test.cc
skipping_data_source_test.cc
LIBRARIES
v::gtest_main
v::hashing
Expand All @@ -24,3 +142,20 @@ rp_test(
ARGS "-- -c1"
)

rp_test(
UNIT_TEST
GTEST
USE_CWD
BINARY_NAME mvlog
SOURCES
skipping_data_source_test.cc
LIBRARIES
v::gtest_main
v::hashing
v::model
v::model_test_utils
v::mvlog
v::random
v::storage
ARGS "-- -c1"
)
2 changes: 1 addition & 1 deletion src/v/storage/mvlog/tests/entry_stream_utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ TEST(EntryStream, TestShortHeader) {
entry_header hdr{0, 0, entry_type::record_batch};
hdr_buf.append(entry_header_to_iobuf(hdr));
ASSERT_GT(hdr_buf.size_bytes(), 1);
for (int i = 1; i < hdr_buf.size_bytes(); i++) {
for (size_t i = 1; i < hdr_buf.size_bytes(); i++) {
auto copy_buf = hdr_buf.copy();
copy_buf.trim_back(i);
auto short_stream = make_iobuf_input_stream(std::move(copy_buf));
Expand Down
Loading

0 comments on commit d41e950

Please sign in to comment.