diff options
author | Henning Baldersheim <balder@oath.com> | 2018-04-06 00:21:15 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-04-06 00:21:15 +0200 |
commit | acd4af1d2c19119132c6803f15fff70cb65b7d4f (patch) | |
tree | 9805b69ea97132a4232310a68de22c31b23447cf /memfilepersistence/src/tests/spi/splitoperationhandlertest.cpp | |
parent | a20eb679819c3f87037f5ff4c8305111b709b5d0 (diff) |
Remove memfile implementation.
Diffstat (limited to 'memfilepersistence/src/tests/spi/splitoperationhandlertest.cpp')
-rw-r--r-- | memfilepersistence/src/tests/spi/splitoperationhandlertest.cpp | 212 |
1 files changed, 0 insertions, 212 deletions
diff --git a/memfilepersistence/src/tests/spi/splitoperationhandlertest.cpp b/memfilepersistence/src/tests/spi/splitoperationhandlertest.cpp deleted file mode 100644 index 89a7d0f6e03..00000000000 --- a/memfilepersistence/src/tests/spi/splitoperationhandlertest.cpp +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "memfiletestutils.h" -#include <vespa/document/datatype/documenttype.h> -#include <vespa/persistence/spi/test.h> - -using document::DocumentType; -using storage::spi::test::makeSpiBucket; - -namespace storage { -namespace memfile { -namespace { - spi::LoadType defaultLoadType(0, "default"); -} - -class SplitOperationHandlerTest : public SingleDiskMemFileTestUtils -{ - - void doTestMultiDisk(uint16_t sourceDisk, - uint16_t targetDisk0, - uint16_t targetDisk1); - - - CPPUNIT_TEST_SUITE(SplitOperationHandlerTest); - CPPUNIT_TEST(testSimple); - CPPUNIT_TEST(testMultiDisk); - CPPUNIT_TEST(testMultiDiskNonZeroSourceIndex); - CPPUNIT_TEST(testExceptionDuringSplittingEvictsAllBuckets); - CPPUNIT_TEST_SUITE_END(); - -public: - void testSimple(); - void testMultiDisk(); - void testMultiDiskNonZeroSourceIndex(); - void testExceptionDuringSplittingEvictsAllBuckets(); -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(SplitOperationHandlerTest); - -void -SplitOperationHandlerTest::testSimple() -{ - spi::Context context(defaultLoadType, spi::Priority(0), - spi::Trace::TraceLevel(0)); - setupDisks(1); - - for (uint32_t i = 0; i < 100; i++) { - uint32_t location = 4; - if (i % 2 == 0) { - location |= (1 << 16); - } - - doPut(location, Timestamp(1000 + i)); - } - flush(document::BucketId(16, 4)); - - env()._cache.clear(); - - document::BucketId sourceBucket = document::BucketId(16, 4); - document::BucketId target1 = document::BucketId(17, 4); - document::BucketId target2 = document::BucketId(17, 4 | (1 << 16)); - - SplitOperationHandler handler(env()); - spi::Result result = getPersistenceProvider().split( - makeSpiBucket(sourceBucket), - makeSpiBucket(target1), - makeSpiBucket(target2), - context); - - env()._cache.clear(); - - { - MemFilePtr file(handler.getMemFile(sourceBucket, 0)); - CPPUNIT_ASSERT_EQUAL(0, (int)file->getSlotCount()); - } - - { - MemFilePtr file(handler.getMemFile(target1, 0)); - CPPUNIT_ASSERT_EQUAL(50, (int)file->getSlotCount()); - for (uint32_t i = 0; i < file->getSlotCount(); ++i) { - file->getDocument((*file)[i], ALL); - } - } - - { - MemFilePtr file(handler.getMemFile(target2, 0)); - CPPUNIT_ASSERT_EQUAL(50, (int)file->getSlotCount()); - for (uint32_t i = 0; i < file->getSlotCount(); ++i) { - file->getDocument((*file)[i], ALL); - } - } -} - -void -SplitOperationHandlerTest::doTestMultiDisk(uint16_t sourceDisk, - uint16_t targetDisk0, - uint16_t targetDisk1) -{ - spi::Context context(defaultLoadType, spi::Priority(0), - spi::Trace::TraceLevel(0)); - setupDisks(3); - - for (uint32_t i = 0; i < 100; i++) { - uint32_t location = 4; - if (i % 2 == 0) { - location |= (1 << 16); - } - - doPutOnDisk(sourceDisk, location, Timestamp(1000 + i)); - } - flush(document::BucketId(16, 4)); - - env()._cache.clear(); - - document::BucketId sourceBucket = document::BucketId(16, 4); - document::BucketId target1 = document::BucketId(17, 4); - document::BucketId target2 = document::BucketId(17, 4 | (1 << 16)); - - SplitOperationHandler handler(env()); - spi::Result result = getPersistenceProvider().split( - makeSpiBucket(sourceBucket, spi::PartitionId(sourceDisk)), - makeSpiBucket(target1, spi::PartitionId(targetDisk0)), - makeSpiBucket(target2, spi::PartitionId(targetDisk1)), - context); - - env()._cache.clear(); - - { - MemFilePtr file(handler.getMemFile(sourceBucket, sourceDisk)); - CPPUNIT_ASSERT_EQUAL(0, (int)file->getSlotCount()); - } - - { - MemFilePtr file(handler.getMemFile(target1, targetDisk0)); - CPPUNIT_ASSERT_EQUAL(50, (int)file->getSlotCount()); - for (uint32_t i = 0; i < file->getSlotCount(); ++i) { - file->getDocument((*file)[i], ALL); - } - } - - { - MemFilePtr file(handler.getMemFile(target2, targetDisk1)); - CPPUNIT_ASSERT_EQUAL(50, (int)file->getSlotCount()); - for (uint32_t i = 0; i < file->getSlotCount(); ++i) { - file->getDocument((*file)[i], ALL); - } - } -} - -void -SplitOperationHandlerTest::testMultiDisk() -{ - doTestMultiDisk(0, 1, 2); -} - -void -SplitOperationHandlerTest::testMultiDiskNonZeroSourceIndex() -{ - doTestMultiDisk(1, 2, 0); -} - -void -SplitOperationHandlerTest::testExceptionDuringSplittingEvictsAllBuckets() -{ - spi::Context context(defaultLoadType, spi::Priority(0), - spi::Trace::TraceLevel(0)); - setupDisks(1); - - for (uint32_t i = 0; i < 100; i++) { - uint32_t location = 4; - if (i % 2 == 0) { - location |= (1 << 16); - } - - doPut(location, Timestamp(1000 + i)); - } - flush(document::BucketId(16, 4)); - - simulateIoErrorsForSubsequentlyOpenedFiles(); - - document::BucketId sourceBucket(16, 4); - document::BucketId target1(17, 4); - document::BucketId target2(17, 4 | (1 << 16)); - - try { - SplitOperationHandler handler(env()); - spi::Result result = getPersistenceProvider().split( - makeSpiBucket(sourceBucket), - makeSpiBucket(target1), - makeSpiBucket(target2), - context); - CPPUNIT_FAIL("Exception not thrown on flush failure"); - } catch (std::exception&) { - } - - CPPUNIT_ASSERT(!env()._cache.contains(sourceBucket)); - CPPUNIT_ASSERT(!env()._cache.contains(target1)); - CPPUNIT_ASSERT(!env()._cache.contains(target2)); - - unSimulateIoErrorsForSubsequentlyOpenedFiles(); - - // Source must not have been deleted - { - SplitOperationHandler handler(env()); - MemFilePtr file(handler.getMemFile(sourceBucket, 0)); - CPPUNIT_ASSERT_EQUAL(100, (int)file->getSlotCount()); - } -} - -} - -} |