summaryrefslogtreecommitdiffstats
path: root/storage/src/tests/persistence/persistencethread_splittest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'storage/src/tests/persistence/persistencethread_splittest.cpp')
-rw-r--r--storage/src/tests/persistence/persistencethread_splittest.cpp121
1 files changed, 63 insertions, 58 deletions
diff --git a/storage/src/tests/persistence/persistencethread_splittest.cpp b/storage/src/tests/persistence/persistencethread_splittest.cpp
index 9c10b9987e0..ea7dce96e0c 100644
--- a/storage/src/tests/persistence/persistencethread_splittest.cpp
+++ b/storage/src/tests/persistence/persistencethread_splittest.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/storage/persistence/persistencethread.h>
#include <vespa/storageapi/message/bucketsplitting.h>
#include <vespa/persistence/spi/test.h>
@@ -9,14 +8,14 @@
using storage::spi::test::makeSpiBucket;
using document::test::makeDocumentBucket;
+using namespace ::testing;
namespace storage {
namespace {
- spi::LoadType defaultLoadType(0, "default");
+spi::LoadType defaultLoadType(0, "default");
}
-struct PersistenceThread_SplitTest : public SingleDiskPersistenceTestUtils
-{
+struct PersistenceThreadSplitTest : public SingleDiskPersistenceTestUtils {
enum SplitCase {
TOO_MANY_DOCS_SPLIT_ONCE, // Only one split needed to divide
TOO_MANY_DOCS_SPLIT_MULTIPLE_BITS, // Multiple bits needed to divide
@@ -26,7 +25,7 @@ struct PersistenceThread_SplitTest : public SingleDiskPersistenceTestUtils
TOO_LARGE_DOCS_SPLIT_MULTIPLE_BITS,
TOO_LARGE_DOCS_SINGLE_DOC, // Cannot split single doc even if too large
TOO_LARGE_DOCS_ACTUALLY_NOT, // Other copy is too large, not this one
- // Need to split to X bits to get in line with other copy or distr.
+ // Need to split to X bits to get in line with other copy or distr.
SPLIT_TOO_LITTLE_SINGLE_SPLIT, // Split all to one target
SPLIT_TOO_LITTLE_JUST_RIGHT, // Just manage to split in two at that lvl
SPLIT_TOO_LITTLE_SPLIT_TOWARDS_ENOUGH, // Has to split shorter
@@ -35,54 +34,60 @@ struct PersistenceThread_SplitTest : public SingleDiskPersistenceTestUtils
};
void doTest(SplitCase);
+};
- void testTooManyDocsSplitOnce()
- { doTest(TOO_MANY_DOCS_SPLIT_ONCE); }
- void testTooManyDocsSplitMulti()
- { doTest(TOO_MANY_DOCS_SPLIT_MULTIPLE_BITS); }
- void testTooManyDocsActuallyNot()
- { doTest(TOO_MANY_DOCS_ACTUALLY_NOT); }
- void testTooLargeDocsSplitOnce()
- { doTest(TOO_LARGE_DOCS_SPLIT_ONCE); }
- void testTooLargeDocsSplitMulti()
- { doTest(TOO_LARGE_DOCS_SPLIT_MULTIPLE_BITS); }
- void testTooLargeDocsSingleDoc()
- { doTest(TOO_LARGE_DOCS_SINGLE_DOC); }
- void testTooLargeDocsActuallyNot()
- { doTest(TOO_LARGE_DOCS_ACTUALLY_NOT); }
- void testSplitTooLittleSingleSplit()
- { doTest(SPLIT_TOO_LITTLE_SINGLE_SPLIT); }
- void testSplitTooLittleJustRight()
- { doTest(SPLIT_TOO_LITTLE_JUST_RIGHT); }
- void testSplitTooLittleSplitTowardsEnough()
- { doTest(SPLIT_TOO_LITTLE_SPLIT_TOWARDS_ENOUGH); }
- void testInconsistentSplitHasOneBitFallbackWhen1Doc() {
- doTest(SPLIT_INCONSISTENT_1_DOC);
- }
- void testInconsistentSplitHasOneBitFallbackWhenAllDocsHaveSameGid() {
- doTest(SPLIT_INCONSISTENT_ALL_DOCS_SAME_GID);
- }
+TEST_F(PersistenceThreadSplitTest, split_single_bit_for_too_many_docs) {
+ doTest(TOO_MANY_DOCS_SPLIT_ONCE);
+}
- CPPUNIT_TEST_SUITE(PersistenceThread_SplitTest);
- CPPUNIT_TEST(testTooManyDocsSplitOnce);
- CPPUNIT_TEST(testTooManyDocsSplitMulti);
- CPPUNIT_TEST(testTooManyDocsActuallyNot);
- CPPUNIT_TEST(testTooLargeDocsSplitOnce);
- CPPUNIT_TEST(testTooLargeDocsSplitMulti);
- CPPUNIT_TEST(testTooLargeDocsSingleDoc);
- CPPUNIT_TEST(testTooLargeDocsActuallyNot);
- CPPUNIT_TEST(testSplitTooLittleSingleSplit);
- CPPUNIT_TEST(testSplitTooLittleJustRight);
- CPPUNIT_TEST(testSplitTooLittleSplitTowardsEnough);
- CPPUNIT_TEST(testInconsistentSplitHasOneBitFallbackWhen1Doc);
- CPPUNIT_TEST(testInconsistentSplitHasOneBitFallbackWhenAllDocsHaveSameGid);
- CPPUNIT_TEST_SUITE_END();
-};
+TEST_F(PersistenceThreadSplitTest, bucket_split_requires_multiple_bit_increase_for_too_many_docs) {
+ doTest(TOO_MANY_DOCS_SPLIT_MULTIPLE_BITS);
+}
-CPPUNIT_TEST_SUITE_REGISTRATION(PersistenceThread_SplitTest);
+TEST_F(PersistenceThreadSplitTest, false_positive_too_many_docs) {
+ doTest(TOO_MANY_DOCS_ACTUALLY_NOT);
+}
+
+TEST_F(PersistenceThreadSplitTest, split_single_bit_for_too_large_docs) {
+ doTest(TOO_LARGE_DOCS_SPLIT_ONCE);
+}
+
+TEST_F(PersistenceThreadSplitTest, bucket_split_requires_multiple_bit_increase_for_too_large_docs) {
+ doTest(TOO_LARGE_DOCS_SPLIT_MULTIPLE_BITS);
+}
+
+TEST_F(PersistenceThreadSplitTest, cannot_split_bucket_with_single_too_large_document) {
+ doTest(TOO_LARGE_DOCS_SINGLE_DOC);
+}
+
+TEST_F(PersistenceThreadSplitTest, false_positive_too_large_docs) {
+ doTest(TOO_LARGE_DOCS_ACTUALLY_NOT);
+}
+
+TEST_F(PersistenceThreadSplitTest, request_can_specify_minimum_split_bit_count) {
+ doTest(SPLIT_TOO_LITTLE_SINGLE_SPLIT);
+}
+
+// TODO verify that name actually matches what test does...
+TEST_F(PersistenceThreadSplitTest, can_split_into_2_targets_at_max_split_level) {
+ doTest(SPLIT_TOO_LITTLE_JUST_RIGHT);
+}
+
+// TODO verify that name actually matches what test does...
+TEST_F(PersistenceThreadSplitTest, actual_split_level_can_be_lower_than_max_level) {
+ doTest(SPLIT_TOO_LITTLE_SPLIT_TOWARDS_ENOUGH);
+}
+
+TEST_F(PersistenceThreadSplitTest, inconsistent_split_has_one_bit_fallback_when_1_doc) {
+ doTest(SPLIT_INCONSISTENT_1_DOC);
+}
+
+TEST_F(PersistenceThreadSplitTest, inconsistent_split_has_one_bit_fallback_when_all_docs_have_same_gid) {
+ doTest(SPLIT_INCONSISTENT_ALL_DOCS_SAME_GID);
+}
void
-PersistenceThread_SplitTest::doTest(SplitCase splitCase)
+PersistenceThreadSplitTest::doTest(SplitCase splitCase)
{
uint32_t maxCount = 4;
uint32_t maxSize = 1000 * 1000;
@@ -119,8 +124,8 @@ PersistenceThread_SplitTest::doTest(SplitCase splitCase)
resultSplitLevel = 3;
break;
case TOO_LARGE_DOCS_SINGLE_DOC:
- // It is possible for bucket to be inconsistent being big enough
- // to split in other copy but this copy has only 1 too big doc.
+ // It is possible for bucket to be inconsistent being big enough
+ // to split in other copy but this copy has only 1 too big doc.
docCount = 1;
docSize = 3000 * 1000;
splitLevelToDivide = 3;
@@ -176,7 +181,7 @@ PersistenceThread_SplitTest::doTest(SplitCase splitCase)
}
uint64_t location = 0;
- uint64_t splitMask = 1 << (splitLevelToDivide - 1);
+ uint64_t splitMask = 1ULL << (splitLevelToDivide - 1);
spi::Context context(defaultLoadType, spi::Priority(0),
spi::Trace::TraceLevel(0));
spi::Bucket bucket(makeSpiBucket(document::BucketId(currentSplitLevel, 1)));
@@ -201,8 +206,7 @@ PersistenceThread_SplitTest::doTest(SplitCase splitCase)
std::unique_ptr<PersistenceThread> thread(createPersistenceThread(0));
getNode().getStateUpdater().setClusterState(
- lib::ClusterState::CSP(
- new lib::ClusterState("distributor:1 storage:1")));
+ std::make_shared<lib::ClusterState>("distributor:1 storage:1"));
api::SplitBucketCommand cmd(makeDocumentBucket(document::BucketId(currentSplitLevel, 1)));
cmd.setMaxSplitBits(maxBits);
cmd.setMinSplitBits(minBits);
@@ -211,10 +215,11 @@ PersistenceThread_SplitTest::doTest(SplitCase splitCase)
cmd.setSourceIndex(0);
MessageTracker::UP result(thread->handleSplitBucket(cmd));
api::ReturnCode code(result->getResult());
- CPPUNIT_ASSERT_EQUAL(error, code);
- if (!code.success()) return;
- api::SplitBucketReply& reply(
- dynamic_cast<api::SplitBucketReply&>(*result->getReply()));
+ EXPECT_EQ(error, code);
+ if (!code.success()) {
+ return;
+ }
+ auto& reply = dynamic_cast<api::SplitBucketReply&>(*result->getReply());
std::set<std::string> expected;
for (uint32_t i=0; i<resultBuckets; ++i) {
document::BucketId b(resultSplitLevel,
@@ -230,7 +235,7 @@ PersistenceThread_SplitTest::doTest(SplitCase splitCase)
ost << b << " - " << b.getUsedBits();
actual.insert(ost.str());
}
- CPPUNIT_ASSERT_EQUAL(expected, actual);
+ EXPECT_EQ(expected, actual);
}
} // storage