To reduce test executable size and speed up compilation time, compile unit tests into a single executable. Here is a file size comparison of the unit test executable: - Before applying the patch $ du -h --exclude='*.o' --exclude='*.o.d' build/release/test/boost/ build/debug/test/boost/ 11G build/release/test/boost/ 29G build/debug/test/boost/ - After applying the patch du -h --exclude='*.o' --exclude='*.o.d' build/release/test/boost/ build/debug/test/boost/ 5.5G build/release/test/boost/ 19G build/debug/test/boost/ It reduces executable sizes 5.5GB on release, and 10GB on debug. Closes #9155 Closes scylladb/scylladb#21443
88 lines
3.1 KiB
C++
88 lines
3.1 KiB
C++
/*
|
|
* Copyright (C) 2020-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#undef SEASTAR_TESTING_MAIN
|
|
#include <seastar/testing/test_case.hh>
|
|
|
|
#include "tracing/tracing.hh"
|
|
#include "tracing/trace_state.hh"
|
|
|
|
#include "test/lib/cql_test_env.hh"
|
|
|
|
BOOST_AUTO_TEST_SUITE(tracing_test)
|
|
|
|
future<> do_with_tracing_env(std::function<future<>(cql_test_env&)> func, cql_test_config cfg_in = {}) {
|
|
return do_with_cql_env_thread([func](auto &env) {
|
|
sharded<tracing::tracing>& tracing = tracing::tracing::tracing_instance();
|
|
tracing.start(sstring("trace_keyspace_helper")).get();
|
|
auto stop = defer([&tracing] { tracing.stop().get(); });
|
|
tracing.invoke_on_all(&tracing::tracing::start, std::ref(env.qp()), std::ref(env.migration_manager())).get();
|
|
func(env).get();
|
|
}, std::move(cfg_in));
|
|
}
|
|
|
|
SEASTAR_TEST_CASE(tracing_respect_events) {
|
|
return do_with_tracing_env([](auto &e) {
|
|
tracing::tracing &t = tracing::tracing::get_local_tracing_instance();
|
|
|
|
t.set_ignore_trace_events(false);
|
|
BOOST_CHECK(!t.ignore_trace_events_enabled());
|
|
|
|
// create session
|
|
tracing::trace_state_props_set trace_props;
|
|
trace_props.set(tracing::trace_state_props::log_slow_query);
|
|
trace_props.set(tracing::trace_state_props::full_tracing);
|
|
|
|
tracing::trace_state_ptr trace_state1 = t.create_session(tracing::trace_type::QUERY, trace_props);
|
|
tracing::begin(trace_state1, "begin", gms::inet_address());
|
|
|
|
tracing::trace(trace_state1, "trace 1");
|
|
BOOST_CHECK_EQUAL(trace_state1->events_size(), 1);
|
|
BOOST_CHECK(tracing::make_trace_info(trace_state1) != std::nullopt);
|
|
|
|
// disable tracing events, it must be ignored for full tracing
|
|
t.set_ignore_trace_events(true);
|
|
BOOST_CHECK(t.ignore_trace_events_enabled());
|
|
|
|
tracing::trace_state_ptr trace_state2 = t.create_session(tracing::trace_type::QUERY, trace_props);
|
|
tracing::begin(trace_state2, "begin", gms::inet_address());
|
|
|
|
tracing::trace(trace_state2, "trace 1");
|
|
BOOST_CHECK_EQUAL(trace_state2->events_size(), 1);
|
|
BOOST_CHECK(tracing::make_trace_info(trace_state2) != std::nullopt);
|
|
|
|
return make_ready_future<>();
|
|
});
|
|
}
|
|
|
|
SEASTAR_TEST_CASE(tracing_slow_query_fast_mode) {
|
|
return do_with_tracing_env([](auto &e) {
|
|
tracing::tracing &t = tracing::tracing::get_local_tracing_instance();
|
|
|
|
// disable tracing events
|
|
t.set_ignore_trace_events(true);
|
|
BOOST_CHECK(t.ignore_trace_events_enabled());
|
|
|
|
// create session
|
|
tracing::trace_state_props_set trace_props;
|
|
trace_props.set(tracing::trace_state_props::log_slow_query);
|
|
|
|
tracing::trace_state_ptr trace_state = t.create_session(tracing::trace_type::QUERY, trace_props);
|
|
tracing::begin(trace_state, "begin", gms::inet_address());
|
|
|
|
// check no event created
|
|
tracing::trace(trace_state, "trace 1");
|
|
BOOST_CHECK_EQUAL(trace_state->events_size(), 0);
|
|
BOOST_CHECK(tracing::make_trace_info(trace_state) == std::nullopt);
|
|
|
|
return make_ready_future<>();
|
|
});
|
|
}
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|