Skip to content

Commit

Permalink
tests/mutation: add reproducer for scylladb#4567
Browse files Browse the repository at this point in the history
  • Loading branch information
pdziepak authored and syuu1228 committed Sep 15, 2020
1 parent ca6f223 commit 0b697e6
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/boost/mutation_test.cc
Expand Up @@ -3038,3 +3038,36 @@ SEASTAR_THREAD_TEST_CASE(test_compaction_data_stream_split) {
run_compaction_data_stream_split_test(schema, query_time, mutations);
}
}

// Reproducer for #4567: "appending_hash<row> ignores cells after first null"
SEASTAR_THREAD_TEST_CASE(test_appending_hash_row_4567) {
auto s = schema_builder("ks", "cf")
.with_column("pk", bytes_type, column_kind::partition_key)
.with_column("ck", bytes_type, column_kind::clustering_key)
.with_column("r1", bytes_type)
.with_column("r2", bytes_type)
.with_column("r3", bytes_type)
.build();

auto r1 = row();
r1.append_cell(0, atomic_cell::make_live(*bytes_type, 1, bytes{}));
r1.append_cell(2, atomic_cell::make_live(*bytes_type, 1, to_bytes("aaa")));

auto r2 = row();
r2.append_cell(0, atomic_cell::make_live(*bytes_type, 1, bytes{}));
r2.append_cell(2, atomic_cell::make_live(*bytes_type, 1, to_bytes("bbb")));

BOOST_CHECK(!r1.equal(column_kind::regular_column, *s, r2, *s));

auto compute_hash = [&] (const row& r, const query::column_id_vector& columns) {
auto hasher = xx_hasher{};
max_timestamp ts;
appending_hash<row>{}(hasher, r, *s, column_kind::regular_column, columns, ts);
return hasher.finalize_uint64();
};

BOOST_CHECK_EQUAL(compute_hash(r1, { 1 }), compute_hash(r2, { 1 }));
BOOST_CHECK_EQUAL(compute_hash(r1, { 0, 1 }), compute_hash(r2, { 0, 1 }));
BOOST_CHECK_NE(compute_hash(r1, { 0, 2 }), compute_hash(r2, { 0, 2 }));
BOOST_CHECK_NE(compute_hash(r1, { 0, 1, 2 }), compute_hash(r2, { 0, 1, 2 }));
}

0 comments on commit 0b697e6

Please sign in to comment.