Files
scylladb/test/boost/schema_changes_test.cc
Avi Kivity fdc1449392 treewide: rename flat_mutation_reader_v2 to mutation_reader
flat_mutation_reader_v2 was introduced in a pair of commits in 2021:

  e3309322c3 "Clone flat_mutation_reader related classes into v2 variants"
  08b5773c12 "Adapt flat_mutation_reader_v2 to the new version of the API"

as a replacement for flat_mutation_reader, using range_tombstone_change
instead of range_tombstone to represent represent range tombstones. See
those commits for more information.

The transition was incremental; the last use of the original
flat_mutation_reader was removed in 2022 in commit

  026f8cc1e7 "db: Use mutation_partition_v2 in mvcc"

In turn, flat_mutation_reader was introduced in 2017 in commit

  748205ca75 "Introduce flat_mutation_reader"

To transition from a mutation_reader that nested rows within
a partition in a separate stream, to a flat reader that streamed
partitions and rows in the same stream.

Here, we reclaim the original name and rename the awkward
flat_mutation_reader_v2 to mutation_reader.

Note that mutation_fragment_v2 remains since we still use the original
for compatibilty, sometimes.

Some notes about the transition:

 - files were also renamed. In one case (flat_mutation_reader_test.cc), the
   rename target already existed, so we rename to
    mutation_reader_another_test.cc.

 - a namespace 'mutation_reader' with two definitions existed (in
   mutation_reader_fwd.hh). Its contents was folded into the mutation_reader
   class. As a result, a few #includes had to be adjusted.

Closes scylladb/scylladb#19356
2024-06-21 07:12:06 +03:00

82 lines
3.1 KiB
C++

/*
* Copyright (C) 2015-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include <boost/test/unit_test.hpp>
#include "test/lib/scylla_test_case.hh"
#include <seastar/testing/thread_test_case.hh>
#include <seastar/core/thread.hh>
#include "sstables/sstables.hh"
#include "test/lib/mutation_source_test.hh"
#include "test/lib/mutation_reader_assertions.hh"
#include "test/lib/sstable_utils.hh"
using namespace sstables;
using namespace std::chrono_literals;
constexpr std::array<sstable_version_types, 3> expected_writable_sstable_versions = {
sstable_version_types::mc,
sstable_version_types::md,
sstable_version_types::me,
};
// Add/remove test cases if writable_sstable_versions changes
static_assert(writable_sstable_versions.size() == expected_writable_sstable_versions.size(), "writable_sstable_versions changed");
static_assert(writable_sstable_versions[0] == expected_writable_sstable_versions[0], "writable_sstable_versions changed");
static_assert(writable_sstable_versions[1] == expected_writable_sstable_versions[1], "writable_sstable_versions changed");
static_assert(writable_sstable_versions[2] == expected_writable_sstable_versions[2], "writable_sstable_versions changed");
future <> test_schema_changes_int(sstable_version_types sstable_vtype) {
return sstables::test_env::do_with_async([] (sstables::test_env& env) {
std::map<schema_ptr, shared_sstable> cache;
for_each_schema_change([&] (schema_ptr base, const std::vector<mutation>& base_mutations,
schema_ptr changed, const std::vector<mutation>& changed_mutations) {
auto it = cache.find(base);
shared_sstable created_with_base_schema;
shared_sstable created_with_changed_schema;
if (it == cache.end()) {
created_with_base_schema = make_sstable_containing(env.make_sstable(base), base_mutations);
cache.emplace(base, created_with_base_schema);
} else {
created_with_base_schema = it->second;
}
created_with_changed_schema = env.reusable_sst(changed, created_with_base_schema).get();
const auto pr = dht::partition_range::make_open_ended_both_sides();
auto mr = assert_that(created_with_base_schema->as_mutation_source()
.make_reader_v2(changed, env.make_reader_permit(), pr, changed->full_slice()));
for (auto& m : changed_mutations) {
mr.produces(m);
}
mr.produces_end_of_stream();
mr = assert_that(created_with_changed_schema->as_mutation_source()
.make_reader_v2(changed, env.make_reader_permit(), pr, changed->full_slice()));
for (auto& m : changed_mutations) {
mr.produces(m);
}
mr.produces_end_of_stream();
});
});
}
SEASTAR_TEST_CASE(test_schema_changes_mc) {
return test_schema_changes_int(sstable_version_types::mc);
}
SEASTAR_TEST_CASE(test_schema_changes_md) {
return test_schema_changes_int(sstable_version_types::md);
}
SEASTAR_TEST_CASE(test_schema_changes_me) {
return test_schema_changes_int(sstable_version_types::me);
}