diff options
Diffstat (limited to 'storage/src/tests/persistence/persistencequeuetest.cpp')
-rw-r--r-- | storage/src/tests/persistence/persistencequeuetest.cpp | 82 |
1 files changed, 32 insertions, 50 deletions
diff --git a/storage/src/tests/persistence/persistencequeuetest.cpp b/storage/src/tests/persistence/persistencequeuetest.cpp index a212e65efe8..be276dd7f9d 100644 --- a/storage/src/tests/persistence/persistencequeuetest.cpp +++ b/storage/src/tests/persistence/persistencequeuetest.cpp @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/log/log.h> -#include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/storageapi/message/bucket.h> #include <tests/persistence/common/persistenceproviderwrapper.h> #include <vespa/persistence/dummyimpl/dummypersistence.h> @@ -12,31 +11,16 @@ LOG_SETUP(".persistencequeuetest"); using document::test::makeDocumentBucket; +using namespace ::testing; namespace storage { class PersistenceQueueTest : public FileStorTestFixture { public: - void testFetchNextUnlockedMessageIfBucketLocked(); - void shared_locked_operations_allow_concurrent_bucket_access(); - void exclusive_locked_operation_not_started_if_shared_op_active(); - void shared_locked_operation_not_started_if_exclusive_op_active(); - void exclusive_locked_operation_not_started_if_exclusive_op_active(); - void operation_batching_not_allowed_across_different_lock_modes(); - 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; - - CPPUNIT_TEST_SUITE(PersistenceQueueTest); - CPPUNIT_TEST(testFetchNextUnlockedMessageIfBucketLocked); - CPPUNIT_TEST(shared_locked_operations_allow_concurrent_bucket_access); - CPPUNIT_TEST(exclusive_locked_operation_not_started_if_shared_op_active); - CPPUNIT_TEST(shared_locked_operation_not_started_if_exclusive_op_active); - CPPUNIT_TEST(exclusive_locked_operation_not_started_if_exclusive_op_active); - CPPUNIT_TEST(operation_batching_not_allowed_across_different_lock_modes); - CPPUNIT_TEST_SUITE_END(); + void SetUp() override; struct Fixture { FileStorTestFixture& parent; @@ -55,8 +39,6 @@ public: static constexpr uint16_t _disk = 0; }; -CPPUNIT_TEST_SUITE_REGISTRATION(PersistenceQueueTest); - PersistenceQueueTest::Fixture::Fixture(FileStorTestFixture& parent_) : parent(parent_), top(), @@ -82,7 +64,7 @@ PersistenceQueueTest::Fixture::Fixture(FileStorTestFixture& parent_) PersistenceQueueTest::Fixture::~Fixture() = default; -void PersistenceQueueTest::setUp() { +void PersistenceQueueTest::SetUp() { setupPersistenceThreads(1); _node->setPersistenceProvider(std::make_unique<spi::dummy::DummyPersistence>(_node->getTypeRepo(), 1)); } @@ -103,7 +85,7 @@ std::shared_ptr<api::StorageMessage> PersistenceQueueTest::createGet(uint64_t bu return cmd; } -void PersistenceQueueTest::testFetchNextUnlockedMessageIfBucketLocked() { +TEST_F(PersistenceQueueTest, fetch_next_unlocked_message_if_bucket_locked) { Fixture f(*this); // Send 2 puts, 2 to the first bucket, 1 to the second. Calling // getNextMessage 2 times should then return a lock on the first bucket, @@ -114,91 +96,91 @@ void PersistenceQueueTest::testFetchNextUnlockedMessageIfBucketLocked() { f.filestorHandler->schedule(createPut(5432, 0), _disk); auto lock0 = f.filestorHandler->getNextMessage(_disk, f.stripeId); - CPPUNIT_ASSERT(lock0.first.get()); - CPPUNIT_ASSERT_EQUAL(document::BucketId(16, 1234), - dynamic_cast<api::PutCommand&>(*lock0.second).getBucketId()); + ASSERT_TRUE(lock0.first.get()); + EXPECT_EQ(document::BucketId(16, 1234), + dynamic_cast<api::PutCommand&>(*lock0.second).getBucketId()); auto lock1 = f.filestorHandler->getNextMessage(_disk, f.stripeId); - CPPUNIT_ASSERT(lock1.first.get()); - CPPUNIT_ASSERT_EQUAL(document::BucketId(16, 5432), - dynamic_cast<api::PutCommand&>(*lock1.second).getBucketId()); + ASSERT_TRUE(lock1.first.get()); + EXPECT_EQ(document::BucketId(16, 5432), + dynamic_cast<api::PutCommand&>(*lock1.second).getBucketId()); } -void PersistenceQueueTest::shared_locked_operations_allow_concurrent_bucket_access() { +TEST_F(PersistenceQueueTest, shared_locked_operations_allow_concurrent_bucket_access) { Fixture f(*this); f.filestorHandler->schedule(createGet(1234), _disk); f.filestorHandler->schedule(createGet(1234), _disk); auto lock0 = f.filestorHandler->getNextMessage(_disk, f.stripeId); - CPPUNIT_ASSERT(lock0.first.get()); - CPPUNIT_ASSERT_EQUAL(api::LockingRequirements::Shared, lock0.first->lockingRequirements()); + ASSERT_TRUE(lock0.first.get()); + EXPECT_EQ(api::LockingRequirements::Shared, lock0.first->lockingRequirements()); // Even though we already have a lock on the bucket, Gets allow shared locking and we // should therefore be able to get another lock. auto lock1 = f.filestorHandler->getNextMessage(_disk, f.stripeId); - CPPUNIT_ASSERT(lock1.first.get()); - CPPUNIT_ASSERT_EQUAL(api::LockingRequirements::Shared, lock1.first->lockingRequirements()); + ASSERT_TRUE(lock1.first.get()); + EXPECT_EQ(api::LockingRequirements::Shared, lock1.first->lockingRequirements()); } -void PersistenceQueueTest::exclusive_locked_operation_not_started_if_shared_op_active() { +TEST_F(PersistenceQueueTest, exclusive_locked_operation_not_started_if_shared_op_active) { Fixture f(*this); f.filestorHandler->schedule(createGet(1234), _disk); f.filestorHandler->schedule(createPut(1234, 0), _disk); auto lock0 = f.filestorHandler->getNextMessage(_disk, f.stripeId); - CPPUNIT_ASSERT(lock0.first.get()); - CPPUNIT_ASSERT_EQUAL(api::LockingRequirements::Shared, lock0.first->lockingRequirements()); + ASSERT_TRUE(lock0.first.get()); + EXPECT_EQ(api::LockingRequirements::Shared, lock0.first->lockingRequirements()); // Expected to time out auto lock1 = f.filestorHandler->getNextMessage(_disk, f.stripeId); - CPPUNIT_ASSERT(!lock1.first.get()); + ASSERT_FALSE(lock1.first.get()); } -void PersistenceQueueTest::shared_locked_operation_not_started_if_exclusive_op_active() { +TEST_F(PersistenceQueueTest, shared_locked_operation_not_started_if_exclusive_op_active) { Fixture f(*this); f.filestorHandler->schedule(createPut(1234, 0), _disk); f.filestorHandler->schedule(createGet(1234), _disk); auto lock0 = f.filestorHandler->getNextMessage(_disk, f.stripeId); - CPPUNIT_ASSERT(lock0.first.get()); - CPPUNIT_ASSERT_EQUAL(api::LockingRequirements::Exclusive, lock0.first->lockingRequirements()); + ASSERT_TRUE(lock0.first.get()); + EXPECT_EQ(api::LockingRequirements::Exclusive, lock0.first->lockingRequirements()); // Expected to time out auto lock1 = f.filestorHandler->getNextMessage(_disk, f.stripeId); - CPPUNIT_ASSERT(!lock1.first.get()); + ASSERT_FALSE(lock1.first.get()); } -void PersistenceQueueTest::exclusive_locked_operation_not_started_if_exclusive_op_active() { +TEST_F(PersistenceQueueTest, exclusive_locked_operation_not_started_if_exclusive_op_active) { Fixture f(*this); f.filestorHandler->schedule(createPut(1234, 0), _disk); f.filestorHandler->schedule(createPut(1234, 0), _disk); auto lock0 = f.filestorHandler->getNextMessage(_disk, f.stripeId); - CPPUNIT_ASSERT(lock0.first.get()); - CPPUNIT_ASSERT_EQUAL(api::LockingRequirements::Exclusive, lock0.first->lockingRequirements()); + ASSERT_TRUE(lock0.first.get()); + EXPECT_EQ(api::LockingRequirements::Exclusive, lock0.first->lockingRequirements()); // Expected to time out auto lock1 = f.filestorHandler->getNextMessage(_disk, f.stripeId); - CPPUNIT_ASSERT(!lock1.first.get()); + ASSERT_FALSE(lock1.first.get()); } -void PersistenceQueueTest::operation_batching_not_allowed_across_different_lock_modes() { +TEST_F(PersistenceQueueTest, operation_batching_not_allowed_across_different_lock_modes) { Fixture f(*this); f.filestorHandler->schedule(createPut(1234, 0), _disk); f.filestorHandler->schedule(createGet(1234), _disk); auto lock0 = f.filestorHandler->getNextMessage(_disk, f.stripeId); - CPPUNIT_ASSERT(lock0.first); - CPPUNIT_ASSERT(lock0.second); - CPPUNIT_ASSERT_EQUAL(api::LockingRequirements::Exclusive, lock0.first->lockingRequirements()); + ASSERT_TRUE(lock0.first); + ASSERT_TRUE(lock0.second); + EXPECT_EQ(api::LockingRequirements::Exclusive, lock0.first->lockingRequirements()); f.filestorHandler->getNextMessage(_disk, f.stripeId, lock0); - CPPUNIT_ASSERT(!lock0.second); + ASSERT_FALSE(lock0.second); } } // namespace storage |