test: use NetworkTopologyStrategy in all unit tests
As described in https://github.com/scylladb/scylladb/issues/8638, we're moving away from `SimpleStrategy`, in the future it will become deprecated. We should remove all uses of it and replace them with `NetworkTopologyStrategy`. This change replaces `SimpleStrategy` with `NetworkTopologyStrategy` in all unit tests, or at least in the ones where it was reasonable to do so. Some of the tests were written explicitly to test the `SimpleStrategy` strategy, or changing the keyspace from `SimpleStrategy` to `NetworkTopologyStrategy`. These tests were left intact. It's still a feature that is supported, even if it's slowly getting deprecated. The typical way to use `NetworkTopologyStrategy` is to specify a replication factor for each datacenter. This could be a bit cumbersome, we would have to fetch the list of datacenters, set the repfactors, etc. Luckily there is another way - we can just specify a replication factor to use for or each existing datacenter, like this: ```cql CREATE KEYSPACE {} WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}; ``` This makes the change rather straightforward - just replace all instances of `'SimpleStrategy'', with `'NetworkTopologyStrategy'`. Refs: https://github.com/scylladb/scylladb/issues/8638 Signed-off-by: Jan Ciolek <jan.ciolek@scylladb.com> Closes #13990
This commit is contained in:
@@ -299,7 +299,7 @@ SEASTAR_TEST_CASE(create_keyspace_default_permissions) {
|
||||
env,
|
||||
alice,
|
||||
"GRANT CREATE ON ALL KEYSPACES TO alice",
|
||||
"CREATE KEYSPACE armies WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 1 }",
|
||||
"CREATE KEYSPACE armies WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', 'replication_factor': 1 }",
|
||||
auth::make_data_resource("armies"));
|
||||
}, db_config_with_auth());
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ using namespace std::literals::chrono_literals;
|
||||
|
||||
SEASTAR_TEST_CASE(test_create_keyspace_statement) {
|
||||
return do_with_cql_env([] (cql_test_env& e) {
|
||||
return e.execute_cql("create keyspace ks2 with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").discard_result().then([&e] {
|
||||
return e.execute_cql("create keyspace ks2 with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").discard_result().then([&e] {
|
||||
return e.require_keyspace_exists("ks2");
|
||||
});
|
||||
});
|
||||
@@ -1790,19 +1790,19 @@ SEASTAR_TEST_CASE(test_select_multiple_ranges) {
|
||||
SEASTAR_TEST_CASE(test_validate_keyspace) {
|
||||
return do_with_cql_env([] (cql_test_env& e) {
|
||||
return make_ready_future<>().then([&e] {
|
||||
return e.execute_cql("create keyspace kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkssssssssssssssssssssssssssssssssssssssssssssss with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
|
||||
return e.execute_cql("create keyspace kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkssssssssssssssssssssssssssssssssssssssssssssss with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };");
|
||||
}).then_wrapped([&e] (future<shared_ptr<cql_transport::messages::result_message>> f) {
|
||||
assert_that_failed(f);
|
||||
return e.execute_cql("create keyspace ks3-1 with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
|
||||
return e.execute_cql("create keyspace ks3-1 with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };");
|
||||
}).then_wrapped([&e] (future<shared_ptr<cql_transport::messages::result_message>> f) {
|
||||
assert_that_failed(f);
|
||||
return e.execute_cql("create keyspace ks3 with replication = { 'replication_factor' : 1 };");
|
||||
}).then_wrapped([&e] (future<shared_ptr<cql_transport::messages::result_message>> f) {
|
||||
assert_that_failed(f);
|
||||
return e.execute_cql("create keyspace ks3 with rreplication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
|
||||
return e.execute_cql("create keyspace ks3 with rreplication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };");
|
||||
}).then_wrapped([&e] (future<shared_ptr<cql_transport::messages::result_message>> f) {
|
||||
assert_that_failed(f);
|
||||
return e.execute_cql("create keyspace SyStEm with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
|
||||
return e.execute_cql("create keyspace SyStEm with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };");
|
||||
}).then_wrapped([] (future<shared_ptr<cql_transport::messages::result_message>> f) {
|
||||
assert_that_failed(f);
|
||||
});
|
||||
@@ -3202,7 +3202,7 @@ SEASTAR_TEST_CASE(test_time_conversions) {
|
||||
// range list.
|
||||
SEASTAR_TEST_CASE(test_empty_partition_range_scan) {
|
||||
return do_with_cql_env_thread([] (cql_test_env& e) {
|
||||
e.execute_cql("create keyspace empty_partition_range_scan with replication = {'class': 'SimpleStrategy', 'replication_factor': 1};").get();
|
||||
e.execute_cql("create keyspace empty_partition_range_scan with replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};").get();
|
||||
e.execute_cql("create table empty_partition_range_scan.tb (a int, b int, c int, val int, PRIMARY KEY ((a,b),c) );").get();
|
||||
|
||||
|
||||
@@ -4309,7 +4309,7 @@ SEASTAR_TEST_CASE(test_describe_view_schema) {
|
||||
{"cf_index4_index", "CREATE INDEX cf_index4 ON \"KS\".\"cF\"((pk, pk1),col2);"}
|
||||
};
|
||||
|
||||
e.execute_cql("CREATE KEYSPACE \"KS\" WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}").get();
|
||||
e.execute_cql("CREATE KEYSPACE \"KS\" WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 3}").get();
|
||||
e.execute_cql(base_table).get();
|
||||
|
||||
for (auto &&ct : cql_create_tables) {
|
||||
|
||||
@@ -52,7 +52,7 @@ SEASTAR_TEST_CASE(test_abort_server_on_background_error) {
|
||||
if (has_ks) {
|
||||
co_await e.execute_cql("drop keyspace new_ks");
|
||||
} else {
|
||||
co_await e.execute_cql("create keyspace new_ks with replication = {'class': 'SimpleStrategy', 'replication_factor': 1}");
|
||||
co_await e.execute_cql("create keyspace new_ks with replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}");
|
||||
}
|
||||
has_ks = !has_ks;
|
||||
};
|
||||
@@ -81,7 +81,7 @@ SEASTAR_TEST_CASE(test_group0_history_clearing_old_entries) {
|
||||
if (has_ks) {
|
||||
co_await e.execute_cql("drop keyspace new_ks");
|
||||
} else {
|
||||
co_await e.execute_cql("create keyspace new_ks with replication = {'class': 'SimpleStrategy', 'replication_factor': 1}");
|
||||
co_await e.execute_cql("create keyspace new_ks with replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}");
|
||||
}
|
||||
has_ks = !has_ks;
|
||||
};
|
||||
@@ -172,7 +172,7 @@ SEASTAR_TEST_CASE(test_concurrent_group0_modifications) {
|
||||
size_t successes = 0;
|
||||
bool has_ks = false;
|
||||
auto drop_ks_cql = format("drop keyspace new_ks{}", task_id);
|
||||
auto create_ks_cql = format("create keyspace new_ks{} with replication = {{'class': 'SimpleStrategy', 'replication_factor': 1}}", task_id);
|
||||
auto create_ks_cql = format("create keyspace new_ks{} with replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': 1}}", task_id);
|
||||
|
||||
auto perform = [&] () -> future<> {
|
||||
try {
|
||||
|
||||
@@ -918,7 +918,7 @@ SEASTAR_TEST_CASE(memtable_flush_compresses_mutations) {
|
||||
// Create table and insert some data
|
||||
char const* ks_name = "keyspace_name";
|
||||
char const* table_name = "table_name";
|
||||
env.execute_cql(format("CREATE KEYSPACE {} WITH REPLICATION = {{'class' : 'SimpleStrategy', 'replication_factor' : 1}};", ks_name)).get();
|
||||
env.execute_cql(format("CREATE KEYSPACE {} WITH REPLICATION = {{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}};", ks_name)).get();
|
||||
env.execute_cql(format("CREATE TABLE {}.{} (pk int, ck int, id int, PRIMARY KEY(pk, ck));", ks_name, table_name)).get();
|
||||
|
||||
replica::database& db = env.local_db();
|
||||
|
||||
@@ -2163,7 +2163,7 @@ SEASTAR_THREAD_TEST_CASE(test_multishard_combining_reader_fast_forwarded_with_pe
|
||||
SEASTAR_THREAD_TEST_CASE(test_multishard_combining_reader_next_partition) {
|
||||
do_with_cql_env_thread([&] (cql_test_env& env) -> future<> {
|
||||
env.execute_cql("CREATE KEYSPACE multishard_combining_reader_next_partition_ks"
|
||||
" WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1};").get();
|
||||
" WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1};").get();
|
||||
env.execute_cql("CREATE TABLE multishard_combining_reader_next_partition_ks.test (pk int, v int, PRIMARY KEY(pk));").get();
|
||||
|
||||
const auto insert_id = env.prepare("INSERT INTO multishard_combining_reader_next_partition_ks.test (\"pk\", \"v\") VALUES (?, ?);").get0();
|
||||
@@ -2249,7 +2249,7 @@ SEASTAR_THREAD_TEST_CASE(test_multishard_streaming_reader) {
|
||||
}
|
||||
|
||||
do_with_cql_env_thread([&] (cql_test_env& env) -> future<> {
|
||||
env.execute_cql("CREATE KEYSPACE multishard_streaming_reader_ks WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1};").get();
|
||||
env.execute_cql("CREATE KEYSPACE multishard_streaming_reader_ks WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1};").get();
|
||||
env.execute_cql("CREATE TABLE multishard_streaming_reader_ks.test (pk int, v int, PRIMARY KEY(pk));").get();
|
||||
|
||||
const auto insert_id = env.prepare("INSERT INTO multishard_streaming_reader_ks.test (\"pk\", \"v\") VALUES (?, ?);").get0();
|
||||
|
||||
@@ -630,7 +630,7 @@ SEASTAR_THREAD_TEST_CASE(test_resources_based_cache_eviction) {
|
||||
// expected
|
||||
}
|
||||
|
||||
env.execute_cql("CREATE KEYSPACE querier_cache WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1};").get();
|
||||
env.execute_cql("CREATE KEYSPACE querier_cache WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1};").get();
|
||||
env.execute_cql("CREATE TABLE querier_cache.test (pk int, ck int, value int, primary key (pk, ck));").get();
|
||||
|
||||
env.require_table_exists("querier_cache", "test").get();
|
||||
|
||||
@@ -4433,7 +4433,7 @@ SEASTAR_TEST_CASE(test_populating_cache_with_expired_and_nonexpired_tombstones)
|
||||
|
||||
env.execute_cql(format(
|
||||
"CREATE KEYSPACE IF NOT EXISTS {} WITH REPLICATION = "
|
||||
"{{'class' : 'SimpleStrategy', 'replication_factor' : 1}};", ks_name)).get();
|
||||
"{{'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}};", ks_name)).get();
|
||||
env.execute_cql(format(
|
||||
"CREATE TABLE {}.{} (pk int, ck int, PRIMARY KEY(pk, ck));", ks_name, table_name)).get();
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ SEASTAR_TEST_CASE(test_new_schema_with_no_structural_change_is_propagated) {
|
||||
.with_column("pk", bytes_type, column_kind::partition_key)
|
||||
.with_column("v1", bytes_type);
|
||||
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
|
||||
auto old_schema = partial.build();
|
||||
|
||||
@@ -73,7 +73,7 @@ SEASTAR_TEST_CASE(test_schema_is_updated_in_keyspace) {
|
||||
.with_column("pk", bytes_type, column_kind::partition_key)
|
||||
.with_column("v1", bytes_type);
|
||||
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
|
||||
auto old_schema = builder.build();
|
||||
|
||||
@@ -108,7 +108,7 @@ SEASTAR_TEST_CASE(test_schema_is_updated_in_keyspace) {
|
||||
SEASTAR_TEST_CASE(test_tombstones_are_ignored_in_version_calculation) {
|
||||
return do_with_cql_env([](cql_test_env& e) {
|
||||
return seastar::async([&] {
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
|
||||
auto table_schema = schema_builder("ks", "table")
|
||||
.with_column("pk", bytes_type, column_kind::partition_key)
|
||||
@@ -145,7 +145,7 @@ SEASTAR_TEST_CASE(test_tombstones_are_ignored_in_version_calculation) {
|
||||
SEASTAR_TEST_CASE(test_concurrent_column_addition) {
|
||||
return do_with_cql_env([](cql_test_env& e) {
|
||||
return seastar::async([&] {
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
|
||||
service::migration_manager& mm = e.migration_manager().local();
|
||||
|
||||
@@ -222,7 +222,7 @@ SEASTAR_TEST_CASE(test_sort_type_in_update) {
|
||||
SEASTAR_TEST_CASE(test_column_is_dropped) {
|
||||
return do_with_cql_env([](cql_test_env& e) {
|
||||
return seastar::async([&] {
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create table tests.table1 (pk int primary key, c1 int, c2 int);").get();
|
||||
e.execute_cql("alter table tests.table1 drop c2;").get();
|
||||
e.execute_cql("alter table tests.table1 add s1 int;").get();
|
||||
@@ -237,7 +237,7 @@ SEASTAR_TEST_CASE(test_column_is_dropped) {
|
||||
|
||||
SEASTAR_TEST_CASE(test_static_column_is_dropped) {
|
||||
return do_with_cql_env_thread([](cql_test_env& e) {
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create table tests.table1 (pk int, c1 int, c2 int static, primary key (pk, c1));").get();
|
||||
|
||||
e.execute_cql("alter table tests.table1 drop c2;").get();
|
||||
@@ -257,7 +257,7 @@ SEASTAR_TEST_CASE(test_static_column_is_dropped) {
|
||||
|
||||
SEASTAR_TEST_CASE(test_multiple_columns_add_and_drop) {
|
||||
return do_with_cql_env_thread([](cql_test_env& e) {
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create table tests.table1 (pk int primary key, c1 int, c2 int, c3 int);").get();
|
||||
|
||||
e.execute_cql("alter table tests.table1 drop (c2);").get();
|
||||
@@ -282,7 +282,7 @@ SEASTAR_TEST_CASE(test_multiple_columns_add_and_drop) {
|
||||
|
||||
SEASTAR_TEST_CASE(test_multiple_static_columns_add_and_drop) {
|
||||
return do_with_cql_env_thread([](cql_test_env& e) {
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create table tests.table1 (pk int, c1 int, c2 int static, c3 int, primary key(pk, c1));").get();
|
||||
|
||||
e.execute_cql("alter table tests.table1 drop (c2);").get();
|
||||
@@ -310,7 +310,7 @@ SEASTAR_TEST_CASE(test_combined_column_add_and_drop) {
|
||||
return seastar::async([&] {
|
||||
service::migration_manager& mm = e.migration_manager().local();
|
||||
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
|
||||
auto s1 = schema_builder("ks", "table1")
|
||||
.with_column("pk", bytes_type, column_kind::partition_key)
|
||||
@@ -372,7 +372,7 @@ SEASTAR_TEST_CASE(test_concurrent_table_creation_with_different_schema) {
|
||||
return seastar::async([&] {
|
||||
service::migration_manager& mm = e.migration_manager().local();
|
||||
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
|
||||
auto s1 = schema_builder("ks", "table1")
|
||||
.with_column("pk1", bytes_type, column_kind::partition_key)
|
||||
@@ -605,7 +605,7 @@ SEASTAR_TEST_CASE(test_notifications) {
|
||||
e.local_mnotifier().register_listener(&listener);
|
||||
auto listener_lease = defer([&e, &listener] { e.local_mnotifier().register_listener(&listener); });
|
||||
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
|
||||
BOOST_REQUIRE_EQUAL(listener.create_keyspace_count, 1);
|
||||
|
||||
@@ -690,7 +690,7 @@ SEASTAR_TEST_CASE(test_prepared_statement_is_invalidated_by_schema_change) {
|
||||
return do_with_cql_env([](cql_test_env& e) {
|
||||
return seastar::async([&] {
|
||||
logging::logger_registry().set_logger_level("query_processor", logging::log_level::debug);
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create keyspace tests with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create table tests.table1 (pk int primary key, c1 int, c2 int);").get();
|
||||
auto id = e.prepare("select * from tests.table1;").get0();
|
||||
|
||||
@@ -752,7 +752,7 @@ future<> test_schema_digest_does_not_change_with_disabled_features(sstring data_
|
||||
if (regenerate) {
|
||||
// Exercise many different kinds of schema changes.
|
||||
e.execute_cql(
|
||||
"create keyspace tests with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
"create keyspace tests with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("create table tests.table1 (pk int primary key, c1 int, c2 int);").get();
|
||||
e.execute_cql("create type tests.basic_info (c1 timestamp, v2 text);").get();
|
||||
e.execute_cql("create index on tests.table1 (c1);").get();
|
||||
@@ -762,7 +762,7 @@ future<> test_schema_digest_does_not_change_with_disabled_features(sstring data_
|
||||
e.execute_cql(
|
||||
"create materialized view ks.tbl_view_2 AS SELECT a FROM ks.tbl WHERE a IS NOT NULL PRIMARY KEY (a)").get();
|
||||
e.execute_cql(
|
||||
"create keyspace tests2 with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };").get();
|
||||
"create keyspace tests2 with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 };").get();
|
||||
e.execute_cql("drop keyspace tests2;").get();
|
||||
extra_schema_changes(e);
|
||||
}
|
||||
@@ -926,7 +926,7 @@ SEASTAR_TEST_CASE(test_schema_digest_does_not_change_with_keyspace_storage_optio
|
||||
std::set<sstring>{},
|
||||
std::move(expected_digests),
|
||||
[] (cql_test_env& e) {
|
||||
e.execute_cql("create keyspace tests_s3 with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }"
|
||||
e.execute_cql("create keyspace tests_s3 with replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 }"
|
||||
" and storage = { 'type': 'S3', 'bucket': 'b1', 'endpoint': 'localhost' };").get();
|
||||
e.execute_cql("create table tests_s3.table1 (pk int primary key, c1 int, c2 int)").get();
|
||||
});
|
||||
|
||||
@@ -16,18 +16,18 @@ SEASTAR_THREAD_TEST_CASE(test_empty) {
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_keyspace_only) {
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas("CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};").get().size(), 0);
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas("CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};").get().size(), 0);
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_single_table) {
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas("CREATE TABLE ks.cf (pk int PRIMARY KEY, v int)").get().size(), 1);
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas("CREATE TABLE ks.cf (pk int PRIMARY KEY, v map<int, int>)").get().size(), 1);
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas("CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}; CREATE TABLE ks.cf (pk int PRIMARY KEY, v int);").get().size(), 1);
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas("CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}; CREATE TABLE ks.cf (pk int PRIMARY KEY, v int);").get().size(), 1);
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_keyspace_replication_strategy) {
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas("CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}; CREATE TABLE ks.cf (pk int PRIMARY KEY, v int);").get().size(), 1);
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas("CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}; CREATE TABLE ks.cf (pk int PRIMARY KEY, v int);").get().size(), 1);
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas("CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}; CREATE TABLE ks.cf (pk int PRIMARY KEY, v int);").get().size(), 1);
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas("CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 3}; CREATE TABLE ks.cf (pk int PRIMARY KEY, v int);").get().size(), 1);
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas("CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'mydc1': 1, 'mydc2': 4}; CREATE TABLE ks.cf (pk int PRIMARY KEY, v int);").get().size(), 1);
|
||||
}
|
||||
|
||||
@@ -35,35 +35,35 @@ SEASTAR_THREAD_TEST_CASE(test_multiple_tables) {
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas("CREATE TABLE ks.cf1 (pk int PRIMARY KEY, v int); CREATE TABLE ks.cf2 (pk int PRIMARY KEY, v int)").get().size(), 2);
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas("CREATE TABLE ks.cf1 (pk int PRIMARY KEY, v int); CREATE TABLE ks.cf2 (pk int PRIMARY KEY, v int);").get().size(), 2);
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas(
|
||||
"CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}; "
|
||||
"CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}; "
|
||||
"CREATE TABLE ks.cf1 (pk int PRIMARY KEY, v int); "
|
||||
"CREATE TABLE ks.cf2 (pk int PRIMARY KEY, v int); "
|
||||
"CREATE TABLE ks.cf3 (pk int PRIMARY KEY, v int); "
|
||||
).get().size(), 3);
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas(
|
||||
"CREATE KEYSPACE ks1 WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}; "
|
||||
"CREATE KEYSPACE ks1 WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}; "
|
||||
"CREATE TABLE ks1.cf (pk int PRIMARY KEY, v int); "
|
||||
"CREATE KEYSPACE ks2 WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}; "
|
||||
"CREATE KEYSPACE ks2 WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}; "
|
||||
"CREATE TABLE ks2.cf (pk int PRIMARY KEY, v int); "
|
||||
).get().size(), 2);
|
||||
}
|
||||
|
||||
SEASTAR_THREAD_TEST_CASE(test_udts) {
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas(
|
||||
"CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}; "
|
||||
"CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}; "
|
||||
"CREATE TYPE ks.type1 (f1 int, f2 text); "
|
||||
"CREATE TABLE ks.cf (pk int PRIMARY KEY, v frozen<type1>); "
|
||||
).get().size(), 1);
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas(
|
||||
"CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}; "
|
||||
"CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}; "
|
||||
"CREATE TYPE ks.type1 (f1 int, f2 text); "
|
||||
"CREATE TABLE ks.cf (pk int PRIMARY KEY, v type1); "
|
||||
).get().size(), 1);
|
||||
BOOST_REQUIRE_EQUAL(tools::load_schemas(
|
||||
"CREATE KEYSPACE ks1 WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}; "
|
||||
"CREATE KEYSPACE ks1 WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}; "
|
||||
"CREATE TYPE ks1.type1 (f1 int, f2 text); "
|
||||
"CREATE TABLE ks1.cf (pk int PRIMARY KEY, v frozen<type1>); "
|
||||
"CREATE KEYSPACE ks2 WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}; "
|
||||
"CREATE KEYSPACE ks2 WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}; "
|
||||
"CREATE TYPE ks2.type1 (f1 int, f2 text); "
|
||||
"CREATE TABLE ks2.cf (pk int PRIMARY KEY, v frozen<type1>); "
|
||||
).get().size(), 2);
|
||||
|
||||
@@ -128,7 +128,7 @@ SEASTAR_TEST_CASE(test_invalid_user_type_statements) {
|
||||
"A user type cannot contain non-frozen user type fields");
|
||||
|
||||
// table cannot refer to UDT in another keyspace
|
||||
e.execute_cql("create keyspace ks2 with replication={'class':'SimpleStrategy','replication_factor':1}").discard_result().get();
|
||||
e.execute_cql("create keyspace ks2 with replication={'class':'NetworkTopologyStrategy','replication_factor':1}").discard_result().get();
|
||||
e.execute_cql("create type ks2.ut2 (a int)").discard_result().get();
|
||||
REQUIRE_INVALID(e, "create table bad (a int primary key, b ks2.ut2)",
|
||||
"Statement on keyspace ks cannot refer to a user type in keyspace ks2; "
|
||||
|
||||
@@ -469,7 +469,7 @@ def test_keyspaces_quoting(cql):
|
||||
# are the ones with capital letters.
|
||||
name = "Quoted_KS"
|
||||
|
||||
cql.execute(f"CREATE KEYSPACE \"{name}\" WITH REPLICATION = {{'class': 'SimpleStrategy', 'replication_factor': 1}}")
|
||||
cql.execute(f"CREATE KEYSPACE \"{name}\" WITH REPLICATION = {{'class': 'NetworkTopologyStrategy', 'replication_factor': 1}}")
|
||||
try:
|
||||
desc = cql.execute(f"DESC KEYSPACE \"{name}\"").one().create_statement
|
||||
|
||||
@@ -494,7 +494,7 @@ def test_table_quoting(cql):
|
||||
name = "Quoted_TABLE"
|
||||
col_name = "!@#$%"
|
||||
|
||||
cql.execute(f"CREATE KEYSPACE \"{ks_name}\" WITH REPLICATION = {{'class': 'SimpleStrategy', 'replication_factor': 1}}")
|
||||
cql.execute(f"CREATE KEYSPACE \"{ks_name}\" WITH REPLICATION = {{'class': 'NetworkTopologyStrategy', 'replication_factor': 1}}")
|
||||
try:
|
||||
cql.execute(f"CREATE TABLE \"{ks_name}\".\"{name}\"(a int primary key, \"{col_name}\" int)")
|
||||
desc = cql.execute(f"DESC TABLE \"{ks_name}\".\"{name}\"").one().create_statement
|
||||
@@ -528,7 +528,7 @@ def test_type_quoting(cql):
|
||||
name = "udt_@@@"
|
||||
field_name = "field_!!!"
|
||||
|
||||
cql.execute(f"CREATE KEYSPACE \"{ks_name}\" WITH REPLICATION = {{'class': 'SimpleStrategy', 'replication_factor': 1}}")
|
||||
cql.execute(f"CREATE KEYSPACE \"{ks_name}\" WITH REPLICATION = {{'class': 'NetworkTopologyStrategy', 'replication_factor': 1}}")
|
||||
try:
|
||||
cql.execute(f"CREATE TYPE \"{ks_name}\".\"{name}\" (a int, \"{field_name}\" text)")
|
||||
desc = cql.execute(f"DESC TYPE \"{ks_name}\".\"{name}\"").one().create_statement
|
||||
@@ -553,7 +553,7 @@ def test_function_quoting(scylla_only, cql, test_keyspace):
|
||||
ks_name = "Quoted_KS"
|
||||
name = "!udf!"
|
||||
|
||||
cql.execute(f"CREATE KEYSPACE \"{ks_name}\" WITH REPLICATION = {{'class': 'SimpleStrategy', 'replication_factor': 1}}")
|
||||
cql.execute(f"CREATE KEYSPACE \"{ks_name}\" WITH REPLICATION = {{'class': 'NetworkTopologyStrategy', 'replication_factor': 1}}")
|
||||
try:
|
||||
cql.execute(f"""
|
||||
CREATE FUNCTION \"{ks_name}\".\"{name}\"(val int)
|
||||
@@ -583,7 +583,7 @@ def test_aggregate_quoting(scylla_only, cql, test_keyspace):
|
||||
sfunc_name = "!udf!"
|
||||
name = "'uda'!"
|
||||
|
||||
cql.execute(f"CREATE KEYSPACE \"{ks_name}\" WITH REPLICATION = {{'class': 'SimpleStrategy', 'replication_factor': 1}}")
|
||||
cql.execute(f"CREATE KEYSPACE \"{ks_name}\" WITH REPLICATION = {{'class': 'NetworkTopologyStrategy', 'replication_factor': 1}}")
|
||||
try:
|
||||
cql.execute(f"""
|
||||
CREATE FUNCTION \"{ks_name}\".\"{sfunc_name}\"(val1 int, val2 int)
|
||||
|
||||
@@ -194,7 +194,7 @@ def test_concurrent_create_and_drop_keyspace(cql, this_dc, fails_without_consist
|
||||
# Test that passing "LOCAL" parameter to storage options works as expected
|
||||
# and is not explicitly stored - since it's equal to the original storage
|
||||
def test_storage_options_local(cql, scylla_only):
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : '1' } " \
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : '1' } " \
|
||||
"AND STORAGE = { 'type' : 'LOCAL' }"
|
||||
with new_test_keyspace(cql, ksdef) as keyspace:
|
||||
res = cql.execute(f"SELECT * FROM system_schema.scylla_keyspaces WHERE keyspace_name = '{keyspace}'")
|
||||
@@ -202,7 +202,7 @@ def test_storage_options_local(cql, scylla_only):
|
||||
|
||||
# Test that passing an unsupported storage type is not legal
|
||||
def test_storage_options_unknown_type(cql, scylla_only):
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : '1' } " \
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : '1' } " \
|
||||
"AND STORAGE = { 'type' : 'S4', 'bucket' : '42', 'endpoint' : 'localhost' }"
|
||||
with pytest.raises(InvalidRequest):
|
||||
with new_test_keyspace(cql, ksdef):
|
||||
@@ -210,12 +210,12 @@ def test_storage_options_unknown_type(cql, scylla_only):
|
||||
|
||||
# Test that passing nonexistent options results in an error
|
||||
def test_storage_options_nonexistent_param(cql, scylla_only):
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : '1' } " \
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : '1' } " \
|
||||
"AND STORAGE = { 'type' : 'S3', 'bucket' : '42', 'endpoint' : 'localhost', 'superfluous' : 'info' }"
|
||||
with pytest.raises(InvalidRequest):
|
||||
with new_test_keyspace(cql, ksdef):
|
||||
pass
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : '1' } " \
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : '1' } " \
|
||||
"AND STORAGE = { 'type' : 'LOCAL', 'superfluous' : 'info' }"
|
||||
with pytest.raises(InvalidRequest):
|
||||
with new_test_keyspace(cql, ksdef):
|
||||
@@ -223,7 +223,7 @@ def test_storage_options_nonexistent_param(cql, scylla_only):
|
||||
|
||||
# Test that not passing required parameters fails
|
||||
def test_storage_options_required_param(cql, scylla_only):
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : '1' } " \
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : '1' } " \
|
||||
"AND STORAGE = { 'type' : 'S3', 'bucket' : '42' }"
|
||||
with pytest.raises(InvalidRequest):
|
||||
with new_test_keyspace(cql, ksdef):
|
||||
@@ -232,18 +232,18 @@ def test_storage_options_required_param(cql, scylla_only):
|
||||
# Test that storage options cannot be altered (at least until it's well defined
|
||||
# what it means to e.g. switch from S3 to another format and back).
|
||||
def test_storage_options_alter_type(cql, scylla_only):
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : '1' } " \
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : '1' } " \
|
||||
"AND STORAGE = { 'type' : 'LOCAL' }"
|
||||
with new_test_keyspace(cql, ksdef) as keyspace:
|
||||
# It's not fine to change the storage type
|
||||
ksdef_local = "WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : '1' } " \
|
||||
ksdef_local = "WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : '1' } " \
|
||||
"AND STORAGE = { 'type' : 'S3', 'bucket' : '/b1', 'endpoint': 'localhost'}"
|
||||
with pytest.raises(InvalidRequest):
|
||||
res = cql.execute(f"ALTER KEYSPACE {keyspace} {ksdef_local}")
|
||||
|
||||
# Test that server-side desc statement is able to describe storage options, when not local.
|
||||
def test_storage_options_describe(cql, scylla_only):
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : '1' } " \
|
||||
ksdef = "WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : '1' } " \
|
||||
"AND STORAGE = {'type': 'S3', 'bucket': '42', 'endpoint': 'localhost'}"
|
||||
|
||||
with new_test_keyspace(cql, ksdef) as keyspace:
|
||||
|
||||
@@ -86,11 +86,11 @@ def test_grant_revoke_data_permissions(cql, test_keyspace):
|
||||
ks = unique_name()
|
||||
# Permissions on all keyspaces
|
||||
def create_keyspace_idempotent():
|
||||
user_session.execute(f"CREATE KEYSPACE IF NOT EXISTS {ks} WITH REPLICATION = {{ 'class' : 'SimpleStrategy', 'replication_factor' : 1 }}")
|
||||
user_session.execute(f"CREATE KEYSPACE IF NOT EXISTS {ks} WITH REPLICATION = {{ 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 }}")
|
||||
user_session.execute(f"DROP KEYSPACE IF EXISTS {ks}")
|
||||
check_enforced(cql, username, permission='CREATE', resource='ALL KEYSPACES', function=create_keyspace_idempotent)
|
||||
# Permissions for a specific keyspace
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }") as keyspace:
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 }") as keyspace:
|
||||
t = unique_name()
|
||||
def create_table_idempotent():
|
||||
user_session.execute(f"CREATE TABLE IF NOT EXISTS {keyspace}.{t}(id int primary key)")
|
||||
@@ -127,7 +127,7 @@ def test_grant_revoke_data_permissions(cql, test_keyspace):
|
||||
# Test that permissions for user-defined functions are serialized in a Cassandra-compatible way
|
||||
def test_udf_permissions_serialization(cql):
|
||||
schema = "a int primary key"
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 1 }") as keyspace, new_user(cql) as user:
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', 'replication_factor': 1 }") as keyspace, new_user(cql) as user:
|
||||
with new_test_table(cql, keyspace, schema) as table:
|
||||
# Creating a bilingual function makes this test case work for both Scylla and Cassandra
|
||||
div_body_lua = "(b bigint, i int) CALLED ON NULL INPUT RETURNS bigint LANGUAGE lua AS 'return b//i'"
|
||||
@@ -165,7 +165,7 @@ def test_udf_permissions_serialization(cql):
|
||||
def test_udf_permissions_quoted_names(cassandra_bug, cql):
|
||||
udt_name = f'"{unique_name()}weird_udt[t^t]a^b^[]"'
|
||||
schema = f"a frozen<{udt_name}> primary key"
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
with new_type(cql, keyspace, "(a text, b int)", udt_name) as udt, new_test_table(cql, keyspace, schema) as table:
|
||||
fun_body_lua = f"(i {udt}) CALLED ON NULL INPUT RETURNS bigint LANGUAGE lua AS 'return 42;'"
|
||||
fun_body_java = f"(i {udt}) CALLED ON NULL INPUT RETURNS bigint LANGUAGE java AS 'return 42;'"
|
||||
@@ -197,7 +197,7 @@ def test_udf_permissions_quoted_names(cassandra_bug, cql):
|
||||
# If the signature is specified, test that the permission check is performed as usual.
|
||||
def test_drop_udf_with_same_name(cql):
|
||||
schema = "a int primary key"
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
body1_lua = "(i int) CALLED ON NULL INPUT RETURNS bigint LANGUAGE lua AS 'return 42;'"
|
||||
body1_java = "(i int) CALLED ON NULL INPUT RETURNS bigint LANGUAGE java AS 'return Long.valueOf(42);'"
|
||||
body2_lua = "(i int, j int) CALLED ON NULL INPUT RETURNS bigint LANGUAGE lua AS 'return 42;'"
|
||||
@@ -229,7 +229,7 @@ def test_drop_udf_with_same_name(cql):
|
||||
def test_grant_revoke_udf_permissions(cql):
|
||||
schema = "a int primary key, b list<int>"
|
||||
user = "cassandra"
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
with new_test_table(cql, keyspace, schema) as table:
|
||||
fun_body_lua = "(i int, l list<int>) CALLED ON NULL INPUT RETURNS int LANGUAGE lua AS 'return 42;'"
|
||||
fun_body_java = "(i int, l list<int>) CALLED ON NULL INPUT RETURNS int LANGUAGE java AS 'return 42;'"
|
||||
@@ -295,7 +295,7 @@ def test_grant_perms_on_nonexistent_udf(cql):
|
||||
grant(cql, 'EXECUTE', f'ALL FUNCTIONS IN KEYSPACE {keyspace}', username)
|
||||
with pytest.raises((InvalidRequest, ConfigurationException)):
|
||||
grant(cql, 'EXECUTE', f'FUNCTION {keyspace}.{fun_name}(int)', username)
|
||||
cql.execute(f"CREATE KEYSPACE IF NOT EXISTS {keyspace} WITH REPLICATION = {{ 'class' : 'SimpleStrategy', 'replication_factor' : 1 }}")
|
||||
cql.execute(f"CREATE KEYSPACE IF NOT EXISTS {keyspace} WITH REPLICATION = {{ 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 }}")
|
||||
grant(cql, 'EXECUTE', f'ALL FUNCTIONS IN KEYSPACE {keyspace}', username)
|
||||
revoke(cql, 'EXECUTE', f'ALL FUNCTIONS IN KEYSPACE {keyspace}', username)
|
||||
with pytest.raises((InvalidRequest, SyntaxException)):
|
||||
@@ -316,7 +316,7 @@ def test_grant_perms_on_nonexistent_udf(cql):
|
||||
# Test that permissions for user-defined aggregates are also enforced.
|
||||
def test_grant_revoke_uda_permissions(cql):
|
||||
schema = 'id bigint primary key'
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
with new_test_table(cql, keyspace, schema) as table:
|
||||
for i in range(8):
|
||||
cql.execute(f"INSERT INTO {table} (id) VALUES ({10**i})")
|
||||
@@ -375,7 +375,7 @@ def test_grant_revoke_uda_permissions(cql):
|
||||
|
||||
# Test that permissions for user-defined functions created on top of user-defined types work
|
||||
def test_udf_permissions_with_udt(cql):
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
with new_type(cql, keyspace, '(v int)') as udt:
|
||||
schema = f"a frozen<{udt}> primary key"
|
||||
with new_test_table(cql, keyspace, schema) as table:
|
||||
@@ -397,7 +397,7 @@ def test_udf_permissions_with_udt(cql):
|
||||
|
||||
# Test that permissions on user-defined functions with no arguments work
|
||||
def test_udf_permissions_no_args(cql):
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
with new_test_table(cql, keyspace, schema="a int primary key") as table, new_user(cql) as username:
|
||||
with new_session(cql, username) as user_session:
|
||||
fun_body_lua = f"() CALLED ON NULL INPUT RETURNS int LANGUAGE lua AS 'return 42;'"
|
||||
@@ -423,7 +423,7 @@ def test_udf_permissions_no_args(cql):
|
||||
def test_create_on_single_function(cql):
|
||||
schema = "a int primary key"
|
||||
user = "cassandra"
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
with new_test_keyspace(cql, "WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', 'replication_factor': 1 }") as keyspace:
|
||||
with new_test_table(cql, keyspace, schema) as table:
|
||||
fun_body_lua = f"(a int, b int) CALLED ON NULL INPUT RETURNS int LANGUAGE lua AS 'return a + b;'"
|
||||
fun_body_java = f"(a int, b int) CALLED ON NULL INPUT RETURNS int LANGUAGE java AS 'return a + b;'"
|
||||
|
||||
@@ -217,7 +217,7 @@ def test_nested_collection_initcond(scylla_only, cql, test_keyspace):
|
||||
|
||||
def test_drop_keyspace_with_uda(scylla_only, cql):
|
||||
ks = unique_name()
|
||||
cql.execute(f"CREATE KEYSPACE {ks} WITH replication = {{'class': 'SimpleStrategy', 'replication_factor': '1'}}")
|
||||
cql.execute(f"CREATE KEYSPACE {ks} WITH replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}}")
|
||||
f1 = unique_name()
|
||||
cql.execute(f"CREATE FUNCTION {ks}.{f1}(acc int, val int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE lua AS $$ return acc $$")
|
||||
f2 = unique_name()
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
-- SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0)
|
||||
|
||||
-- setup
|
||||
CREATE KEYSPACE k WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE k WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
USE k;
|
||||
|
||||
-- testBatch
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
> -- SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0)
|
||||
>
|
||||
> -- setup
|
||||
> CREATE KEYSPACE k WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE k WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> USE k;
|
||||
OK
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
create table ks.test_scylla_cdc_log (pk int primary key);
|
||||
-- Should be possible to drop it
|
||||
drop table ks.test_scylla_cdc_log;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> create table ks.test_scylla_cdc_log (pk int primary key);
|
||||
OK
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
-- do range delete in batch
|
||||
create table ks.t (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> -- do range delete in batch
|
||||
> create table ks.t (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true, 'preimage': true, 'postimage': true};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
create table ks.tb1 (pk int primary key, c1 counter) with cdc = {'enabled': true};
|
||||
|
||||
create table ks.tb2 (pk int primary key, c1 counter);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> create table ks.tb1 (pk int primary key, c1 counter) with cdc = {'enabled': true};
|
||||
Error from server: code=2200 [Invalid query] message="Cannot create CDC log for table ks.tb1. Counter support not implemented"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
create table ks.tb1 (pk int primary key, v int) with cdc = {'enabled': true};
|
||||
|
||||
create materialized view ks.tb1_mv as select * from ks.tb1_scylla_cdc_log where v is not null primary key (v);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> create table ks.tb1 (pk int primary key, v int) with cdc = {'enabled': true};
|
||||
OK
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
create table ks.tbl (pk int primary key) with cdc = {'enabled': true};
|
||||
alter table ks.tbl_scylla_cdc_log with cdc = {'enabled': true};
|
||||
DROP KEYSPACE ks;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> create table ks.tbl (pk int primary key) with cdc = {'enabled': true};
|
||||
OK
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
-- do not depend on how stream IDs are assigned to partition keys.
|
||||
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
|
||||
-- create cdc enabled table
|
||||
create table ks.t (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
> -- do not depend on how stream IDs are assigned to partition keys.
|
||||
>
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
>
|
||||
> -- create cdc enabled table
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
create table ks.t (pk int, ck int, vs int static, vc int, primary key (pk, ck)) with cdc = {'enabled': true, 'preimage': true};
|
||||
|
||||
-- generates 2 rows: preimage(static), delta(static)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> create table ks.t (pk int, ck int, vs int static, vc int, primary key (pk, ck)) with cdc = {'enabled': true, 'preimage': true};
|
||||
OK
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
CREATE TABLE ks.tbl_cdc_lwt (pk int, ck int, val int, PRIMARY KEY(pk, ck)) WITH cdc = {'enabled':true, 'preimage':true};
|
||||
|
||||
-- (0) successful insert
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> CREATE TABLE ks.tbl_cdc_lwt (pk int, ck int, val int, PRIMARY KEY(pk, ck)) WITH cdc = {'enabled':true, 'preimage':true};
|
||||
OK
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
CREATE TABLE ks.tbl_cnt (pk int PRIMARY KEY, c1 counter);
|
||||
|
||||
-- insert some values in one column
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> CREATE TABLE ks.tbl_cnt (pk int PRIMARY KEY, c1 counter);
|
||||
OK
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
create type ks.ut (a int);
|
||||
create table ks.t (pk frozen<ut> primary key);
|
||||
alter type ks.ut add b int;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> create type ks.ut (a int);
|
||||
OK
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Error messages contain a keyspace name. Make the output stable.
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
-- setup
|
||||
create table ks.my_table (key int primary key);
|
||||
insert into ks.my_table (key) values (1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
> -- Error messages contain a keyspace name. Make the output stable.
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> -- setup
|
||||
> create table ks.my_table (key int primary key);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE KEYSPACE k WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE k WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
USE k;
|
||||
CREATE TABLE t1 (userid int PRIMARY KEY);
|
||||
CREATE TABLE t2 (userid int PRIMARY KEY);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
> CREATE KEYSPACE k WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE k WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> USE k;
|
||||
OK
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- single null value
|
||||
CREATE KEYSPACE reproducer WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE reproducer WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
CREATE TABLE reproducer.t(pk int PRIMARY KEY, v int);
|
||||
INSERT INTO reproducer.t (pk) VALUES (1);
|
||||
SELECT TOKEN(v) FROM reproducer.t;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
> -- single null value
|
||||
> CREATE KEYSPACE reproducer WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE reproducer WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> CREATE TABLE reproducer.t(pk int PRIMARY KEY, v int);
|
||||
OK
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- regression test for #10642
|
||||
CREATE KEYSPACE reproducer WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
CREATE KEYSPACE reproducer WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
CREATE TABLE reproducer.varchar(pk int, ck int, PRIMARY KEY(pk, ck));
|
||||
CREATE TABLE reproducer.text(pk int, ck int, PRIMARY KEY(pk, ck));
|
||||
DROP KEYSPACE reproducer;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
> -- regression test for #10642
|
||||
> CREATE KEYSPACE reproducer WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
> CREATE KEYSPACE reproducer WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
||||
OK
|
||||
> CREATE TABLE reproducer.varchar(pk int, ck int, PRIMARY KEY(pk, ck));
|
||||
OK
|
||||
|
||||
@@ -465,7 +465,7 @@ public:
|
||||
}
|
||||
|
||||
future<> create_keyspace(std::string_view name) {
|
||||
auto query = format("create keyspace {} with replication = {{ 'class' : 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor' : 1 }};", name);
|
||||
auto query = format("create keyspace {} with replication = {{ 'class' : 'org.apache.cassandra.locator.NetworkTopologyStrategy', 'replication_factor' : 1 }};", name);
|
||||
return execute_cql(query).discard_result();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ run.wait_for_services(pid, [ lambda: check_cql(ip) ])
|
||||
print(f'Create keyspace (minio listening at {s3_server_address})')
|
||||
cluster = run.get_cql_cluster(ip)
|
||||
conn = cluster.connect()
|
||||
conn.execute("CREATE KEYSPACE test_ks WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': '1' } AND STORAGE = { 'type': 'S3', 'endpoint': '" + f'{s3_server_address}' + "', 'bucket': '" + f'{s3_public_bucket}' + "' };")
|
||||
conn.execute("CREATE KEYSPACE test_ks WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', 'replication_factor': '1' } AND STORAGE = { 'type': 'S3', 'endpoint': '" + f'{s3_server_address}' + "', 'bucket': '" + f'{s3_public_bucket}' + "' };")
|
||||
conn.execute("CREATE TABLE test_ks.test_cf ( name text primary key, value text );")
|
||||
conn.execute("INSERT INTO test_ks.test_cf ( name, value ) VALUES ('0', 'zero');")
|
||||
conn.execute("INSERT INTO test_ks.test_cf ( name, value ) VALUES ('1', 'one');")
|
||||
|
||||
@@ -1743,7 +1743,7 @@ static
|
||||
void populate(const std::vector<dataset*>& datasets, cql_test_env& env, const table_config& cfg, size_t flush_threshold) {
|
||||
drop_keyspace_if_exists(env, "ks");
|
||||
|
||||
env.execute_cql("CREATE KEYSPACE ks WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1};").get();
|
||||
env.execute_cql("CREATE KEYSPACE ks WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1};").get();
|
||||
|
||||
std::cout << "Saving test config...\n";
|
||||
env.execute_cql("create table config (name text primary key, n_rows int, value_size int)").get();
|
||||
|
||||
@@ -458,7 +458,7 @@ class ScyllaServer:
|
||||
) as cluster:
|
||||
with cluster.connect() as session:
|
||||
session.execute("CREATE KEYSPACE IF NOT EXISTS k WITH REPLICATION = {" +
|
||||
"'class' : 'SimpleStrategy', 'replication_factor' : 1 }")
|
||||
"'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1 }")
|
||||
session.execute("DROP KEYSPACE k")
|
||||
|
||||
async def shutdown_control_connection(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user