From 8a4648761cffaa2ab06c3a4ddfae5e79dcd971a2 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Mon, 24 Aug 2015 13:12:09 +0300 Subject: [PATCH] tests: make test cql environment use volatile system keyspace Prevents hangs due to the database not being able to persist a memtable. Tested-by: Asias He --- database.cc | 2 +- database.hh | 4 ++-- db/config.hh | 1 + db/system_keyspace.cc | 8 ++++---- db/system_keyspace.hh | 2 +- tests/cql_test_env.cc | 1 + 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/database.cc b/database.cc index e466cb90f4..aec28236a7 100644 --- a/database.cc +++ b/database.cc @@ -666,7 +666,7 @@ database::database(const db::config& cfg) , _version(empty_version) { bool durable = cfg.data_file_directories().size() > 0; - db::system_keyspace::make(*this, durable); + db::system_keyspace::make(*this, durable, _cfg->volatile_system_keyspace_for_testing()); // Start compaction manager with two tasks for handling compaction jobs. _compaction_manager.start(2); setup_collectd(); diff --git a/database.hh b/database.hh index 216c71647f..41f7922a11 100644 --- a/database.hh +++ b/database.hh @@ -71,7 +71,7 @@ class commitlog; class config; namespace system_keyspace { -void make(database& db, bool durable); +void make(database& db, bool durable, bool volatile_testing_only); } } @@ -385,7 +385,7 @@ private: // not be using this directly. Go for the public create_keyspace instead. void add_keyspace(sstring name, keyspace k); void create_in_memory_keyspace(const lw_shared_ptr& ksm); - friend void db::system_keyspace::make(database& db, bool durable); + friend void db::system_keyspace::make(database& db, bool durable, bool volatile_testing_only); void setup_collectd(); public: static utils::UUID empty_version; diff --git a/db/config.hh b/db/config.hh index 6f256a678e..c39142d690 100644 --- a/db/config.hh +++ b/db/config.hh @@ -690,6 +690,7 @@ public: val(enable_in_memory_data_store, bool, false, Used, "Enable in memory mode (system tables are always persisted)") \ val(enable_cache, bool, true, Used, "Enable cache") \ val(enable_commitlog, bool, true, Used, "Enable commitlog") \ + val(volatile_system_keyspace_for_testing, bool, false, Used, "Don't persist system keyspace - testing only!") \ /* done! */ #define _make_value_member(name, type, deflt, status, desc, ...) \ diff --git a/db/system_keyspace.cc b/db/system_keyspace.cc index 7dd31e6569..91b6268af6 100644 --- a/db/system_keyspace.cc +++ b/db/system_keyspace.cc @@ -813,16 +813,16 @@ std::vector all_tables() { return r; } -void make(database& db, bool durable) { +void make(database& db, bool durable, bool volatile_testing_only) { auto ksm = make_lw_shared(NAME, "org.apache.cassandra.locator.LocalStrategy", std::map{}, durable ); auto kscfg = db.make_keyspace_config(*ksm); - kscfg.enable_disk_reads = true; - kscfg.enable_disk_writes = true; - kscfg.enable_commitlog = true; + kscfg.enable_disk_reads = !volatile_testing_only; + kscfg.enable_disk_writes = !volatile_testing_only; + kscfg.enable_commitlog = !volatile_testing_only; kscfg.enable_cache = true; keyspace _ks{ksm, std::move(kscfg)}; auto rs(locator::abstract_replication_strategy::create_replication_strategy(NAME, "LocalStrategy", service::get_local_storage_service().get_token_metadata(), ksm->strategy_options())); diff --git a/db/system_keyspace.hh b/db/system_keyspace.hh index 396e14a2be..76e84c4804 100644 --- a/db/system_keyspace.hh +++ b/db/system_keyspace.hh @@ -83,7 +83,7 @@ future<> remove_endpoint(gms::inet_address ep); future<> update_hints_dropped(gms::inet_address ep, utils::UUID time_period, int value); std::vector all_tables(); -void make(database& db, bool durable); +void make(database& db, bool durable, bool volatile_testing_only = false); future>> query_mutations(service::storage_proxy& proxy, const sstring& cf_name); diff --git a/tests/cql_test_env.cc b/tests/cql_test_env.cc index 07ff35ca59..731296b005 100644 --- a/tests/cql_test_env.cc +++ b/tests/cql_test_env.cc @@ -216,6 +216,7 @@ future<::shared_ptr> make_env_for_test() { return seastar::async([db] { auto cfg = make_lw_shared(); cfg->data_file_directories() = {}; + cfg->volatile_system_keyspace_for_testing() = true; db->start(std::move(*cfg)).get(); distributed& proxy = service::get_storage_proxy();