test: cql_query_test: add test_clustering_filtering unit tests
Add unit tests reproducing https://github.com/scylladb/scylla/issues/3552 with clustering-key filtering enabled. enable_sstables_md_format option is set to true as clustering-key filtering is enabled only for md-format sstables. Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
@@ -4653,3 +4653,84 @@ SEASTAR_THREAD_TEST_CASE(test_query_limit) {
|
||||
}
|
||||
}, std::move(cfg)).get();
|
||||
}
|
||||
|
||||
// reproduces https://github.com/scylladb/scylla/issues/3552
|
||||
// when clustering-key filtering is enabled in filter_sstable_for_reader
|
||||
static future<> test_clustering_filtering_with_compaction_strategy(const std::string_view& cs) {
|
||||
auto db_config = make_shared<db::config>();
|
||||
db_config->enable_sstables_md_format.set(true);
|
||||
|
||||
return do_with_cql_env_thread([&cs] (cql_test_env& e) {
|
||||
cquery_nofail(e, format("CREATE TABLE cf(pk text, ck int, v text, PRIMARY KEY(pk, ck)) WITH COMPACTION = {{'class': '{}'}}", cs));
|
||||
cquery_nofail(e, "INSERT INTO cf(pk, ck, v) VALUES ('a', 1, 'a1')");
|
||||
e.db().invoke_on_all([] (database& db) { return db.flush_all_memtables(); }).get();
|
||||
e.db().invoke_on_all([] (database& db) { db.row_cache_tracker().clear(); }).get();
|
||||
require_rows(e, "SELECT v FROM cf WHERE pk='a' AND ck=0 ALLOW FILTERING", {});
|
||||
require_rows(e, "SELECT v FROM cf", {{T("a1")}});
|
||||
}, cql_test_config(db_config));
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(test_clustering_filtering) {
|
||||
static std::array<std::string_view, 2> test_compaction_strategies = {
|
||||
"SizeTieredCompactionStrategy",
|
||||
"TimeWindowCompactionStrategy",
|
||||
};
|
||||
|
||||
return do_for_each(test_compaction_strategies,
|
||||
test_clustering_filtering_with_compaction_strategy);
|
||||
}
|
||||
|
||||
static future<> test_clustering_filtering_2_with_compaction_strategy(const std::string_view& cs) {
|
||||
auto db_config = make_shared<db::config>();
|
||||
db_config->enable_sstables_md_format.set(true);
|
||||
|
||||
return do_with_cql_env_thread([&cs] (cql_test_env& e) {
|
||||
cquery_nofail(e, format("CREATE TABLE cf(pk text, ck int, v text, PRIMARY KEY(pk, ck)) WITH COMPACTION = {{'class': '{}'}}", cs));
|
||||
cquery_nofail(e, "INSERT INTO cf(pk, ck, v) VALUES ('a', 1, 'a1')");
|
||||
cquery_nofail(e, "INSERT INTO cf(pk, ck, v) VALUES ('b', 2, 'b2')");
|
||||
e.db().invoke_on_all([] (database& db) { return db.flush_all_memtables(); }).get();
|
||||
e.db().invoke_on_all([] (database& db) { db.row_cache_tracker().clear(); }).get();
|
||||
require_rows(e, "SELECT v FROM cf WHERE pk='a' AND ck=0 ALLOW FILTERING", {});
|
||||
require_rows(e, "SELECT v FROM cf", {{T("a1")}, {T("b2")}});
|
||||
}, cql_test_config(db_config));
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(test_clustering_filtering_2) {
|
||||
static std::array<std::string_view, 2> test_compaction_strategies = {
|
||||
"SizeTieredCompactionStrategy",
|
||||
"TimeWindowCompactionStrategy",
|
||||
};
|
||||
|
||||
return do_for_each(test_compaction_strategies,
|
||||
test_clustering_filtering_2_with_compaction_strategy);
|
||||
}
|
||||
|
||||
static future<> test_clustering_filtering_3_with_compaction_strategy(const std::string_view& cs) {
|
||||
auto db_config = make_shared<db::config>();
|
||||
db_config->enable_sstables_md_format.set(true);
|
||||
|
||||
return do_with_cql_env_thread([&cs] (cql_test_env& e) {
|
||||
cquery_nofail(e, format("CREATE TABLE cf(pk text, ck int, v text, PRIMARY KEY(pk, ck)) WITH COMPACTION = {{'class': '{}'}}", cs));
|
||||
e.db().invoke_on_all([] (database& db) {
|
||||
auto& table = db.find_column_family("ks", "cf");
|
||||
table.disable_auto_compaction();
|
||||
}).get();
|
||||
cquery_nofail(e, "INSERT INTO cf(pk, ck, v) VALUES ('a', 1, 'a1')");
|
||||
e.db().invoke_on_all([] (database& db) { return db.flush_all_memtables(); }).get();
|
||||
cquery_nofail(e, "INSERT INTO cf(pk, ck, v) VALUES ('b', 0, 'b0')");
|
||||
e.db().invoke_on_all([] (database& db) { return db.flush_all_memtables(); }).get();
|
||||
e.db().invoke_on_all([] (database& db) { db.row_cache_tracker().clear(); }).get();
|
||||
require_rows(e, "SELECT v FROM cf WHERE pk='a' AND ck=0 ALLOW FILTERING", {});
|
||||
require_rows(e, "SELECT v FROM cf", {{T("a1")}, {T("b0")}});
|
||||
}, cql_test_config(db_config));
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(test_clustering_filtering_3) {
|
||||
static std::array<std::string_view, 2> test_compaction_strategies = {
|
||||
"SizeTieredCompactionStrategy",
|
||||
"TimeWindowCompactionStrategy",
|
||||
};
|
||||
|
||||
return do_for_each(test_compaction_strategies,
|
||||
test_clustering_filtering_3_with_compaction_strategy);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user