From 9c8cf9f51d0452254d09ed33f1caeb79555bc833 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 27 Oct 2019 19:47:43 +0200 Subject: [PATCH 1/3] mutation_test: test_udt_mutations: fixup udt comment Signed-off-by: Benny Halevy --- tests/mutation_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mutation_test.cc b/tests/mutation_test.cc index 4989ebb3bf..19f03bdd97 100644 --- a/tests/mutation_test.cc +++ b/tests/mutation_test.cc @@ -323,7 +323,7 @@ SEASTAR_TEST_CASE(test_list_mutations) { } SEASTAR_THREAD_TEST_CASE(test_udt_mutations) { - // (a int, b text, c long) + // (a int, b text, c long, d text) auto ut = user_type_impl::get_instance("ks", to_bytes("ut"), {to_bytes("a"), to_bytes("b"), to_bytes("c"), to_bytes("d")}, {int32_type, utf8_type, long_type, utf8_type}, From fec772538c6d8b173e320195e22fe8766a85dff1 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 27 Oct 2019 19:49:25 +0200 Subject: [PATCH 2/3] mutation_test: test_udt_mutations: fix end iterator in call to std::all_of Signed-off-by: Benny Halevy --- tests/mutation_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mutation_test.cc b/tests/mutation_test.cc index 19f03bdd97..87f6bc94d3 100644 --- a/tests/mutation_test.cc +++ b/tests/mutation_test.cc @@ -361,7 +361,7 @@ SEASTAR_THREAD_TEST_CASE(test_udt_mutations) { i->as_collection_mutation().with_deserialized(*ut, [&] (collection_mutation_view_description m) { // one cell for each field that has been set. mut3 and mut1 should have been merged BOOST_REQUIRE(m.cells.size() == 3); - BOOST_REQUIRE(std::all_of(m.cells.begin(), m.cells.begin(), [] (const auto& c) { return c.second.is_live(); })); + BOOST_REQUIRE(std::all_of(m.cells.begin(), m.cells.end(), [] (const auto& c) { return c.second.is_live(); })); auto cells_equal = [] (const auto& c1, const auto& c2) { return c1.first == c2.first && c1.second.value().linearize() == c2.second.value().linearize(); From 1895fb276ea196a8d3e6e7cb093f597f1dd6fe68 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 27 Oct 2019 20:22:18 +0200 Subject: [PATCH 3/3] mutation_test: test_udt_mutations: use int64_t constants for long_type Otherwise they are decomposed and serialized as 4-byte int32. For example, on my machine cell[1] looked like this: {0002, atomic_cell{0000000310600000;ts=0;expiry=-1,ttl=0}} and it failed cells_equal against: {0002, atomic_cell{0000000300000000;ts=0;expiry=-1,ttl=0}} Signed-off-by: Benny Halevy --- tests/mutation_test.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/mutation_test.cc b/tests/mutation_test.cc index 87f6bc94d3..33e05aa532 100644 --- a/tests/mutation_test.cc +++ b/tests/mutation_test.cc @@ -337,7 +337,7 @@ SEASTAR_THREAD_TEST_CASE(test_udt_mutations) { // {a: 0, c: 2} auto mut1 = make_collection_mutation({}, serialize_field_index(0), make_collection_member(int32_type, 0), - serialize_field_index(2), make_collection_member(long_type, 2)); + serialize_field_index(2), make_collection_member(long_type, int64_t(2))); mutation m1(s, key); m1.set_static_cell(column, mut1.serialize(*ut)); mt->apply(m1); @@ -349,7 +349,7 @@ SEASTAR_THREAD_TEST_CASE(test_udt_mutations) { mt->apply(m2); // {c: 3} - auto mut3 = make_collection_mutation({}, serialize_field_index(2), make_collection_member(long_type, 3)); + auto mut3 = make_collection_mutation({}, serialize_field_index(2), make_collection_member(long_type, int64_t(3))); mutation m3(s, key); m3.set_static_cell(column, mut3.serialize(*ut)); mt->apply(m3); @@ -370,7 +370,7 @@ SEASTAR_THREAD_TEST_CASE(test_udt_mutations) { auto cell_a = std::make_pair(serialize_field_index(0), make_collection_member(int32_type, 0)); BOOST_REQUIRE(cells_equal(m.cells[0], std::pair(cell_a.first, cell_a.second))); - auto cell_c = std::make_pair(serialize_field_index(2), make_collection_member(long_type, 3)); + auto cell_c = std::make_pair(serialize_field_index(2), make_collection_member(long_type, int64_t(3))); BOOST_REQUIRE(cells_equal(m.cells[1], std::pair(cell_c.first, cell_c.second))); auto cell_d = std::make_pair(serialize_field_index(3), make_collection_member(utf8_type, "text"));