test: extract debug::the_database out

we want to integrate some perf test into scylla executable, so we
can run them on a regular basis. but `test/lib/cql_test_env.cc`
shares `debug::the_database` with `main.cc`, so we cannot just
compile them into a single binary without changing them.

before this change, both `test/lib/cql_test_env.cc`
and `main.cc` define `debug::the_database`.

after this change, `debug::the_database` is extracted into
`debug.cc`, so it compiles into a separate compiling unit.
and scylla and tests using seastar testing framework are linked
against `debug.cc` via `scylla_core` respectively. this paves the road to
integrating scylla with the tests linking aginst
`test/lib/cql_test_env.cc`.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
Kefu Chai
2023-01-18 21:01:50 +08:00
parent 965443d6be
commit c65692a13a
4 changed files with 17 additions and 8 deletions

View File

@@ -668,6 +668,7 @@ scylla_core = (['message/messaging_service.cc',
'caching_options.cc', 'caching_options.cc',
'collection_mutation.cc', 'collection_mutation.cc',
'client_data.cc', 'client_data.cc',
'debug.cc',
'hashers.cc', 'hashers.cc',
'schema.cc', 'schema.cc',
'frozen_schema.cc', 'frozen_schema.cc',

15
debug.cc Normal file
View File

@@ -0,0 +1,15 @@
/*
* Copyright (C) 2023-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include "debug.hh"
namespace debug {
seastar::sharded<replica::database>* the_database = nullptr;
}

View File

@@ -435,7 +435,6 @@ sharded<cql3::query_processor>* the_query_processor;
sharded<qos::service_level_controller>* the_sl_controller; sharded<qos::service_level_controller>* the_sl_controller;
sharded<service::migration_manager>* the_migration_manager; sharded<service::migration_manager>* the_migration_manager;
sharded<service::storage_service>* the_storage_service; sharded<service::storage_service>* the_storage_service;
sharded<replica::database>* the_database;
sharded<streaming::stream_manager> *the_stream_manager; sharded<streaming::stream_manager> *the_stream_manager;
sharded<gms::feature_service> *the_feature_service; sharded<gms::feature_service> *the_feature_service;
sharded<gms::gossiper> *the_gossiper; sharded<gms::gossiper> *the_gossiper;
@@ -1747,7 +1746,7 @@ static main_func_type lookup_main_func(std::string_view name) {
{"types", tools::scylla_types_main}, {"types", tools::scylla_types_main},
{"sstable", tools::scylla_sstable_main}, {"sstable", tools::scylla_sstable_main},
}; };
auto found = std::ranges::find_if(funcs, [name](auto& name_and_func) { auto found = std::ranges::find_if(funcs, [name] (auto& name_and_func) {
return name_and_func.first == name; return name_and_func.first == name;
}); });
if (found == std::end(funcs)) { if (found == std::end(funcs)) {

View File

@@ -973,9 +973,3 @@ cql_test_config raft_cql_test_config() {
c.db_config->consistent_cluster_management(true); c.db_config->consistent_cluster_management(true);
return c; return c;
} }
namespace debug {
seastar::sharded<replica::database>* the_database;
}