diff options
author | Tor Brede Vekterli <vekterli@vespa.ai> | 2024-04-10 09:36:36 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@vespa.ai> | 2024-04-10 09:36:36 +0000 |
commit | e5597498f44f5e34d87c64fcbd8d6643417e7baf (patch) | |
tree | bca9ba5eed9876f785787d7d473b6c75c549dabf | |
parent | 32df7bf1195fd3c90a77efb1aa7311e4655c1737 (diff) |
Ensure SetUp/TearDown symmetry with test superclass
Can't initialize members in constructor that depend on objects
that are subsequently reset by the superclass' `SetUp()` method.
-rw-r--r-- | storage/src/tests/persistence/active_operations_stats_test.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/storage/src/tests/persistence/active_operations_stats_test.cpp b/storage/src/tests/persistence/active_operations_stats_test.cpp index bf91a84235a..71be34e3f54 100644 --- a/storage/src/tests/persistence/active_operations_stats_test.cpp +++ b/storage/src/tests/persistence/active_operations_stats_test.cpp @@ -28,6 +28,8 @@ public: std::shared_ptr<api::StorageMessage> createPut(uint64_t bucket, uint64_t docIdx); std::shared_ptr<api::StorageMessage> createGet(uint64_t bucket) const; + void SetUp() override; + void TearDown() override; void assert_active_operations_stats(const ActiveOperationsStats &stats, uint32_t exp_active_size, uint32_t exp_size_samples, uint32_t exp_latency_samples); void update_metrics(); void test_active_operations_stats(); @@ -41,16 +43,30 @@ ActiveOperationsStatsTest::ActiveOperationsStatsTest() metrics(), stripeId(0) { + // Initialization of members must happen in SetUp() since this test transitively + // depends on components modified by the superclass' SetUp() method. +} + +void +ActiveOperationsStatsTest::SetUp() +{ + FileStorTestFixture::SetUp(); setupPersistenceThreads(1); _node->setPersistenceProvider(std::make_unique<spi::dummy::DummyPersistence>(_node->getTypeRepo())); top.push_back(std::move(dummyManager)); top.open(); metrics.initDiskMetrics(1, 1); - filestorHandler = std::make_unique<FileStorHandlerImpl>(messageSender, metrics, - _node->getComponentRegister()); + filestorHandler = std::make_unique<FileStorHandlerImpl>(messageSender, metrics, _node->getComponentRegister()); filestorHandler->setGetNextMessageTimeout(20ms); } +void +ActiveOperationsStatsTest::TearDown() +{ + filestorHandler.reset(); + FileStorTestFixture::TearDown(); +} + ActiveOperationsStatsTest::~ActiveOperationsStatsTest() = default; std::shared_ptr<api::StorageMessage> |