Merge " Support 64-bit gc_clock" (fixes) from Benny
" Use int64_t in data::cell for expiry / deletion time. Extend time_overflow unit tests in cql_query_test to use select statements with and without bypass cache to access deeper into the system. Refs #3353 " * 'projects/gc_clock_64_fixes/v1' of https://github.com/bhalevy/scylla: tests: extend time_overflow unit tests data::cell: use int64_t for expiry and deletion time
This commit is contained in:
@@ -162,7 +162,7 @@ struct cell {
|
||||
/// The cell value can be either a deletion time (if the cell is dead),
|
||||
/// a delta (counter update cell), fixed-size value or variable-sized value.
|
||||
using value_variant = imr::variant<tags::value,
|
||||
imr::member<tags::dead, imr::pod<int32_t>>,
|
||||
imr::member<tags::dead, imr::pod<int64_t>>,
|
||||
imr::member<tags::counter_update, imr::pod<int64_t>>,
|
||||
imr::member<tags::fixed_value, fixed_value>,
|
||||
imr::member<tags::variable_value, variable_value::structure>
|
||||
@@ -178,7 +178,7 @@ struct cell {
|
||||
imr::member<tags::timestamp, imr::pod<api::timestamp_type>>,
|
||||
imr::optional_member<tags::expiring, imr::structure<
|
||||
imr::member<tags::ttl, imr::pod<int32_t>>,
|
||||
imr::member<tags::expiry, imr::pod<int32_t>>
|
||||
imr::member<tags::expiry, imr::pod<int64_t>>
|
||||
>>,
|
||||
imr::member<tags::value, value_variant>
|
||||
>;
|
||||
@@ -382,7 +382,7 @@ public:
|
||||
.template serialize_as_nested<tags::atomic_cell>()
|
||||
.serialize(ts)
|
||||
.serialize_nested()
|
||||
.serialize(ttl.count())
|
||||
.serialize(gc_clock::as_int32(ttl))
|
||||
.serialize(expiry.time_since_epoch().count())
|
||||
.done();
|
||||
return [&] {
|
||||
|
||||
@@ -1153,24 +1153,60 @@ SEASTAR_TEST_CASE(test_writetime_and_ttl) {
|
||||
|
||||
SEASTAR_TEST_CASE(test_time_overflow_with_default_ttl) {
|
||||
return do_with_cql_env([] (cql_test_env& e) {
|
||||
auto verify = [&e] (int value, bool bypass_cache) -> future<> {
|
||||
auto sq = format("select i from cf where p1 = 'key1' {};", bypass_cache ? "bypass cache" : "");
|
||||
return e.execute_cql(sq).then([value] (shared_ptr<cql_transport::messages::result_message> msg) {
|
||||
assert_that(msg).is_rows()
|
||||
.with_size(1)
|
||||
.with_row({
|
||||
{int32_type->decompose(value)},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
auto cr = format("create table cf (p1 varchar primary key, i int) with default_time_to_live = {:d};", max_ttl.count());
|
||||
return e.execute_cql(cr).discard_result().then([&e] {
|
||||
auto q = format("insert into cf (p1, i) values ('key1', 1);");
|
||||
return e.execute_cql(q).discard_result();
|
||||
}).then([&e] {
|
||||
return e.require_column_has_value("cf", {sstring("key1")}, {}, "i", 1);
|
||||
}).then([&e, &verify] {
|
||||
return verify(1, false);
|
||||
}).then([&e, &verify] {
|
||||
return verify(1, true);
|
||||
}).then([&e] {
|
||||
return e.execute_cql("update cf set i = 2 where p1 = 'key1';").discard_result();
|
||||
}).then([&e, &verify] {
|
||||
return verify(2, true);
|
||||
}).then([&e, &verify] {
|
||||
return verify(2, false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(test_time_overflow_using_ttl) {
|
||||
return do_with_cql_env([] (cql_test_env& e) {
|
||||
auto verify = [&e] (int value, bool bypass_cache) -> future<> {
|
||||
auto sq = format("select i from cf where p1 = 'key1' {};", bypass_cache ? "bypass cache" : "");
|
||||
return e.execute_cql(sq).then([value] (shared_ptr<cql_transport::messages::result_message> msg) {
|
||||
assert_that(msg).is_rows()
|
||||
.with_size(1)
|
||||
.with_row({
|
||||
{int32_type->decompose(value)},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
auto cr = "create table cf (p1 varchar primary key, i int);";
|
||||
return e.execute_cql(cr).discard_result().then([&e] {
|
||||
auto q = format("insert into cf (p1, i) values ('key1', 1) using ttl {:d};", max_ttl.count());
|
||||
return e.execute_cql(q).discard_result();
|
||||
}).then([&e] {
|
||||
return e.require_column_has_value("cf", {sstring("key1")}, {}, "i", 1);
|
||||
}).then([&e, &verify] {
|
||||
return verify(1, true);
|
||||
}).then([&e, &verify] {
|
||||
return verify(1, false);
|
||||
}).then([&e] {
|
||||
auto q = format("insert into cf (p1, i) values ('key2', 0);");
|
||||
return e.execute_cql(q).discard_result();
|
||||
@@ -1179,6 +1215,10 @@ SEASTAR_TEST_CASE(test_time_overflow_using_ttl) {
|
||||
return e.execute_cql(q).discard_result();
|
||||
}).then([&e] {
|
||||
return e.require_column_has_value("cf", {sstring("key2")}, {}, "i", 2);
|
||||
}).then([&e, &verify] {
|
||||
return verify(1, false);
|
||||
}).then([&e, &verify] {
|
||||
return verify(1, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user