diff --git a/db/system_keyspace.cc b/db/system_keyspace.cc index 7980ce771a..65959c3a2d 100644 --- a/db/system_keyspace.cc +++ b/db/system_keyspace.cc @@ -1947,7 +1947,7 @@ void register_virtual_tables(service::storage_service& ss) { add_table(std::make_unique(ss)); } -std::vector all_tables() { +std::vector all_tables(const db::config& cfg) { std::vector r; auto schema_tables = db::schema_tables::all_tables(schema_features::full()); std::copy(schema_tables.begin(), schema_tables.end(), std::back_inserter(r)); @@ -1956,12 +1956,14 @@ std::vector all_tables() { compactions_in_progress(), compaction_history(), sstable_activity(), clients(), size_estimates(), large_partitions(), large_rows(), large_cells(), scylla_local(), db::schema_tables::scylla_table_schema_history(), - raft(), raft_snapshots(), v3::views_builds_in_progress(), v3::built_views(), v3::scylla_views_builds_in_progress(), v3::truncated(), v3::cdc_local(), }); + if (cfg.check_experimental(db::experimental_features_t::RAFT)) { + r.insert(r.end(), {raft(), raft_snapshots()}); + } // legacy schema r.insert(r.end(), { // TODO: once we migrate hints/batchlog and add convertor @@ -1997,9 +1999,10 @@ static bool maybe_write_in_user_memory(schema_ptr s, database& db) { future<> make(database& db, service::storage_service& ss) { register_virtual_tables(ss); - auto enable_cache = db.get_config().enable_cache(); - bool durable = db.get_config().data_file_directories().size() > 0; - for (auto&& table : all_tables()) { + auto& db_config = db.get_config(); + auto enable_cache = db_config.enable_cache(); + bool durable = db_config.data_file_directories().size() > 0; + for (auto&& table : all_tables(db_config)) { auto ks_name = table->ks_name(); if (!db.has_keyspace(ks_name)) { auto ksm = make_lw_shared(ks_name, diff --git a/db/system_keyspace.hh b/db/system_keyspace.hh index 34ec9bffa7..8a5260315a 100644 --- a/db/system_keyspace.hh +++ b/db/system_keyspace.hh @@ -90,6 +90,8 @@ namespace db { sstring system_keyspace_name(); +class config; + namespace system_keyspace { static constexpr auto NAME = "system"; @@ -213,7 +215,7 @@ future<> remove_endpoint(gms::inet_address ep); future<> set_scylla_local_param(const sstring& key, const sstring& value); future> get_scylla_local_param(const sstring& key); -std::vector all_tables(); +std::vector all_tables(const db::config& cfg); future<> make(database& db, service::storage_service& ss); /// overloads diff --git a/test/boost/schema_change_test.cc b/test/boost/schema_change_test.cc index 8c24e599ac..c697634b2c 100644 --- a/test/boost/schema_change_test.cc +++ b/test/boost/schema_change_test.cc @@ -805,5 +805,5 @@ SEASTAR_TEST_CASE(test_schema_tables_use_null_sharder) { BOOST_REQUIRE_EQUAL(s->get_sharder().shard_count(), 1); } }).get(); - }); + }, raft_cql_test_config()); } diff --git a/test/lib/cql_test_env.cc b/test/lib/cql_test_env.cc index 2f03df6b8c..05b7f93dc9 100644 --- a/test/lib/cql_test_env.cc +++ b/test/lib/cql_test_env.cc @@ -685,12 +685,18 @@ public: sys_dist_ks.start(std::ref(qp), std::ref(mm), std::ref(proxy)).get(); - // We need to have a system keyspace started and - // initialized to initialize Raft service. - raft_gr.invoke_on_all(&service::raft_group_registry::init).get(); + const bool raft_enabled = cfg->check_experimental(db::experimental_features_t::RAFT); + if (raft_enabled) { + // We need to have a system keyspace started and + // initialized to initialize Raft service. + raft_gr.invoke_on_all(&service::raft_group_registry::init).get(); + } auto stop_raft_rpc = defer([&raft_gr] { raft_gr.invoke_on_all(&service::raft_group_registry::uninit).get(); }); + if (!raft_enabled) { + stop_raft_rpc.cancel(); + } cdc_generation_service.start(std::ref(*cfg), std::ref(gms::get_gossiper()), std::ref(sys_dist_ks), std::ref(abort_sources), std::ref(token_metadata), std::ref(feature_service)).get(); auto stop_cdc_generation_service = defer([&cdc_generation_service] { @@ -811,6 +817,12 @@ reader_permit make_reader_permit(cql_test_env& env) { return env.local_db().get_reader_concurrency_semaphore().make_tracking_only_permit(nullptr, "test", db::no_timeout); } +cql_test_config raft_cql_test_config() { + cql_test_config c; + c.db_config->experimental_features({db::experimental_features_t::RAFT}); + return c; +} + namespace debug { seastar::sharded* db; diff --git a/test/lib/cql_test_env.hh b/test/lib/cql_test_env.hh index 109c44aebb..2067898ad9 100644 --- a/test/lib/cql_test_env.hh +++ b/test/lib/cql_test_env.hh @@ -168,3 +168,6 @@ future<> do_with_cql_env(std::function(cql_test_env&)> func, cql_test_c future<> do_with_cql_env_thread(std::function func, cql_test_config = {}, thread_attributes thread_attr = {}); reader_permit make_reader_permit(cql_test_env&); + +// CQL test config with raft experimental feature enabled +cql_test_config raft_cql_test_config(); diff --git a/test/raft/raft_sys_table_storage_test.cc b/test/raft/raft_sys_table_storage_test.cc index 7fb82e0a7d..7fdda5cd7a 100644 --- a/test/raft/raft_sys_table_storage_test.cc +++ b/test/raft/raft_sys_table_storage_test.cc @@ -98,7 +98,7 @@ SEASTAR_TEST_CASE(test_store_load_term_and_vote) { BOOST_CHECK_EQUAL(vote_term, persisted.first); BOOST_CHECK_EQUAL(vote_id, persisted.second); - }); + }, raft_cql_test_config()); } SEASTAR_TEST_CASE(test_store_load_snapshot) { @@ -124,7 +124,7 @@ SEASTAR_TEST_CASE(test_store_load_snapshot) { raft::snapshot loaded_snp = co_await storage.load_snapshot(); BOOST_CHECK(snp == loaded_snp); - }); + }, raft_cql_test_config()); } SEASTAR_TEST_CASE(test_store_load_log_entries) { @@ -140,7 +140,7 @@ SEASTAR_TEST_CASE(test_store_load_log_entries) { for (size_t i = 0, end = entries.size(); i != end; ++i) { BOOST_CHECK(*entries[i] == *loaded_entries[i]); } - }); + }, raft_cql_test_config()); } SEASTAR_TEST_CASE(test_truncate_log) { @@ -158,7 +158,7 @@ SEASTAR_TEST_CASE(test_truncate_log) { for (size_t i = 0, end = loaded_entries.size(); i != end; ++i) { BOOST_CHECK(*entries[i] == *loaded_entries[i]); } - }); + }, raft_cql_test_config()); } SEASTAR_TEST_CASE(test_store_snapshot_truncate_log_tail) { @@ -189,5 +189,5 @@ SEASTAR_TEST_CASE(test_store_snapshot_truncate_log_tail) { for (size_t i = 0, end = loaded_entries.size(); i != end; ++i) { BOOST_CHECK(*entries[i + 1] == *loaded_entries[i]); } - }); + }, raft_cql_test_config()); }