tests: flat_reader_assertions::produces_compacted(): add query_time param
`produces_compacted()` is usually used in tandem of another compaction done on the expected output (`m` param). This is usually done so that even though the reader works with an uncompacted stream, when checking the checking of the result will not fail due to insignificant changes to the data, e.g. expired collection cells dropped while merging two collections. Currently, the two compactions, the one inside `produce_compacted()` and the one done by the caller uses two separate calls to `gc_clock::now()` to obtain the query time. This can lead to off-by-one errors in the two query times and subsequently artificial differences between the two compacted mutations, ultimately failing the test due to a false-positive. To prevent this allow callers to pass in a query time, the same they used to compact the input mutation (`m`). This solves another source of flakyness in unit tests using the mutation source test suite. Refs: #4695 Fixes: #4747 Signed-off-by: Botond Dénes <bdenes@scylladb.com> Message-Id: <20190726144032.3411-1-bdenes@scylladb.com>
This commit is contained in:
@@ -428,12 +428,13 @@ public:
|
||||
});
|
||||
}
|
||||
|
||||
flat_reader_assertions& produces_compacted(const mutation& m, const std::optional<query::clustering_row_ranges>& ck_ranges = {}) {
|
||||
flat_reader_assertions& produces_compacted(const mutation& m, gc_clock::time_point query_time,
|
||||
const std::optional<query::clustering_row_ranges>& ck_ranges = {}) {
|
||||
auto mo = read_mutation_from_flat_mutation_reader(_reader, db::no_timeout).get0();
|
||||
BOOST_REQUIRE(bool(mo));
|
||||
memory::disable_failure_guard dfg;
|
||||
mutation got = *mo;
|
||||
got.partition().compact_for_compaction(*m.schema(), always_gc, gc_clock::now());
|
||||
got.partition().compact_for_compaction(*m.schema(), always_gc, query_time);
|
||||
assert_that(got).is_equal_to(m, ck_ranges);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -965,11 +965,13 @@ static void test_range_queries(populate_fn populate) {
|
||||
void test_all_data_is_read_back(populate_fn populate) {
|
||||
BOOST_TEST_MESSAGE(__PRETTY_FUNCTION__);
|
||||
|
||||
for_each_mutation([&populate] (const mutation& m) mutable {
|
||||
const auto query_time = gc_clock::now();
|
||||
|
||||
for_each_mutation([&populate, query_time] (const mutation& m) mutable {
|
||||
auto ms = populate(m.schema(), {m});
|
||||
mutation copy(m);
|
||||
copy.partition().compact_for_compaction(*copy.schema(), always_gc, gc_clock::now());
|
||||
assert_that(ms.make_reader(m.schema())).produces_compacted(copy);
|
||||
copy.partition().compact_for_compaction(*copy.schema(), always_gc, query_time);
|
||||
assert_that(ms.make_reader(m.schema())).produces_compacted(copy, query_time);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2844,7 +2844,7 @@ SEASTAR_TEST_CASE(test_continuity_is_populated_when_read_overlaps_with_older_ver
|
||||
check_continuous(cache, pr, query::full_clustering_range);
|
||||
|
||||
assert_that(cache.make_reader(s.schema(), pr))
|
||||
.produces_compacted(m1 + m2 + m3 + m4)
|
||||
.produces_compacted(m1 + m2 + m3 + m4, gc_clock::now())
|
||||
.produces_end_of_stream();
|
||||
}
|
||||
});
|
||||
@@ -2927,14 +2927,14 @@ SEASTAR_TEST_CASE(test_continuity_population_with_multicolumn_clustering_key) {
|
||||
.produces_end_of_stream();
|
||||
|
||||
assert_that(cache.make_reader(s, pr))
|
||||
.produces_compacted(m1 + m2)
|
||||
.produces_compacted(m1 + m2, gc_clock::now())
|
||||
.produces_end_of_stream();
|
||||
|
||||
auto slice34 = partition_slice_builder(*s)
|
||||
.with_range(range_3_4)
|
||||
.build();
|
||||
assert_that(cache.make_reader(s, pr, slice34))
|
||||
.produces_compacted(m34)
|
||||
.produces_compacted(m34, gc_clock::now())
|
||||
.produces_end_of_stream();
|
||||
}
|
||||
});
|
||||
@@ -2979,7 +2979,7 @@ SEASTAR_TEST_CASE(test_continuity_is_populated_for_single_row_reads) {
|
||||
check_continuous(cache, pr, query::clustering_range::make_singular(s.make_ckey(7)));
|
||||
|
||||
assert_that(cache.make_reader(s.schema()))
|
||||
.produces_compacted(m1)
|
||||
.produces_compacted(m1, gc_clock::now())
|
||||
.produces_end_of_stream();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user