Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add storage_e2e_single_threaded test in bazel #23878

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions src/v/storage/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,48 @@ redpanda_test_cc_library(
],
)

redpanda_test_cc_library(
name = "common",
hdrs = [
"common.h",
],
include_prefix = "storage/tests",
deps = [
"//src/v/storage",
],
)

redpanda_test_cc_library(
name = "storage_test_fixture",
hdrs = [
"storage_test_fixture.h",
],
include_prefix = "storage/tests",
deps = [
"//src/v/compression",
"//src/v/config",
"//src/v/features",
"//src/v/model/tests:random",
"//src/v/storage",
"//src/v/test_utils:seastar_boost",
],
)

redpanda_test_cc_library(
name = "log_gap_analysis",
srcs = [
"utils/log_gap_analysis.cc",
],
hdrs = [
"utils/log_gap_analysis.h",
],
include_prefix = "storage/tests",
deps = [
"//src/v/model",
"//src/v/storage:parser_utils",
],
)

redpanda_cc_gtest(
name = "segment_offset_tracker_test",
timeout = "short",
Expand Down Expand Up @@ -461,3 +503,41 @@ redpanda_cc_gtest(
"@seastar",
],
)

redpanda_cc_btest(
name = "storage_e2e_single_thread",
timeout = "moderate",
srcs = [
"storage_e2e_test.cc",
],
cpu = 1,
deps = [
":common",
":disk_log_builder",
":disk_log_builder_fixture",
":log_gap_analysis",
":storage_test_fixture",
"//src/v/base",
"//src/v/bytes",
"//src/v/bytes:random",
"//src/v/compression",
"//src/v/config",
"//src/v/features",
"//src/v/finjector",
"//src/v/model",
"//src/v/model/tests:random",
"//src/v/random:generators",
"//src/v/reflection:adl",
"//src/v/storage",
"//src/v/storage:batch_cache",
"//src/v/storage:record_batch_builder",
"//src/v/storage:resources",
"//src/v/test_utils:random",
"//src/v/test_utils:seastar_boost",
"//src/v/utils:directory_walker",
"//src/v/utils:to_string",
"@boost//:test",
"@fmt",
"@seastar",
],
)
26 changes: 13 additions & 13 deletions src/v/storage/tests/storage_e2e_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ FIXTURE_TEST(test_truncation_with_write_caching, storage_test_fixture) {
const auto truncate_batch_ix = headers.size() - 2;
const auto truncate_offset = [&]() {
model::offset o{0};
for (auto i = 0; i < truncate_batch_ix; i++) {
for (size_t i = 0; i < truncate_batch_ix; i++) {
o += headers[i].record_count;
}
return o;
Expand Down Expand Up @@ -937,7 +937,7 @@ ss::future<storage::append_result> append_exactly(

val_sz -= real_batch_size;

for (int i = 0; i < batch_count; ++i) {
for (size_t i = 0; i < batch_count; ++i) {
storage::record_batch_builder builder(batch_type, model::offset{});
iobuf value = bytes_to_iobuf(random_generators::get_bytes(val_sz));
builder.add_raw_kv(key_buf.copy(), std::move(value));
Expand Down Expand Up @@ -1050,7 +1050,7 @@ FIXTURE_TEST(append_concurrent_with_prefix_truncate, storage_test_fixture) {
auto log = mgr.manage(std::move(ntp_cfg)).get0();

bool stop = false;
int cnt = 0;
size_t cnt = 0;
std::vector<model::record_batch_type> types{
model::record_batch_type::raft_data,
model::record_batch_type::raft_configuration};
Expand Down Expand Up @@ -2445,7 +2445,7 @@ FIXTURE_TEST(changing_cleanup_policy_back_and_forth, storage_test_fixture) {

// add a segment, some of the record keys in batches are random and some of
// them are the same to generate offset gaps after compaction
auto add_segment = [&log, disk_log](size_t size, model::term_id term) {
auto add_segment = [&log, disk_log](size_t size) {
do {
// 10 records per batch
for (int i = 0; i < 10; ++i) {
Expand Down Expand Up @@ -2481,11 +2481,11 @@ FIXTURE_TEST(changing_cleanup_policy_back_and_forth, storage_test_fixture) {
} while (disk_log->segments().back()->size_bytes() < size);
};
// add 2 log segments
add_segment(1_MiB, model::term_id(1));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused param

add_segment(1_MiB);
disk_log->force_roll(ss::default_priority_class()).get();
add_segment(1_MiB, model::term_id(1));
add_segment(1_MiB);
disk_log->force_roll(ss::default_priority_class()).get();
add_segment(1_MiB, model::term_id(1));
add_segment(1_MiB);
log->flush().get();

BOOST_REQUIRE_EQUAL(disk_log->segment_count(), 3);
Expand Down Expand Up @@ -3840,7 +3840,7 @@ FIXTURE_TEST(test_bytes_eviction_overrides, storage_test_fixture) {
auto deferred_rm = ss::defer(
[&mgr, ntp]() mutable { mgr.remove(ntp).get(); });

for (int i = 0; i < batch_cnt; ++i) {
for (size_t i = 0; i < batch_cnt; ++i) {
append_exactly(log, 1, batch_size).get();
}
auto disk_log = log;
Expand Down Expand Up @@ -4261,7 +4261,7 @@ FIXTURE_TEST(test_offset_range_size, storage_test_fixture) {
auto log = mgr.manage(std::move(ntp_cfg)).get();

model::offset first_segment_last_offset;
for (int i = 0; i < num_segments; i++) {
for (size_t i = 0; i < num_segments; i++) {
append_random_batches(
log,
10,
Expand Down Expand Up @@ -4374,7 +4374,7 @@ FIXTURE_TEST(test_offset_range_size2, storage_test_fixture) {
auto log = mgr.manage(std::move(ntp_cfg)).get();

model::offset first_segment_last_offset;
for (int i = 0; i < num_segments; i++) {
for (size_t i = 0; i < num_segments; i++) {
append_random_batches(
log,
10,
Expand Down Expand Up @@ -4578,7 +4578,7 @@ FIXTURE_TEST(test_offset_range_size_compacted, storage_test_fixture) {
auto log = mgr.manage(std::move(ntp_cfg)).get();

model::offset first_segment_last_offset;
for (int i = 0; i < num_segments; i++) {
for (size_t i = 0; i < num_segments; i++) {
append_random_batches(
log, 10, model::term_id(i), key_limited_random_batch_generator());
if (first_segment_last_offset == model::offset{}) {
Expand Down Expand Up @@ -4777,7 +4777,7 @@ FIXTURE_TEST(test_offset_range_size2_compacted, storage_test_fixture) {
auto log = mgr.manage(std::move(ntp_cfg)).get();

model::offset first_segment_last_offset;
for (int i = 0; i < num_segments; i++) {
for (size_t i = 0; i < num_segments; i++) {
append_random_batches(
log, 10, model::term_id(0), key_limited_random_batch_generator());
if (first_segment_last_offset == model::offset{}) {
Expand Down Expand Up @@ -5079,7 +5079,7 @@ FIXTURE_TEST(test_offset_range_size_incremental, storage_test_fixture) {
auto log = mgr.manage(std::move(ntp_cfg)).get();

model::offset first_segment_last_offset;
for (int i = 0; i < num_segments; i++) {
for (size_t i = 0; i < num_segments; i++) {
append_random_batches(
log,
10,
Expand Down
Loading