From 79eedded35f64d1eb4001447ca362c6ff5b99b1c Mon Sep 17 00:00:00 2001 From: Alejo Sanchez Date: Thu, 29 Jun 2023 10:07:56 +0200 Subject: [PATCH] test/boost/database_test: split mutation sub-tests Split long-runing database mutation tests. At a trade-off with verbosity, split these sub-tests for the long running tests database_with_data_in_sstables_is_a_mutation_source_*. Refs #13905 Signed-off-by: Alejo Sanchez --- test/boost/database_test.cc | 68 ++++++++++++++-- test/lib/mutation_source_test.cc | 131 +++++++++++++++++++++++-------- test/lib/mutation_source_test.hh | 8 ++ 3 files changed, 168 insertions(+), 39 deletions(-) diff --git a/test/boost/database_test.cc b/test/boost/database_test.cc index b52b03a325..a4adf1793a 100644 --- a/test/boost/database_test.cc +++ b/test/boost/database_test.cc @@ -291,20 +291,72 @@ static void test_database(void (*run_tests)(populate_fn_ex, bool), unsigned cgs) }).get(); } -SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_plain_cg0) { - test_database(run_mutation_source_tests_plain, 0); +// plain cg0 +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_plain_basic_cg0) { + test_database(run_mutation_source_tests_plain_basic, 0); } -SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_plain_cg1) { - test_database(run_mutation_source_tests_plain, 1); +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_plain_reader_conversion_cg0) { + test_database(run_mutation_source_tests_plain_reader_conversion, 0); } -SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_reverse_cg0) { - test_database(run_mutation_source_tests_reverse, 0); +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_plain_fragments_monotonic_cg0) { + test_database(run_mutation_source_tests_plain_fragments_monotonic, 0); } -SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_reverse_cg1) { - test_database(run_mutation_source_tests_reverse, 1); +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_plain_read_back_cg0) { + test_database(run_mutation_source_tests_plain_read_back, 0); +} + +// plain cg1 +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_plain_basic_cg1) { + test_database(run_mutation_source_tests_plain_basic, 1); +} + +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_plain_reader_conversion_cg1) { + test_database(run_mutation_source_tests_plain_reader_conversion, 1); +} + +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_plain_fragments_monotonic_cg1) { + test_database(run_mutation_source_tests_plain_fragments_monotonic, 1); +} + +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_plain_read_back_cg1) { + test_database(run_mutation_source_tests_plain_read_back, 1); +} + +// reverse cg0 +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_reverse_basic_cg0) { + test_database(run_mutation_source_tests_reverse_basic, 0); +} + +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_reverse_reader_conversion_cg0) { + test_database(run_mutation_source_tests_reverse_reader_conversion, 0); +} + +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_reverse_fragments_monotonic_cg0) { + test_database(run_mutation_source_tests_reverse_fragments_monotonic, 0); +} + +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_reverse_read_back_cg0) { + test_database(run_mutation_source_tests_reverse_read_back, 0); +} + +// reverse cg1 +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_reverse_basic_cg1) { + test_database(run_mutation_source_tests_reverse_basic, 1); +} + +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_reverse_reader_conversion_cg1) { + test_database(run_mutation_source_tests_reverse_reader_conversion, 1); +} + +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_reverse_fragments_monotonic_cg1) { + test_database(run_mutation_source_tests_reverse_fragments_monotonic, 1); +} + +SEASTAR_THREAD_TEST_CASE(test_database_with_data_in_sstables_is_a_mutation_source_reverse_read_back_cg1) { + test_database(run_mutation_source_tests_reverse_read_back, 1); } static void require_exist(const sstring& filename, bool should) { diff --git a/test/lib/mutation_source_test.cc b/test/lib/mutation_source_test.cc index 8aad2a4cdf..41b99b0d15 100644 --- a/test/lib/mutation_source_test.cc +++ b/test/lib/mutation_source_test.cc @@ -1594,19 +1594,15 @@ void test_reader_conversions(tests::reader_concurrency_semaphore_wrapper& semaph void test_next_partition(tests::reader_concurrency_semaphore_wrapper&, populate_fn_ex); -void run_mutation_reader_tests(populate_fn_ex populate, bool with_partition_range_forwarding) { +void run_mutation_reader_tests_basic(tests::reader_concurrency_semaphore_wrapper& semaphore, + populate_fn_ex populate, bool with_partition_range_forwarding) { testlog.info(__PRETTY_FUNCTION__); - tests::reader_concurrency_semaphore_wrapper semaphore; - test_range_tombstones_v2(semaphore, populate); - test_reader_conversions(semaphore, populate); test_time_window_clustering_slicing(semaphore, populate); test_clustering_slices(semaphore, populate); - test_mutation_reader_fragments_have_monotonic_positions(semaphore, populate); test_streamed_mutation_forwarding_across_range_tombstones(semaphore, populate); test_streamed_mutation_forwarding_guarantees(semaphore, populate); - test_all_data_is_read_back(semaphore, populate); test_streamed_mutation_slicing_returns_only_relevant_tombstones(semaphore, populate); test_streamed_mutation_forwarding_is_consistent_with_slicing(semaphore, populate); test_range_queries(semaphore, populate); @@ -1622,6 +1618,18 @@ void run_mutation_reader_tests(populate_fn_ex populate, bool with_partition_rang } } +void run_mutation_reader_tests_all(populate_fn_ex populate, bool with_partition_range_forwarding) { + testlog.info(__PRETTY_FUNCTION__); + + tests::reader_concurrency_semaphore_wrapper semaphore; + run_mutation_reader_tests_basic(semaphore, populate, with_partition_range_forwarding); + + // Most of the time is spent in the following tests + test_reader_conversions(semaphore, populate); + test_mutation_reader_fragments_have_monotonic_positions(semaphore, populate); + test_all_data_is_read_back(semaphore, populate); +} + void test_next_partition(tests::reader_concurrency_semaphore_wrapper& semaphore, populate_fn_ex populate) { testlog.info(__PRETTY_FUNCTION__); @@ -1673,38 +1681,99 @@ void run_mutation_source_tests(populate_fn_ex populate, bool with_partition_rang void run_mutation_source_tests_plain(populate_fn_ex populate, bool with_partition_range_forwarding) { testlog.info(__PRETTY_FUNCTION__); - run_mutation_reader_tests(populate, with_partition_range_forwarding); + run_mutation_reader_tests_all(populate, with_partition_range_forwarding); +} + +void run_mutation_source_tests_plain_basic(populate_fn_ex populate, bool with_partition_range_forwarding) { + testlog.info(__PRETTY_FUNCTION__); + tests::reader_concurrency_semaphore_wrapper semaphore; + run_mutation_reader_tests_basic(semaphore, populate, with_partition_range_forwarding); +} + +void run_mutation_source_tests_plain_reader_conversion(populate_fn_ex populate, bool with_partition_range_forwarding) { + testlog.info(__PRETTY_FUNCTION__); + tests::reader_concurrency_semaphore_wrapper semaphore; + test_reader_conversions(semaphore, populate); +} + +void run_mutation_source_tests_plain_fragments_monotonic(populate_fn_ex populate, bool with_partition_range_forwarding) { + testlog.info(__PRETTY_FUNCTION__); + tests::reader_concurrency_semaphore_wrapper semaphore; + test_mutation_reader_fragments_have_monotonic_positions(semaphore, populate); +} + +void run_mutation_source_tests_plain_read_back(populate_fn_ex populate, bool with_partition_range_forwarding) { + testlog.info(__PRETTY_FUNCTION__); + tests::reader_concurrency_semaphore_wrapper semaphore; + test_all_data_is_read_back(semaphore, populate); +} + +// read in reverse +static mutation_source make_mutation_source(populate_fn_ex populate, schema_ptr s, + const std::vector& m, gc_clock::time_point t) { + auto table_schema = s->make_reversed(); + + std::vector reversed_mutations; + reversed_mutations.reserve(m.size()); + for (const auto& mut : m) { + reversed_mutations.emplace_back(reverse(mut)); + } + auto ms = populate(table_schema, reversed_mutations, t); + + return mutation_source([table_schema, ms = std::move(ms), reversed_slices = std::list()] ( + schema_ptr query_schema, + reader_permit permit, + const dht::partition_range& pr, + const query::partition_slice& slice, + tracing::trace_state_ptr tr, + streamed_mutation::forwarding fwd, + mutation_reader::forwarding mr_fwd) mutable { + reversed_slices.emplace_back(partition_slice_builder(*table_schema, query::native_reverse_slice_to_legacy_reverse_slice(*table_schema, slice)) + .with_option() + .build()); + return ms.make_reader_v2(query_schema, std::move(permit), pr, reversed_slices.back(), tr, fwd, mr_fwd); + }); } void run_mutation_source_tests_reverse(populate_fn_ex populate, bool with_partition_range_forwarding) { testlog.info(__PRETTY_FUNCTION__); - // read in reverse - run_mutation_reader_tests([populate] (schema_ptr s, const std::vector& m, gc_clock::time_point t) -> mutation_source { - auto table_schema = s->make_reversed(); - - std::vector reversed_mutations; - reversed_mutations.reserve(m.size()); - for (const auto& mut : m) { - reversed_mutations.emplace_back(reverse(mut)); - } - auto ms = populate(table_schema, reversed_mutations, t); - - return mutation_source([table_schema, ms = std::move(ms), reversed_slices = std::list()] ( - schema_ptr query_schema, - reader_permit permit, - const dht::partition_range& pr, - const query::partition_slice& slice, - tracing::trace_state_ptr tr, - streamed_mutation::forwarding fwd, - mutation_reader::forwarding mr_fwd) mutable { - reversed_slices.emplace_back(partition_slice_builder(*table_schema, query::native_reverse_slice_to_legacy_reverse_slice(*table_schema, slice)) - .with_option() - .build()); - return ms.make_reader_v2(query_schema, std::move(permit), pr, reversed_slices.back(), tr, fwd, mr_fwd); - }); + run_mutation_reader_tests_all([&populate] (schema_ptr s, const std::vector& m, gc_clock::time_point t) -> mutation_source { + return make_mutation_source(populate, s, m, t); }, false); // FIXME: pass with_partition_range_forwarding after all natively reversing sources have fast-forwarding support } +void run_mutation_source_tests_reverse_basic(populate_fn_ex populate, bool with_partition_range_forwarding) { + testlog.info(__PRETTY_FUNCTION__); + tests::reader_concurrency_semaphore_wrapper semaphore; + run_mutation_reader_tests_basic(semaphore, [&populate] (schema_ptr s, const std::vector& m, gc_clock::time_point t) -> mutation_source { + return make_mutation_source(populate, s, m, t); + }, false); // FIXME: pass with_partition_range_forwarding after all natively reversing sources have fast-forwarding support +} + +void run_mutation_source_tests_reverse_reader_conversion(populate_fn_ex populate, bool with_partition_range_forwarding) { + testlog.info(__PRETTY_FUNCTION__); + tests::reader_concurrency_semaphore_wrapper semaphore; + test_reader_conversions(semaphore, [&populate] (schema_ptr s, const std::vector& m, gc_clock::time_point t) -> mutation_source { + return make_mutation_source(populate, s, m, t); + }); +} + +void run_mutation_source_tests_reverse_fragments_monotonic(populate_fn_ex populate, bool with_partition_range_forwarding) { + testlog.info(__PRETTY_FUNCTION__); + tests::reader_concurrency_semaphore_wrapper semaphore; + test_mutation_reader_fragments_have_monotonic_positions(semaphore, [&populate] (schema_ptr s, const std::vector& m, gc_clock::time_point t) -> mutation_source { + return make_mutation_source(populate, s, m, t); + }); +} + +void run_mutation_source_tests_reverse_read_back(populate_fn_ex populate, bool with_partition_range_forwarding) { + testlog.info(__PRETTY_FUNCTION__); + tests::reader_concurrency_semaphore_wrapper semaphore; + test_all_data_is_read_back(semaphore, [&populate] (schema_ptr s, const std::vector& m, gc_clock::time_point t) -> mutation_source { + return make_mutation_source(populate, s, m, t); + }); +} + struct mutation_sets { std::vector> equal; std::vector> unequal; diff --git a/test/lib/mutation_source_test.hh b/test/lib/mutation_source_test.hh index 41003c70ae..30a63024b8 100644 --- a/test/lib/mutation_source_test.hh +++ b/test/lib/mutation_source_test.hh @@ -18,7 +18,15 @@ using populate_fn_ex = std::function