test: cql: Add test for results order with variable length keys

This commit is contained in:
Tomasz Grabiec
2015-03-26 10:21:03 +01:00
parent 2bc1c7b534
commit 283f52549b
2 changed files with 39 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
#include "cql3/query_options.hh"
#include "core/distributed.hh"
#include "tests/test-utils.hh"
#include "tests/urchin/cql_test_env.hh"
struct conversation_state {
service::storage_proxy proxy;
@@ -420,6 +421,34 @@ SEASTAR_TEST_CASE(test_range_queries) {
});
}
SEASTAR_TEST_CASE(test_ordering_of_composites_with_variable_length_components) {
return do_with_cql_env([] (auto& e) {
return e.create_table([](auto ks) {
return schema(ks, "cf",
{{"k", bytes_type}},
// We need more than one clustering column so that the single-element tuple format optimisation doesn't kick in
{{"c0", bytes_type}, {"c1", bytes_type}},
{{"v", bytes_type}},
{},
utf8_type);
}).then([&e] {
return e.execute_cql("update cf set v = 0x01 where k = 0x00 and c0 = 0x0001 and c1 = 0x00;").discard_result();
}).then([&e] {
return e.execute_cql("update cf set v = 0x02 where k = 0x00 and c0 = 0x03 and c1 = 0x00;").discard_result();
}).then([&e] {
return e.execute_cql("update cf set v = 0x03 where k = 0x00 and c0 = 0x035555 and c1 = 0x00;").discard_result();
}).then([&e] {
return e.execute_cql("update cf set v = 0x04 where k = 0x00 and c0 = 0x05 and c1 = 0x00;").discard_result();
}).then([&e] {
return e.execute_cql("select v from cf where k = 0x00 allow filtering;").then([](auto msg) {
assert_that(msg).is_rows().with_rows({
{from_hex("01")}, {from_hex("02")}, {from_hex("03")}, {from_hex("04")}
});
});
});
});
}
SEASTAR_TEST_CASE(test_map_insert_update) {
auto db = make_shared<distributed<database>>();
auto state = make_shared<conversation_state>(*db, ks_name);

View File

@@ -111,3 +111,13 @@ future<::shared_ptr<cql_test_env>> make_env_for_test() {
});
});
}
template <typename Func>
static inline
future<> do_with_cql_env(Func&& func) {
return make_env_for_test().then([func = std::forward<Func>(func)] (auto e) {
return func(*e).finally([e] {
return e->stop().finally([e] {});
});
});
}