From 95c8da827646e70d3773eca6fdf12be4a0282ce8 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Wed, 17 Jun 2015 07:26:47 -0400 Subject: [PATCH] tests: test corner case for summary creation We have recently had a bug where we were messing up with the summary generation in certain corner cases. In particular, when the number of keys was an exact multiple of the sampling rate. Add a test case to make sure we never regress on this. Signed-off-by: Glauber Costa --- tests/urchin/sstable_datafile_test.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/urchin/sstable_datafile_test.cc b/tests/urchin/sstable_datafile_test.cc index e0b31cf707..eac5ca50d1 100644 --- a/tests/urchin/sstable_datafile_test.cc +++ b/tests/urchin/sstable_datafile_test.cc @@ -923,3 +923,29 @@ SEASTAR_TEST_CASE(datafile_generation_13) { }).then([sst, mtp] {}); }); } + +SEASTAR_TEST_CASE(datafile_generation_14) { + return test_setup::do_with_test_directory([] { + auto s = uncompressed_schema(); + + auto mtp = make_shared(s); + // Create a number of keys that is a multiple of the sampling level + for (int i = 0; i < 0x80; ++i) { + sstring k = "key" + to_sstring(i); + auto key = partition_key::from_exploded(*s, {to_bytes(k)}); + mutation m(key, s); + + auto c_key = clustering_key::make_empty(*s); + m.set_clustered_cell(c_key, to_bytes("col2"), boost::any(i), api::max_timestamp); + mtp->apply(std::move(m)); + } + + auto sst = make_lw_shared("tests/urchin/sstables/tests-temporary", 14, la, big); + return sst->write_components(*mtp).then([s] { + return reusable_sst("tests/urchin/sstables/tests-temporary", 14).then([] (auto s) { + // Not crashing is enough + return make_ready_future<>(); + }); + }).then([sst, mtp] {}); + }); +}