From b2f76273bd57de695cff25bc37f287293a1eb5f2 Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Mon, 24 Aug 2015 15:25:52 -0300 Subject: [PATCH] tests: check correctness of sstable ancestor metadata adding testcase for that purpose. Signed-off-by: Raphael S. Carvalho --- tests/sstable_datafile_test.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/sstable_datafile_test.cc b/tests/sstable_datafile_test.cc index 5f10c2143e..9b9d263e31 100644 --- a/tests/sstable_datafile_test.cc +++ b/tests/sstable_datafile_test.cc @@ -1457,3 +1457,27 @@ SEASTAR_TEST_CASE(datafile_generation_41) { }).then([sst, mt] {}); }); } + +SEASTAR_TEST_CASE(check_compaction_ancestor_metadata) { + // NOTE: generations 18 to 38 are used here. + + // check that ancestors list of compacted sstable is correct. + + return test_setup::do_with_test_directory([] { + return compact_sstables({ 42, 43, 44, 45 }, 46).then([] { + return open_sstable("tests/sstables/tests-temporary", 46).then([] (shared_sstable sst) { + std::set ancestors; + const compaction_metadata& cm = sst->get_compaction_metadata(); + for (auto& ancestor : cm.ancestors.elements) { + ancestors.insert(ancestor); + } + BOOST_REQUIRE(ancestors.find(42) != ancestors.end()); + BOOST_REQUIRE(ancestors.find(43) != ancestors.end()); + BOOST_REQUIRE(ancestors.find(44) != ancestors.end()); + BOOST_REQUIRE(ancestors.find(45) != ancestors.end()); + + return make_ready_future<>(); + }); + }); + }); +}