cql_query_test: handle bounce_to_shard msg in test_null_value_tuple_floating_types_and_uuids

Use `prepared_on_shard` helper function to handle `bounce_to_shard`
messages that can happen when using LWT statements.

Fixes: #7757
Tests: unit(dev)

Signed-off-by: Pavel Solodovnikov <pa.solodovnikov@scylladb.com>
Message-Id: <20201204172944.601730-1-pa.solodovnikov@scylladb.com>
This commit is contained in:
Pavel Solodovnikov
2020-12-04 20:29:44 +03:00
committed by Avi Kivity
parent 6b1659ee80
commit 56c0fcfcb2

View File

@@ -4411,32 +4411,6 @@ SEASTAR_TEST_CASE(test_views_with_future_tombstones) {
});
}
SEASTAR_TEST_CASE(test_null_value_tuple_floating_types_and_uuids) {
return do_with_cql_env_thread([] (cql_test_env& e) {
auto test_for_single_type = [&e] (const shared_ptr<const abstract_type>& type, auto update_value) {
cquery_nofail(e, format("CREATE TABLE IF NOT EXISTS t (k int PRIMARY KEY, test {})", type->cql3_type_name()));
cquery_nofail(e, "INSERT INTO t (k, test) VALUES (0, null)");
auto stmt = e.prepare(format("UPDATE t SET test={} WHERE k=0 IF test IN ?", update_value)).get0();
auto list_type = list_type_impl::get_instance(type, true);
// decomposed (null) value
auto arg_value = list_type->decompose(
make_list_value(list_type, {data_value::make_null(type)}));
require_rows(e, stmt,
{cql3::raw_value::make_value(std::move(arg_value))},
{{boolean_type->decompose(true), std::nullopt}});
cquery_nofail(e, "DROP TABLE t");
};
test_for_single_type(double_type, 1.0);
test_for_single_type(float_type, 1.0f);
test_for_single_type(uuid_type, utils::make_random_uuid());
test_for_single_type(timeuuid_type, utils::UUID("00000000-0000-1000-0000-000000000000"));
});
}
static std::unique_ptr<cql3::query_options> q_serial_opts(
std::vector<cql3::raw_value> values,
db::consistency_level cl) {
@@ -4487,6 +4461,31 @@ static void prepared_on_shard(cql_test_env& e, const sstring& query,
}
}
SEASTAR_TEST_CASE(test_null_value_tuple_floating_types_and_uuids) {
return do_with_cql_env_thread([] (cql_test_env& e) {
auto test_for_single_type = [&e] (const shared_ptr<const abstract_type>& type, auto update_value) {
cquery_nofail(e, format("CREATE TABLE IF NOT EXISTS t (k int PRIMARY KEY, test {})", type->cql3_type_name()));
cquery_nofail(e, "INSERT INTO t (k, test) VALUES (0, null)");
auto list_type = list_type_impl::get_instance(type, true);
// decomposed (null) value
auto arg_value = list_type->decompose(
make_list_value(list_type, {data_value::make_null(type)}));
prepared_on_shard(e, format("UPDATE t SET test={} WHERE k=0 IF test IN ?", update_value),
{std::move(arg_value)},
{{boolean_type->decompose(true), std::nullopt}});
cquery_nofail(e, "DROP TABLE t");
};
test_for_single_type(double_type, 1.0);
test_for_single_type(float_type, 1.0f);
test_for_single_type(uuid_type, utils::make_random_uuid());
test_for_single_type(timeuuid_type, utils::UUID("00000000-0000-1000-0000-000000000000"));
});
}
SEASTAR_TEST_CASE(test_like_parameter_marker) {
return do_with_cql_env_thread([] (cql_test_env& e) {
cquery_nofail(e, "CREATE TABLE t (pk int PRIMARY KEY, col text)");