diff options
Diffstat (limited to 'storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp')
-rw-r--r-- | storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp | 51 |
1 files changed, 17 insertions, 34 deletions
diff --git a/storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp b/storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp index 1fab3a8bcc1..e21dde006dc 100644 --- a/storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp +++ b/storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp @@ -1,6 +1,5 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/storageapi/message/bucket.h> #include <vespa/storage/persistence/filestorage/modifiedbucketchecker.h> #include <vespa/persistence/spi/test.h> @@ -9,6 +8,7 @@ #include <tests/persistence/common/filestortestfixture.h> using storage::spi::test::makeSpiBucket; +using namespace ::testing; namespace storage { @@ -16,26 +16,14 @@ namespace storage { * Effectively an integration test between the ModifiedBucketChecker storage * link and the behavior of the filestor component. */ -class FileStorModifiedBucketsTest : public FileStorTestFixture -{ -public: - void modifiedBucketsSendNotifyBucketChange(); - void fileStorRepliesToRecheckBucketCommands(); - +struct FileStorModifiedBucketsTest : FileStorTestFixture { void modifyBuckets(uint32_t first, uint32_t count); spi::dummy::DummyPersistence& getDummyPersistence() { return dynamic_cast<spi::dummy::DummyPersistence&>(_node->getPersistenceProvider()); } - - CPPUNIT_TEST_SUITE(FileStorModifiedBucketsTest); - CPPUNIT_TEST(modifiedBucketsSendNotifyBucketChange); - CPPUNIT_TEST(fileStorRepliesToRecheckBucketCommands); - CPPUNIT_TEST_SUITE_END(); }; -CPPUNIT_TEST_SUITE_REGISTRATION(FileStorModifiedBucketsTest); - namespace { struct BucketCheckerInjector : FileStorTestFixture::StorageLinkInjector @@ -48,20 +36,19 @@ struct BucketCheckerInjector : FileStorTestFixture::StorageLinkInjector _fixture(fixture) {} void inject(DummyStorageLink& link) const override { - link.push_back(std::unique_ptr<ModifiedBucketChecker>( - new ModifiedBucketChecker(_node.getComponentRegister(), - _node.getPersistenceProvider(), - _fixture._config->getConfigId()))); + link.push_back(std::make_unique<ModifiedBucketChecker>( + _node.getComponentRegister(), + _node.getPersistenceProvider(), + _fixture._config->getConfigId())); } }; void assertIsNotifyCommandWithActiveBucket(api::StorageMessage& msg) { - api::NotifyBucketChangeCommand& cmd( - dynamic_cast<api::NotifyBucketChangeCommand&>(msg)); - CPPUNIT_ASSERT(cmd.getBucketInfo().isActive()); - CPPUNIT_ASSERT_EQUAL( + auto& cmd = dynamic_cast<api::NotifyBucketChangeCommand&>(msg); + ASSERT_TRUE(cmd.getBucketInfo().isActive()); + ASSERT_EQ( vespalib::string("StorageMessageAddress(Storage protocol, " "cluster storage, nodetype distributor, index 0)"), cmd.getAddress()->toString()); @@ -83,11 +70,9 @@ FileStorModifiedBucketsTest::modifyBuckets(uint32_t first, uint32_t count) getDummyPersistence().setModifiedBuckets(buckets); } -void -FileStorModifiedBucketsTest::modifiedBucketsSendNotifyBucketChange() -{ +TEST_F(FileStorModifiedBucketsTest, modified_buckets_send_notify_bucket_change) { BucketCheckerInjector bcj(*_node, *this); - TestFileStorComponents c(*this, "modifiedBucketsSendNotifyBucketChange", bcj); + TestFileStorComponents c(*this, bcj); setClusterState("storage:1 distributor:1"); uint32_t numBuckets = 10; @@ -104,21 +89,19 @@ FileStorModifiedBucketsTest::modifiedBucketsSendNotifyBucketChange() c.top.waitForMessages(numBuckets, MSG_WAIT_TIME); for (uint32_t i = 0; i < 10; ++i) { - assertIsNotifyCommandWithActiveBucket(*c.top.getReply(i)); + ASSERT_NO_FATAL_FAILURE(assertIsNotifyCommandWithActiveBucket(*c.top.getReply(i))); StorBucketDatabase::WrappedEntry entry( _node->getStorageBucketDatabase().get( document::BucketId(16, i), "foo")); - CPPUNIT_ASSERT(entry->info.isActive()); + EXPECT_TRUE(entry->info.isActive()); } } -void -FileStorModifiedBucketsTest::fileStorRepliesToRecheckBucketCommands() -{ +TEST_F(FileStorModifiedBucketsTest, file_stor_replies_to_recheck_bucket_commands) { BucketCheckerInjector bcj(*_node, *this); - TestFileStorComponents c(*this, "fileStorRepliesToRecheckBucketCommands", bcj); + TestFileStorComponents c(*this, bcj); setClusterState("storage:1 distributor:1"); document::BucketId bucket(16, 0); @@ -129,7 +112,7 @@ FileStorModifiedBucketsTest::fileStorRepliesToRecheckBucketCommands() modifyBuckets(0, 1); c.top.waitForMessages(1, MSG_WAIT_TIME); - assertIsNotifyCommandWithActiveBucket(*c.top.getReply(0)); + ASSERT_NO_FATAL_FAILURE(assertIsNotifyCommandWithActiveBucket(*c.top.getReply(0))); // If we don't reply to the recheck bucket commands, we won't trigger // a new round of getModifiedBuckets and recheck commands. @@ -137,7 +120,7 @@ FileStorModifiedBucketsTest::fileStorRepliesToRecheckBucketCommands() createBucket(makeSpiBucket(document::BucketId(16, 1))); modifyBuckets(1, 1); c.top.waitForMessages(1, MSG_WAIT_TIME); - assertIsNotifyCommandWithActiveBucket(*c.top.getReply(0)); + ASSERT_NO_FATAL_FAILURE(assertIsNotifyCommandWithActiveBucket(*c.top.getReply(0))); } } // storage |