Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion test/common/stats/stat_test_utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,14 @@ class TestStore : public IsolatedStoreImpl {

class SymbolTableCreatorTestPeer {
public:
static void setUseFakeSymbolTables(bool use_fakes) {
~SymbolTableCreatorTestPeer() { SymbolTableCreator::setUseFakeSymbolTables(save_use_fakes_); }

void setUseFakeSymbolTables(bool use_fakes) {
SymbolTableCreator::setUseFakeSymbolTables(use_fakes);
}

private:
const bool save_use_fakes_{SymbolTableCreator::useFakeSymbolTables()};
};

// Serializes a number into a uint8_t array, and check that it de-serializes to
Expand Down
7 changes: 5 additions & 2 deletions test/common/stats/stat_test_utility_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ namespace {
class StatTestUtilityTest : public testing::Test {
protected:
StatTestUtilityTest()
: symbol_table_(SymbolTableCreator::initAndMakeSymbolTable(false)),
test_store_(*symbol_table_), dynamic_(*symbol_table_), symbolic_(*symbol_table_) {}
: symbol_table_(SymbolTableCreator::makeSymbolTable()), test_store_(*symbol_table_),
dynamic_(*symbol_table_), symbolic_(*symbol_table_) {
symbol_table_creator_test_peer_.setUseFakeSymbolTables(false);
}

TestUtil::SymbolTableCreatorTestPeer symbol_table_creator_test_peer_;
SymbolTablePtr symbol_table_;
TestUtil::TestStore test_store_;
StatNameDynamicPool dynamic_;
Expand Down
7 changes: 2 additions & 5 deletions test/common/stats/thread_local_store_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -908,18 +908,15 @@ TEST_F(StatsThreadLocalStoreTest, NonHotRestartNoTruncation) {

class StatsThreadLocalStoreTestNoFixture : public testing::Test {
protected:
StatsThreadLocalStoreTestNoFixture()
: save_use_fakes_(SymbolTableCreator::useFakeSymbolTables()) {}
~StatsThreadLocalStoreTestNoFixture() override {
TestUtil::SymbolTableCreatorTestPeer::setUseFakeSymbolTables(save_use_fakes_);
if (threading_enabled_) {
store_->shutdownThreading();
tls_.shutdownThread();
}
}

void init(bool use_fakes) {
TestUtil::SymbolTableCreatorTestPeer::setUseFakeSymbolTables(use_fakes);
symbol_table_creator_test_peer_.setUseFakeSymbolTables(use_fakes);
symbol_table_ = SymbolTableCreator::makeSymbolTable();
alloc_ = std::make_unique<AllocatorImpl>(*symbol_table_);
store_ = std::make_unique<ThreadLocalStoreImpl>(*alloc_);
Expand All @@ -943,7 +940,7 @@ class StatsThreadLocalStoreTestNoFixture : public testing::Test {
std::unique_ptr<ThreadLocalStoreImpl> store_;
NiceMock<Event::MockDispatcher> main_thread_dispatcher_;
NiceMock<ThreadLocal::MockInstance> tls_;
const bool save_use_fakes_;
TestUtil::SymbolTableCreatorTestPeer symbol_table_creator_test_peer_;
bool threading_enabled_{false};
};

Expand Down
3 changes: 2 additions & 1 deletion test/integration/integration_admin_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ std::string ContentType(const BufferingStreamDecoderPtr& response) {
} // namespace

TEST_P(IntegrationAdminTest, Admin) {
Stats::TestUtil::SymbolTableCreatorTestPeer::setUseFakeSymbolTables(false);
Stats::TestUtil::SymbolTableCreatorTestPeer symbol_table_creator_test_peer;
symbol_table_creator_test_peer.setUseFakeSymbolTables(false);
initialize();

BufferingStreamDecoderPtr response;
Expand Down
14 changes: 4 additions & 10 deletions test/integration/stats_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,21 +206,15 @@ class ClusterMemoryTestHelper : public BaseIntegrationTest {
};
class ClusterMemoryTestRunner : public testing::TestWithParam<Network::Address::IpVersion> {
protected:
ClusterMemoryTestRunner() : save_use_fakes_(Stats::SymbolTableCreator::useFakeSymbolTables()) {}
~ClusterMemoryTestRunner() override {
Stats::TestUtil::SymbolTableCreatorTestPeer::setUseFakeSymbolTables(save_use_fakes_);
}

private:
const bool save_use_fakes_;
Stats::TestUtil::SymbolTableCreatorTestPeer symbol_table_creator_test_peer_;
};

INSTANTIATE_TEST_SUITE_P(IpVersions, ClusterMemoryTestRunner,
testing::ValuesIn(TestEnvironment::getIpVersionsForTest()),
TestUtility::ipTestParamsToString);

TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithFakeSymbolTable) {
Stats::TestUtil::SymbolTableCreatorTestPeer::setUseFakeSymbolTables(true);
symbol_table_creator_test_peer_.setUseFakeSymbolTables(true);

// A unique instance of ClusterMemoryTest allows for multiple runs of Envoy with
// differing configuration. This is necessary for measuring the memory consumption
Expand Down Expand Up @@ -291,7 +285,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithFakeSymbolTable) {
}

TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithRealSymbolTable) {
Stats::TestUtil::SymbolTableCreatorTestPeer::setUseFakeSymbolTables(false);
symbol_table_creator_test_peer_.setUseFakeSymbolTables(false);

// A unique instance of ClusterMemoryTest allows for multiple runs of Envoy with
// differing configuration. This is necessary for measuring the memory consumption
Expand Down Expand Up @@ -345,7 +339,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithRealSymbolTable) {
}

TEST_P(ClusterMemoryTestRunner, MemoryLargeHostSizeWithStats) {
Stats::TestUtil::SymbolTableCreatorTestPeer::setUseFakeSymbolTables(false);
symbol_table_creator_test_peer_.setUseFakeSymbolTables(false);

// A unique instance of ClusterMemoryTest allows for multiple runs of Envoy with
// differing configuration. This is necessary for measuring the memory consumption
Expand Down
3 changes: 3 additions & 0 deletions test/server/http/admin_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,9 @@ class PrometheusStatsFormatterTest : public testing::Test {

void clearStorage() {
pool_.clear();
counters_.clear();
gauges_.clear();
histograms_.clear();
EXPECT_EQ(0, symbol_table_->numSymbols());
}

Expand Down
5 changes: 4 additions & 1 deletion test/server/server_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,11 @@ TEST_P(ServerInstanceImplTest, Stats) {
class TestWithSimTimeAndRealSymbolTables : public Event::TestUsingSimulatedTime {
protected:
TestWithSimTimeAndRealSymbolTables() {
Stats::TestUtil::SymbolTableCreatorTestPeer::setUseFakeSymbolTables(false);
symbol_table_creator_test_peer_.setUseFakeSymbolTables(false);
}

private:
Stats::TestUtil::SymbolTableCreatorTestPeer symbol_table_creator_test_peer_;
};

class ServerStatsTest
Expand Down