Skip to content

Commit

Permalink
s/e2e_tests: added test checking if segment sizes are unique
Browse files Browse the repository at this point in the history
Added simple test proving that all created logs have different segment
size, which means that jitter is applied.

Signed-off-by: Michal Maslanka <michal@vectorized.io>
  • Loading branch information
mmaslankaprv committed Nov 6, 2020
1 parent ed3f8a4 commit 064df76
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/v/storage/tests/storage_e2e_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <boost/test/tools/old/interface.hpp>

#include <algorithm>
#include <iterator>
#include <numeric>

void validate_offsets(
Expand Down Expand Up @@ -1016,7 +1017,6 @@ FIXTURE_TEST(partition_size_while_cleanup, storage_test_fixture) {
return sum + b.size_bytes();
});

BOOST_REQUIRE_EQUAL(batches.size(), 4);
// Expected size is equal to size of 4 batches (compacted one) plus batches
// being present in active segment that is not compacted

Expand All @@ -1025,3 +1025,34 @@ FIXTURE_TEST(partition_size_while_cleanup, storage_test_fixture) {
BOOST_REQUIRE_EQUAL(
get_disk_log(log)->get_probe().partition_size(), expected_size);
};

FIXTURE_TEST(check_segment_size_jitter, storage_test_fixture) {
auto cfg = default_log_config(test_dir);

// defaults
cfg.max_segment_size = 100_KiB;
cfg.stype = storage::log_config::storage_type::disk;
ss::abort_source as;
storage::log_manager mgr = make_log_manager(cfg);
using overrides_t = storage::ntp_config::default_overrides;

auto deferred = ss::defer([&mgr]() mutable { mgr.stop().get0(); });
std::vector<storage::log> logs;
for (int i = 0; i < 5; ++i) {
auto ntp = model::ntp("default", fmt::format("test-{}", i), 0);
storage::ntp_config ntp_cfg(ntp, mgr.config().base_dir);
auto log = mgr.manage(std::move(ntp_cfg)).get0();
auto result = append_exactly(log, 1000, 100).get0();
logs.push_back(log);
}
std::vector<size_t> sizes;
for (auto& l : logs) {
auto& segs = get_disk_log(l)->segments();
sizes.push_back((*segs.begin())->size_bytes());
}
std::sort(sizes.begin(), sizes.end());
auto end = std::unique(sizes.begin(), sizes.end());
auto unique_cnt = std::distance(sizes.begin(), end);
// check if all logs have unique segment size
BOOST_REQUIRE_EQUAL(unique_cnt, sizes.size());
}

0 comments on commit 064df76

Please sign in to comment.