From cc89acff67a5ce72bad190e2b397f9b02d5310c5 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 2 Nov 2023 17:46:06 +0300 Subject: [PATCH] sstable_conforms_to_mutation_source_test: Open-code the make_sstable() helper This test case is pretty special in the sense that it uses custom path for tempdir to create, write and load sstable to/from. It's better to open-code the make_sstable() helper into the test case rather than encourage callers to use custom tempdirs. "Good" test cases can use make_sstable_easy() for the same purposes (in fact they alredy do). Signed-off-by: Pavel Emelyanov --- .../boost/sstable_conforms_to_mutation_source_test.cc | 7 ++++++- test/lib/sstable_utils.cc | 11 ----------- test/lib/sstable_utils.hh | 3 --- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/test/boost/sstable_conforms_to_mutation_source_test.cc b/test/boost/sstable_conforms_to_mutation_source_test.cc index a3fd81ac6f..0be8006d82 100644 --- a/test/boost/sstable_conforms_to_mutation_source_test.cc +++ b/test/boost/sstable_conforms_to_mutation_source_test.cc @@ -28,7 +28,12 @@ using namespace std::chrono_literals; static mutation_source make_sstable_mutation_source(sstables::test_env& env, schema_ptr s, sstring dir, std::vector mutations, sstable_writer_config cfg, sstables::sstable::version_types version, gc_clock::time_point query_time = gc_clock::now()) { - return make_sstable(env, s, dir, std::move(mutations), cfg, version, query_time)->as_mutation_source(); + auto sst = env.make_sstable(s, dir, env.new_generation(), version, sstable_format_types::big, default_sstable_buffer_size, query_time); + auto mt = make_memtable(s, mutations); + auto mr = mt->make_flat_reader(s, env.make_reader_permit()); + sst->write_components(std::move(mr), mutations.size(), s, cfg, mt->get_encoding_stats()).get(); + sst->load(s->get_sharder()).get(); + return sst->as_mutation_source(); } static void consume_all(flat_mutation_reader_v2& rd) { diff --git a/test/lib/sstable_utils.cc b/test/lib/sstable_utils.cc index e3db6c4f71..3970c22eba 100644 --- a/test/lib/sstable_utils.cc +++ b/test/lib/sstable_utils.cc @@ -85,17 +85,6 @@ sstables::shared_sstable make_sstable_containing(sstables::shared_sstable sst, s return sst; } -shared_sstable make_sstable(sstables::test_env& env, schema_ptr s, sstring dir, std::vector mutations, - sstable_writer_config cfg, sstables::sstable::version_types version, gc_clock::time_point query_time) { - fs::path dir_path(dir); - auto mt = make_memtable(s, mutations); - auto sst = env.make_sstable(s, dir_path.string(), env.new_generation(), version, sstable_format_types::big, default_sstable_buffer_size, query_time); - auto mr = mt->make_flat_reader(s, env.make_reader_permit()); - sst->write_components(std::move(mr), mutations.size(), s, cfg, mt->get_encoding_stats()).get(); - sst->load(s->get_sharder()).get(); - return sst; -} - shared_sstable make_sstable_easy(test_env& env, flat_mutation_reader_v2 rd, sstable_writer_config cfg, sstables::generation_type gen, const sstables::sstable::version_types version, int expected_partition, gc_clock::time_point query_time) { auto s = rd.schema(); diff --git a/test/lib/sstable_utils.hh b/test/lib/sstable_utils.hh index 43ba970291..f1b2cd687a 100644 --- a/test/lib/sstable_utils.hh +++ b/test/lib/sstable_utils.hh @@ -38,9 +38,6 @@ inline future<> write_memtable_to_sstable_for_test(replica::memtable& mt, sstabl return write_memtable_to_sstable(mt, sst, sst->manager().configure_writer("memtable")); } -shared_sstable make_sstable(sstables::test_env& env, schema_ptr s, sstring dir, std::vector mutations, - sstable_writer_config cfg, sstables::sstable::version_types version, gc_clock::time_point query_time = gc_clock::now()); - namespace sstables { using sstable_ptr = shared_sstable;