cql3: keyspace prepare_options: expand replication_factor also for fully qualified NetworkTopologyStrategy

It was auto-expanded only if the strategy name
was the short "NetworkTopologyStrategy" name.

Fixes #9302

Test: cql_query_test.test_rf_expand(dev)

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2021-09-06 15:49:01 +03:00
parent e4dc81ec04
commit b9aa92edd4
2 changed files with 8 additions and 1 deletions

View File

@@ -55,7 +55,7 @@ static std::map<sstring, sstring> prepare_options(
const std::map<sstring, sstring>& old_options = {}) {
options.erase(ks_prop_defs::REPLICATION_STRATEGY_CLASS_KEY);
if (strategy_class != "NetworkTopologyStrategy") {
if (locator::abstract_replication_strategy::to_qualified_class_name(strategy_class) != "org.apache.cassandra.locator.NetworkTopologyStrategy") {
return options;
}

View File

@@ -3611,6 +3611,13 @@ SEASTAR_TEST_CASE(test_rf_expand) {
}
};
// 'replication_factor' option should be translated to datacenter name for NetworkTopologyStrategy
e.execute_cql(format("CREATE KEYSPACE rf_expand_0 WITH replication = {{'class': '{}', 'replication_factor': 3}}", network_topology)).get();
assert_replication_contains("rf_expand_0", {
{"class", network_topology},
{"datacenter1", "3"}
});
e.execute_cql("CREATE KEYSPACE rf_expand_1 WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 3}").get();
assert_replication_contains("rf_expand_1", {
{"class", network_topology},