From 324061e5b2195ca51864b5a13360e4897ae72840 Mon Sep 17 00:00:00 2001 From: Dmitrii Petukhov Date: Tue, 15 Oct 2024 00:14:41 +0300 Subject: [PATCH] Refactor Tester classes and Test classes: removed bloated classes structure Signed-off-by: Dmitrii Petukhov --- .../mqb/mqbs/mqbs_filebackedstorage.t.cpp | 345 +++++++----------- 1 file changed, 129 insertions(+), 216 deletions(-) diff --git a/src/groups/mqb/mqbs/mqbs_filebackedstorage.t.cpp b/src/groups/mqb/mqbs/mqbs_filebackedstorage.t.cpp index 56335f5e1..9a6422e56 100644 --- a/src/groups/mqb/mqbs/mqbs_filebackedstorage.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_filebackedstorage.t.cpp @@ -102,12 +102,14 @@ namespace { const int k_PARTITION_ID = 1; const int k_PROXY_PARTITION_ID = mqbs::DataStore::k_INVALID_PARTITION_ID; const char k_HEX_QUEUE[] = "ABCDEF1234"; -const bsls::Types::Int64 k_DEFAULT_MSG = 20; -const bsls::Types::Int64 k_DEFAULT_BYTES = 2048; -const char k_URI_STR[] = "bmq://mydomain/testqueue"; -const char k_APP_ID1[] = "app1"; -const char k_APP_ID2[] = "app2"; -const char k_APP_ID3[] = "app3"; +const bsls::Types::Int64 k_DEFAULT_MSG = 20; +const bsls::Types::Int64 k_DEFAULT_BYTES = 2048; +const double k_MSG_WATERMARK_RATIO = 0.8; +const double k_BYTE_WATERMARK_RATIO = 0.8; +const char k_URI_STR[] = "bmq://mydomain/testqueue"; +const char k_APP_ID1[] = "app1"; +const char k_APP_ID2[] = "app2"; +const char k_APP_ID3[] = "app3"; const mqbu::StorageKey k_QUEUE_KEY(mqbu::StorageKey::HexRepresentation(), k_HEX_QUEUE); const mqbu::StorageKey k_APP_KEY1(mqbu::StorageKey::HexRepresentation(), @@ -451,7 +453,7 @@ class MockDataStore : public mqbs::DataStore { return sizeof(int); } - unsigned int primaryLeaseId() const BSLS_KEYWORD_OVERRIDE { return 0; } + unsigned int primaryLeaseId() const BSLS_KEYWORD_OVERRIDE { return 0U; } bool hasReceipt(const mqbs::DataStoreRecordHandle&) const BSLS_KEYWORD_OVERRIDE @@ -460,18 +462,18 @@ class MockDataStore : public mqbs::DataStore { } }; -// ================= -// struct BaseTester -// ================= +// ============= +// struct Tester +// ============= -/// BaseTester class provides testing capabilities to verify both +/// Tester class provides testing capabilities to verify both /// FileBackedStorage and InMemoryStorage -struct BaseTester { +struct Tester { private: // PRIVATE TYPES typedef mqbs::DataStoreConfig::Records Records; - protected: + private: // DATA bdlbb::PooledBlobBufferFactory d_bufferFactory; mqbmock::Cluster d_mockCluster; @@ -481,10 +483,15 @@ struct BaseTester { bslma::ManagedPtr d_replicatedStorage_mp; Records d_records; bslma::Allocator* d_allocator_p; + MockDataStore d_dataStore; public: // CREATORS - explicit BaseTester(bslma::Allocator* allocator) + Tester(bslma::Allocator* allocator, + int partitionId = k_PARTITION_ID, + const bslstl::StringRef& uri = k_URI_STR, + const mqbu::StorageKey& queueKey = k_QUEUE_KEY, + bsls::Types::Int64 ttlSeconds = k_INT64_MAX) : d_bufferFactory(1024, allocator) , d_mockCluster(&d_bufferFactory, allocator) , d_mockDomain(&d_mockCluster, allocator) @@ -493,34 +500,41 @@ struct BaseTester { , d_replicatedStorage_mp() , d_records(allocator) , d_allocator_p(allocator) + , d_dataStore(allocator, partitionId) { d_mockDomain.capacityMeter()->setLimits(k_INT64_MAX, k_INT64_MAX); d_mockQueue._setQueueEngine(&d_mockQueueEngine); + + mqbconfm::Domain domainCfg; + domainCfg.deduplicationTimeMs() = 0; // No history + domainCfg.messageTtl() = ttlSeconds; + + d_replicatedStorage_mp.load( + new (*d_allocator_p) + mqbs::FileBackedStorage(&d_dataStore, + bmqt::Uri(uri, s_allocator_p), + queueKey, + domainCfg, + d_mockDomain.capacityMeter(), + d_allocator_p), + d_allocator_p); + + d_replicatedStorage_mp->setQueue(&d_mockQueue); + BSLS_ASSERT_OPT(d_replicatedStorage_mp->queue() == &d_mockQueue); } - ~BaseTester() + ~Tester() { d_replicatedStorage_mp->removeAll(k_NULL_KEY); d_replicatedStorage_mp->close(); } // MANIPULATORS - void setupReplicatedStorage(bsls::Types::Int64 ttlSeconds, - bool toConfigure) - { - d_replicatedStorage_mp->setQueue(&d_mockQueue); - BSLS_ASSERT_OPT(d_replicatedStorage_mp->queue() == &d_mockQueue); - - if (toConfigure) { - configure(k_DEFAULT_MSG, k_DEFAULT_BYTES, 0.8, 0.8, ttlSeconds); - } - } - - int configure(bsls::Types::Int64 msgCapacity, - bsls::Types::Int64 byteCapacity, - double msgWatermarkRatio = 0.8, - double byteWatermarkRatio = 0.8, - bsls::Types::Int64 messageTtl = k_INT64_MAX) + int configure(bsls::Types::Int64 msgCapacity = k_DEFAULT_MSG, + bsls::Types::Int64 byteCapacity = k_DEFAULT_BYTES, + double msgWatermarkRatio = k_MSG_WATERMARK_RATIO, + double byteWatermarkRatio = k_BYTE_WATERMARK_RATIO, + bsls::Types::Int64 messageTtl = k_INT64_MAX) { // PRECONDITIONS BSLS_ASSERT_OPT(d_replicatedStorage_mp && "Storage was not created"); @@ -630,84 +644,14 @@ struct BaseTester { recordItRef = insertRc.first; } - private: - // NOT IMPLEMENTED - BaseTester(const BaseTester&) BSLS_KEYWORD_DELETED; - BaseTester& operator=(const BaseTester&) BSLS_KEYWORD_DELETED; -}; - -// ============= -// struct Tester -// ============= -struct Tester : public BaseTester { - MockDataStore d_dataStore; - - public: - Tester(const bslstl::StringRef& uri, - const mqbu::StorageKey& queueKey, - int partitionId, - bsls::Types::Int64 ttlSeconds, - bslma::Allocator* allocator, - bool toConfigure = false) - : BaseTester(allocator) - , d_dataStore(allocator, partitionId) - { - mqbconfm::Domain domainCfg; - domainCfg.deduplicationTimeMs() = 0; // No history - domainCfg.messageTtl() = ttlSeconds; - - d_replicatedStorage_mp.load( - new (*d_allocator_p) - mqbs::FileBackedStorage(&d_dataStore, - bmqt::Uri(uri, s_allocator_p), - queueKey, - domainCfg, - d_mockDomain.capacityMeter(), - d_allocator_p), - d_allocator_p); - - setupReplicatedStorage(ttlSeconds, toConfigure); - } - const MockDataStore& dataStore() { return d_dataStore; } -}; - -// ================ -// struct BasicTest -// ================ - -/// Fixture instantiating a tester of `mqbs::FileBackedStorage` having not yet -/// configured the storage with a storage configuration. -struct BasicTest : mwctst::Test { - // PUBLIC DATA - Tester d_tester; - // CREATORS - BasicTest(); - ~BasicTest() BSLS_KEYWORD_OVERRIDE; + private: + // NOT IMPLEMENTED + Tester(const Tester&) BSLS_KEYWORD_DELETED; + Tester& operator=(const Tester&) BSLS_KEYWORD_DELETED; }; -// ---------------- -// struct BasicTest -// ---------------- - -// CREATORS -BasicTest::BasicTest() -: d_tester(k_URI_STR, - k_QUEUE_KEY, - k_PROXY_PARTITION_ID, - k_INT64_MAX, // ttlSeconds - s_allocator_p, - false) // toConfigure -{ - // NOTHING -} - -BasicTest::~BasicTest() -{ - // NOTHING -} - // =========== // struct Test // =========== @@ -728,14 +672,14 @@ struct Test : mwctst::Test { // ----------- // CREATORS Test::Test() -: d_tester(k_URI_STR, - k_QUEUE_KEY, +: d_tester(s_allocator_p, k_PARTITION_ID, - k_INT64_MAX, // ttlSeconds - s_allocator_p, - true) // toConfigure + k_URI_STR, + k_QUEUE_KEY, + k_INT64_MAX // ttlSeconds + ) { - // NOTHING + d_tester.configure(); } Test::~Test() @@ -743,65 +687,13 @@ Test::~Test() // NOTHING } -// ============= -// struct GCTest -// ============= - -/// Fixture instantiating a tester of `mqbs::FileBackedStorage` instantiated -/// with parameterized `TTL` and having already configured the storage with -/// an FileBackedStorage configuration. -struct GCTest : mwctst::Test { - // PUBLIC DATA - bsls::ObjectBuffer d_testerBuffer; - - // CREATORS - GCTest(); - ~GCTest() BSLS_KEYWORD_OVERRIDE; - - // MANIPULATORS - void configure(bsls::Types::Int64 ttlSeconds); - - Tester& tester(); -}; - -// ------------- -// struct GCTest -// ------------- -// CREATORS -GCTest::GCTest() -: d_testerBuffer() -{ - // NOTHING -} - -GCTest::~GCTest() -{ - d_testerBuffer.object().~Tester(); -} - -// MANIPULATORS -void GCTest::configure(bsls::Types::Int64 ttlSeconds) -{ - new (d_testerBuffer.buffer()) Tester(k_URI_STR, - k_QUEUE_KEY, - k_PARTITION_ID, - ttlSeconds, - s_allocator_p, - true); // toConfigure -} - -Tester& GCTest::tester() -{ - return d_testerBuffer.object(); -} - } // close unnamed namespace // ============================================================================ // TESTS // ---------------------------------------------------------------------------- -TEST_F(BasicTest, breathingTest) +TEST(breathingTest) // ------------------------------------------------------------------------ // BREATHING TEST // @@ -816,7 +708,9 @@ TEST_F(BasicTest, breathingTest) { mwctst::TestHelper::printTestName("BREATHING TEST"); - mqbs::ReplicatedStorage& storage = d_tester.storage(); + Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + + mqbs::ReplicatedStorage& storage = tester.storage(); ASSERT_EQ(storage.queueUri().asString(), k_URI_STR); ASSERT_EQ(storage.queueKey(), k_QUEUE_KEY); @@ -835,7 +729,7 @@ TEST_F(BasicTest, breathingTest) ASSERT_EQ(storage.queueOpRecordHandles().empty(), true); } -TEST_F(BasicTest, configure) +TEST(configure) // ------------------------------------------------------------------------ // CONFIGURE // @@ -851,14 +745,16 @@ TEST_F(BasicTest, configure) { mwctst::TestHelper::printTestName("CONFIGURE"); - ASSERT_EQ(d_tester.configure(k_DEFAULT_MSG, k_DEFAULT_BYTES), 0); + Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); - mqbs::ReplicatedStorage& storage = d_tester.storage(); + BSLS_ASSERT_OPT(tester.configure(k_DEFAULT_MSG, k_DEFAULT_BYTES) == 0); + + mqbs::ReplicatedStorage& storage = tester.storage(); ASSERT_EQ(storage.capacityMeter()->byteCapacity(), k_DEFAULT_BYTES); ASSERT_EQ(storage.config(), fileBackedStorageConfig()); - ASSERT_EQ(d_tester.configure(k_DEFAULT_MSG, k_DEFAULT_BYTES + 5), 0); + ASSERT_EQ(tester.configure(k_DEFAULT_MSG, k_DEFAULT_BYTES + 5), 0); ASSERT_EQ(storage.capacityMeter()->byteCapacity(), k_DEFAULT_BYTES + 5); ASSERT_EQ(storage.config(), fileBackedStorageConfig()); } @@ -1230,7 +1126,7 @@ TEST_F(Test, removeVirtualStorage) ASSERT_EQ(storage.numVirtualStorages(), 0); } -TEST_F(BasicTest, put_withVirtualStorages) +TEST(put_withVirtualStorages) // ------------------------------------------------------------------------ // Put Test with virtual storages // @@ -1247,15 +1143,16 @@ TEST_F(BasicTest, put_withVirtualStorages) mwcu::MemOutStream errDescription(s_allocator_p); - int rc = d_tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT); - BSLS_ASSERT_OPT(rc == 0); + Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); - mqbs::ReplicatedStorage& storage = d_tester.storage(); + BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); + + mqbs::ReplicatedStorage& storage = tester.storage(); - rc = storage.addVirtualStorage(errDescription, k_APP_ID1, k_APP_KEY1); - BSLS_ASSERT_OPT(rc == 0); - rc = storage.addVirtualStorage(errDescription, k_APP_ID2, k_APP_KEY2); - BSLS_ASSERT_OPT(rc == 0); + BSLS_ASSERT_OPT( + storage.addVirtualStorage(errDescription, k_APP_ID1, k_APP_KEY1) == 0); + BSLS_ASSERT_OPT( + storage.addVirtualStorage(errDescription, k_APP_ID2, k_APP_KEY2) == 0); // Scenario: // Two Virtual Storages. @@ -1269,7 +1166,7 @@ TEST_F(BasicTest, put_withVirtualStorages) bsl::vector guids(s_allocator_p); // Check 'put'- To physical storage (StorageKeys = NULL) - ASSERT_EQ(d_tester.addMessages(&guids, k_MSG_COUNT), + ASSERT_EQ(tester.addMessages(&guids, k_MSG_COUNT), mqbi::StorageResult::e_SUCCESS); // Verify number of messages for each Virtual storage @@ -1297,7 +1194,7 @@ TEST_F(BasicTest, put_withVirtualStorages) mqbi::StorageResult::e_SUCCESS); } -TEST_F(BasicTest, removeAllMessages_appKeyNotFound) +TEST(removeAllMessages_appKeyNotFound) // ------------------------------------------------------------------------ // REMOVE ALL MESSAGES - APPKEY NOT FOUND // @@ -1315,9 +1212,11 @@ TEST_F(BasicTest, removeAllMessages_appKeyNotFound) const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - BSLS_ASSERT_OPT(d_tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); + Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); - mqbs::ReplicatedStorage& storage = d_tester.storage(); + BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); + + mqbs::ReplicatedStorage& storage = tester.storage(); BSLS_ASSERT_OPT( storage.addVirtualStorage(errDescription, k_APP_ID1, k_APP_KEY1) == 0); @@ -1333,7 +1232,7 @@ TEST_F(BasicTest, removeAllMessages_appKeyNotFound) sizeof(int)); bsl::vector guids(s_allocator_p); - d_tester.addMessages(&guids, k_MSG_COUNT); + tester.addMessages(&guids, k_MSG_COUNT); // Verify 'removeAll' operation BSLS_ASSERT_OPT(storage.numMessages(k_NULL_KEY) == k_MSG_COUNT_INT64); @@ -1346,7 +1245,7 @@ TEST_F(BasicTest, removeAllMessages_appKeyNotFound) mqbi::StorageResult::e_APPKEY_NOT_FOUND); } -TEST_F(BasicTest, removeAllMessages) +TEST(removeAllMessages) // ------------------------------------------------------------------------ // RemoveAll Messages Test // @@ -1363,9 +1262,11 @@ TEST_F(BasicTest, removeAllMessages) const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - BSLS_ASSERT_OPT(d_tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); + Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); - mqbs::ReplicatedStorage& storage = d_tester.storage(); + BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); + + mqbs::ReplicatedStorage& storage = tester.storage(); BSLS_ASSERT_OPT( storage.addVirtualStorage(errDescription, k_APP_ID1, k_APP_KEY1) == 0); @@ -1383,7 +1284,7 @@ TEST_F(BasicTest, removeAllMessages) bsl::vector guids(s_allocator_p); - ASSERT_EQ(d_tester.addMessages(&guids, k_MSG_COUNT), + ASSERT_EQ(tester.addMessages(&guids, k_MSG_COUNT), mqbi::StorageResult::e_SUCCESS); // Verify 'removeAll' operation @@ -1409,7 +1310,7 @@ TEST_F(BasicTest, removeAllMessages) ASSERT_EQ(storage.numBytes(mqbu::StorageKey::k_NULL_KEY), 0); } -TEST_F(BasicTest, get_withVirtualStorages) +TEST(get_withVirtualStorages) // ------------------------------------------------------------------------ // Get Test With virtual storages // @@ -1425,9 +1326,11 @@ TEST_F(BasicTest, get_withVirtualStorages) const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - BSLS_ASSERT_OPT(d_tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); + Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); - mqbs::ReplicatedStorage& storage = d_tester.storage(); + BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); + + mqbs::ReplicatedStorage& storage = tester.storage(); storage.addVirtualStorage(errDescription, k_APP_ID1, k_APP_KEY1); @@ -1437,8 +1340,7 @@ TEST_F(BasicTest, get_withVirtualStorages) bsl::vector guids(s_allocator_p); // Check 'put'- To physical storage (StorageKeys = NULL) - ASSERT_EQ(d_tester.addMessages(&guids, 20), - mqbi::StorageResult::e_SUCCESS); + ASSERT_EQ(tester.addMessages(&guids, 20), mqbi::StorageResult::e_SUCCESS); // Verify 'get' operation mqbi::StorageMessageAttributes attributes; @@ -1466,7 +1368,7 @@ TEST_F(BasicTest, get_withVirtualStorages) mqbi::StorageResult::e_SUCCESS); } -TEST_F(BasicTest, confirm) +TEST(confirm) // ------------------------------------------------------------------------ // RELEASE REF // @@ -1482,9 +1384,11 @@ TEST_F(BasicTest, confirm) mwcu::MemOutStream errDescription(s_allocator_p); - BSLS_ASSERT_OPT(d_tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); + Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); - mqbs::ReplicatedStorage& storage = d_tester.storage(); + BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); + + mqbs::ReplicatedStorage& storage = tester.storage(); storage.addVirtualStorage(errDescription, k_APP_ID1, k_APP_KEY1); @@ -1504,11 +1408,11 @@ TEST_F(BasicTest, confirm) bsl::vector guids(s_allocator_p); // Check 'put': To physical storage (StorageKeys = NULL) - ASSERT_EQ(d_tester.addMessages(&guids, - k_MSG_COUNT, - dataOffset, - useSameGuids, - defaultRefCount), + ASSERT_EQ(tester.addMessages(&guids, + k_MSG_COUNT, + dataOffset, + useSameGuids, + defaultRefCount), mqbi::StorageResult::e_SUCCESS); mqbi::StorageMessageAttributes attributes; @@ -1618,7 +1522,7 @@ TEST_F(Test, getIterator_noVirtualStorages) mqbi::StorageResult::e_SUCCESS); } -TEST_F(BasicTest, getIterator_withVirtualStorages) +TEST(getIterator_withVirtualStorages) // ------------------------------------------------------------------------ // Iterator Test // @@ -1634,9 +1538,11 @@ TEST_F(BasicTest, getIterator_withVirtualStorages) const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - BSLS_ASSERT_OPT(d_tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); + Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); - mqbs::ReplicatedStorage& storage = d_tester.storage(); + BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); + + mqbs::ReplicatedStorage& storage = tester.storage(); storage.addVirtualStorage(errDescription, k_APP_ID1, k_APP_KEY1); storage.addVirtualStorage(errDescription, k_APP_ID2, k_APP_KEY2); @@ -1648,13 +1554,12 @@ TEST_F(BasicTest, getIterator_withVirtualStorages) bsl::vector guids(s_allocator_p); // Check 'put': To physical storage (StorageKeys = NULL) - ASSERT_EQ(d_tester.addMessages(&guids, 20), - mqbi::StorageResult::e_SUCCESS); + ASSERT_EQ(tester.addMessages(&guids, 20), mqbi::StorageResult::e_SUCCESS); - ASSERT_EQ(d_tester.addMessages(&guids, 20, 20), + ASSERT_EQ(tester.addMessages(&guids, 20, 20), mqbi::StorageResult::e_SUCCESS); - ASSERT_EQ(d_tester.addMessages(&guids, 20, 40), + ASSERT_EQ(tester.addMessages(&guids, 20, 40), mqbi::StorageResult::e_SUCCESS); // Check Iterator @@ -1761,7 +1666,7 @@ TEST_F(Test, capacityMeter_limitMessages) ASSERT_EQ(storage.capacityMeter()->messages(), 0); } -TEST_F(BasicTest, capacityMeter_limitBytes) +TEST(capacityMeter_limitBytes) // ------------------------------------------------------------------------ // Capacity Meter Test // @@ -1775,24 +1680,26 @@ TEST_F(BasicTest, capacityMeter_limitBytes) const bsls::Types::Int64 k_MSG_LIMIT = 30; const bsls::Types::Int64 k_BYTES_LIMIT = 80; - BSLS_ASSERT_OPT(d_tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); + Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + + BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); bsl::vector guids(s_allocator_p); // Insert Max messages possible in 80bytes const int k_MSG_COUNT = 20; - ASSERT_EQ(d_tester.addMessages(&guids, k_MSG_COUNT), + ASSERT_EQ(tester.addMessages(&guids, k_MSG_COUNT), mqbi::StorageResult::e_SUCCESS); // Try to insert more than Capacity Meter - Check success first time - ASSERT_EQ(d_tester.addMessages(&guids, 1), mqbi::StorageResult::e_SUCCESS); + ASSERT_EQ(tester.addMessages(&guids, 1), mqbi::StorageResult::e_SUCCESS); - mqbs::ReplicatedStorage& storage = d_tester.storage(); + mqbs::ReplicatedStorage& storage = tester.storage(); ASSERT_EQ(storage.capacityMeter()->bytes(), 84); // Try to insert more than Capacity Meter, check failure after it's full - ASSERT_EQ(d_tester.addMessages(&guids, 1), + ASSERT_EQ(tester.addMessages(&guids, 1), mqbi::StorageResult::e_LIMIT_BYTES); ASSERT_EQ(storage.removeAll(mqbu::StorageKey::k_NULL_KEY), @@ -1800,7 +1707,7 @@ TEST_F(BasicTest, capacityMeter_limitBytes) ASSERT_EQ(storage.capacityMeter()->bytes(), 0); } -TEST_F(GCTest, garbageCollect) +TEST(garbageCollect) // ------------------------------------------------------------------------ // GARBAGE COLLECT // @@ -1816,7 +1723,13 @@ TEST_F(GCTest, garbageCollect) // input const int k_TTL = 20; - configure(k_TTL); + Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + + BSLS_ASSERT_OPT(tester.configure(k_DEFAULT_MSG, + k_DEFAULT_BYTES, + k_MSG_WATERMARK_RATIO, + k_BYTE_WATERMARK_RATIO, + k_TTL) == 0); bsl::vector guids(s_allocator_p); @@ -1824,14 +1737,14 @@ TEST_F(GCTest, garbageCollect) // Use offset of '1' so the first message at timestamp 1 and increments // from there - ASSERT_EQ(tester().addMessages(&guids, k_MSG_COUNT, 1), + ASSERT_EQ(tester.addMessages(&guids, k_MSG_COUNT, 1), mqbi::StorageResult::e_SUCCESS); bsls::Types::Uint64 latestMsgTimestamp; bsls::Types::Int64 configuredTtlValue; bsls::Types::Uint64 secondsFromEpoch = 5; - mqbs::ReplicatedStorage& storage = tester().storage(); + mqbs::ReplicatedStorage& storage = tester.storage(); // Case 1: Remove Zero messages (secondsFromEpoch = Low Value) // Such that '0 < seccondsFromEpoch - msgTimeStamp <= TTL'