aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/tests/distributor/mergeoperationtest.cpp
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@verizonmedia.com>2019-06-21 14:32:05 +0000
committerTor Brede Vekterli <vekterli@verizonmedia.com>2019-06-25 11:08:43 +0000
commit0ec1dddb0e75c235edfc68d72f4471ad186c3399 (patch)
tree254cdda75b06c8453a207933a8d556c1db90b997 /storage/src/tests/distributor/mergeoperationtest.cpp
parenta0d854b6a3fab6fe44b1164c071fc994b331c3bc (diff)
Convert remaining CppUnit tests to GTest
Move base message sender stub out to common test module to avoid artificial dependency from persistence tests to the distributor tests.
Diffstat (limited to 'storage/src/tests/distributor/mergeoperationtest.cpp')
-rw-r--r--storage/src/tests/distributor/mergeoperationtest.cpp378
1 files changed, 140 insertions, 238 deletions
diff --git a/storage/src/tests/distributor/mergeoperationtest.cpp b/storage/src/tests/distributor/mergeoperationtest.cpp
index 672c1d06124..75faddbe667 100644
--- a/storage/src/tests/distributor/mergeoperationtest.cpp
+++ b/storage/src/tests/distributor/mergeoperationtest.cpp
@@ -1,70 +1,35 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <boost/lexical_cast.hpp>
-#include <cppunit/extensions/HelperMacros.h>
-#include <iomanip>
+#include <vespa/document/test/make_document_bucket.h>
#include <tests/common/dummystoragelink.h>
#include <vespa/storage/distributor/idealstatemanager.h>
#include <vespa/storageapi/message/persistence.h>
#include <vespa/storage/distributor/operations/idealstate/mergeoperation.h>
#include <vespa/storage/distributor/bucketdbupdater.h>
-#include <tests/distributor/distributortestutil.h>
-#include <vespa/document/test/make_document_bucket.h>
#include <vespa/storage/distributor/distributor.h>
+#include <tests/distributor/distributortestutil.h>
#include <vespa/vespalib/text/stringtokenizer.h>
+#include <vespa/vespalib/gtest/gtest.h>
-using std::shared_ptr;
using document::test::makeDocumentBucket;
+using namespace ::testing;
-namespace storage {
-namespace distributor {
-
-class MergeOperationTest : public CppUnit::TestFixture,
- public DistributorTestUtil
-{
- CPPUNIT_TEST_SUITE(MergeOperationTest);
- CPPUNIT_TEST(testSimple);
- CPPUNIT_TEST(testFailIfSourceOnlyCopiesChanged);
- CPPUNIT_TEST(testGenerateNodeList);
- CPPUNIT_TEST(doNotRemoveCopiesWithPendingMessages);
- CPPUNIT_TEST(allow_deleting_active_source_only_replica);
- CPPUNIT_TEST(testMarkRedundantTrustedCopiesAsSourceOnly);
- CPPUNIT_TEST(onlyMarkRedundantRetiredReplicasAsSourceOnly);
- CPPUNIT_TEST(mark_post_merge_redundant_replicas_source_only);
- CPPUNIT_TEST(merge_operation_is_blocked_by_any_busy_target_node);
- CPPUNIT_TEST(missing_replica_is_included_in_limited_node_list);
- CPPUNIT_TEST_SUITE_END();
+namespace storage::distributor {
+struct MergeOperationTest : Test, DistributorTestUtil {
std::unique_ptr<PendingMessageTracker> _pendingTracker;
-protected:
- void testSimple();
- void testFailIfSourceOnlyCopiesChanged();
- void testGenerateNodeList();
- void doNotRemoveCopiesWithPendingMessages();
- void allow_deleting_active_source_only_replica();
- void testMarkRedundantTrustedCopiesAsSourceOnly();
- void onlyMarkRedundantRetiredReplicasAsSourceOnly();
- void mark_post_merge_redundant_replicas_source_only();
- void merge_operation_is_blocked_by_any_busy_target_node();
- void missing_replica_is_included_in_limited_node_list();
-
-public:
- void setUp() override {
+ void SetUp() override {
createLinks();
- _pendingTracker.reset(new PendingMessageTracker(getComponentRegister()));
+ _pendingTracker = std::make_unique<PendingMessageTracker>(getComponentRegister());
_sender.setPendingMessageTracker(*_pendingTracker);
}
- void tearDown() override {
+ void TearDown() override {
close();
}
};
-CPPUNIT_TEST_SUITE_REGISTRATION(MergeOperationTest);
-
-void
-MergeOperationTest::testSimple()
-{
+TEST_F(MergeOperationTest, simple) {
getClock().setAbsoluteTimeInSeconds(10);
addNodesToBucketDB(document::BucketId(16, 1),
@@ -79,25 +44,20 @@ MergeOperationTest::testSimple()
op.setIdealStateManager(&getIdealStateManager());
op.start(_sender, framework::MilliSecTime(0));
- CPPUNIT_ASSERT_EQUAL(
- std::string(
- "MergeBucketCommand(BucketId(0x4000000000000001), to time 10000000, "
- "cluster state version: 0, nodes: [0, 2, 1 (source only)], chain: [], "
- "reasons to start: ) => 0"),
- _sender.getLastCommand(true));
+ ASSERT_EQ("MergeBucketCommand(BucketId(0x4000000000000001), to time 10000000, "
+ "cluster state version: 0, nodes: [0, 2, 1 (source only)], chain: [], "
+ "reasons to start: ) => 0",
+ _sender.getLastCommand(true));
sendReply(op);
- CPPUNIT_ASSERT_EQUAL(
- std::string("DeleteBucketCommand(BucketId(0x4000000000000001)) "
- "Reasons to start: => 1"),
- _sender.getLastCommand(true));
+ ASSERT_EQ("DeleteBucketCommand(BucketId(0x4000000000000001)) "
+ "Reasons to start: => 1",
+ _sender.getLastCommand(true));
}
-void
-MergeOperationTest::testFailIfSourceOnlyCopiesChanged()
-{
+TEST_F(MergeOperationTest, fail_if_source_only_copies_changed) {
getClock().setAbsoluteTimeInSeconds(10);
addNodesToBucketDB(document::BucketId(16, 1),
@@ -116,11 +76,10 @@ MergeOperationTest::testFailIfSourceOnlyCopiesChanged()
"cluster state version: 0, nodes: [0, 2, 1 (source only)], chain: [], "
"reasons to start: ) => 0");
- CPPUNIT_ASSERT_EQUAL(merge, _sender.getLastCommand(true));
+ ASSERT_EQ(merge, _sender.getLastCommand(true));
{
- const api::MergeBucketCommand& cmd(
- dynamic_cast<api::MergeBucketCommand&>(*_sender.commands[0]));
- CPPUNIT_ASSERT_EQUAL(uint16_t(0), cmd.getSourceIndex());
+ auto& cmd = dynamic_cast<api::MergeBucketCommand&>(*_sender.command(0));
+ EXPECT_EQ(0, cmd.getSourceIndex());
}
// Source-only copy changed during merge
@@ -130,8 +89,8 @@ MergeOperationTest::testFailIfSourceOnlyCopiesChanged()
"2=10/1/1/t");
sendReply(op);
// Should not be a remove here!
- CPPUNIT_ASSERT_EQUAL(merge, _sender.getLastCommand(true));
- CPPUNIT_ASSERT(!op.ok());
+ ASSERT_EQ(merge, _sender.getLastCommand(true));
+ EXPECT_FALSE(op.ok());
}
namespace {
@@ -176,130 +135,96 @@ std::string getNodeList(std::string state, uint32_t redundancy, std::string exis
}
}
-void
-MergeOperationTest::testGenerateNodeList()
-{
+TEST_F(MergeOperationTest, generate_node_list) {
// If this fails, the distribution has changed and the rest of the test will
// likely fail
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0,9,2,1,4"),
- getNodeList("storage:10", 10, "0,1,2,3,4,5,6,7,8,9"));
+ ASSERT_EQ("3,5,7,6,8,0,9,2,1,4",
+ getNodeList("storage:10", 10, "0,1,2,3,4,5,6,7,8,9"));
// Nodes that are initializing should be treated as up
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7s,6s"),
- getNodeList("storage:10 .3.s:i .5.s:i", 2, "7,6,3,5")); // Ideal: 3,5
+ EXPECT_EQ("3,5,7s,6s",
+ getNodeList("storage:10 .3.s:i .5.s:i", 2, "7,6,3,5")); // Ideal: 3,5
// Order is given by ideal state algorithm, not order of storagenodes in bucket db
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7"),
- getNodeList("storage:10", 3, "3,7,5"));
+ EXPECT_EQ("3,5,7",
+ getNodeList("storage:10", 3, "3,7,5"));
// Node not in ideal state will be used if not enough nodes in ideal state
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,7,6"),
- getNodeList("storage:10", 3, "3,7,6"));
+ EXPECT_EQ("3,7,6",
+ getNodeList("storage:10", 3, "3,7,6"));
// Nodes not in ideal state will be included as source only after redundancy
// is reached
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,8s"),
- getNodeList("storage:10", 3, "3,5,7,8"));
+ EXPECT_EQ("3,5,7,8s",
+ getNodeList("storage:10", 3, "3,5,7,8"));
// Need at least redundancy copies that are not source only
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,8,9s"),
- getNodeList("storage:10", 3, "3,5,8,9"));
+ EXPECT_EQ("3,5,8,9s",
+ getNodeList("storage:10", 3, "3,5,8,9"));
// Order is given by storagenodes in bucket db
// when no nodes are in ideal state
- CPPUNIT_ASSERT_EQUAL(
- std::string("4,1,2"),
- getNodeList("storage:10", 3, "4,1,2"));
-
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,0s,1s,2s,4s,5s,6s,7s,8s,9s"),
- getNodeList("storage:10", 1, "0,1,2,3,4,5,6,7,8,9"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,0s,1s,2s,4s,6s,7s,8s,9s"),
- getNodeList("storage:10", 2, "0,1,2,3,4,5,6,7,8,9"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,0s,1s,2s,4s,6s,8s,9s"),
- getNodeList("storage:10", 3, "0,1,2,3,4,5,6,7,8,9"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,0s,1s,2s,4s,8s,9s"),
- getNodeList("storage:10", 4, "0,1,2,3,4,5,6,7,8,9"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0s,1s,2s,4s,9s"),
- getNodeList("storage:10", 5, "0,1,2,3,4,5,6,7,8,9"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0,1s,2s,4s,9s"),
- getNodeList("storage:10", 6, "0,1,2,3,4,5,6,7,8,9"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0,9,1s,2s,4s"),
- getNodeList("storage:10", 7, "0,1,2,3,4,5,6,7,8,9"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0,9,2,1s,4s"),
- getNodeList("storage:10", 8, "0,1,2,3,4,5,6,7,8,9"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0,9,2,1,4s"),
- getNodeList("storage:10", 9, "0,1,2,3,4,5,6,7,8,9"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0,9,2,1,4"),
- getNodeList("storage:10", 10, "0,1,2,3,4,5,6,7,8,9"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,9s,8s,7s,6s,5s,4s,2s,1s,0s"),
- getNodeList("storage:10", 1, "9,8,7,6,5,4,3,2,1,0"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,9s,8s,7s,6s,4s,2s,1s,0s"),
- getNodeList("storage:10", 2, "9,8,7,6,5,4,3,2,1,0"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,9s,8s,6s,4s,2s,1s,0s"),
- getNodeList("storage:10", 3, "9,8,7,6,5,4,3,2,1,0"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,9s,8s,4s,2s,1s,0s"),
- getNodeList("storage:10", 4, "9,8,7,6,5,4,3,2,1,0"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,9s,4s,2s,1s,0s"),
- getNodeList("storage:10", 5, "9,8,7,6,5,4,3,2,1,0"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0,9s,4s,2s,1s"),
- getNodeList("storage:10", 6, "9,8,7,6,5,4,3,2,1,0"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0,9,4s,2s,1s"),
- getNodeList("storage:10", 7, "9,8,7,6,5,4,3,2,1,0"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0,9,2,4s,1s"),
- getNodeList("storage:10", 8, "9,8,7,6,5,4,3,2,1,0"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0,9,2,1,4s"),
- getNodeList("storage:10", 9, "9,8,7,6,5,4,3,2,1,0"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0,9,2,1,4"),
- getNodeList("storage:10", 10, "9,8,7,6,5,4,3,2,1,0"));
+ EXPECT_EQ("4,1,2",
+ getNodeList("storage:10", 3, "4,1,2"));
+
+ EXPECT_EQ("3,0s,1s,2s,4s,5s,6s,7s,8s,9s",
+ getNodeList("storage:10", 1, "0,1,2,3,4,5,6,7,8,9"));
+ EXPECT_EQ("3,5,0s,1s,2s,4s,6s,7s,8s,9s",
+ getNodeList("storage:10", 2, "0,1,2,3,4,5,6,7,8,9"));
+ EXPECT_EQ("3,5,7,0s,1s,2s,4s,6s,8s,9s",
+ getNodeList("storage:10", 3, "0,1,2,3,4,5,6,7,8,9"));
+ EXPECT_EQ("3,5,7,6,0s,1s,2s,4s,8s,9s",
+ getNodeList("storage:10", 4, "0,1,2,3,4,5,6,7,8,9"));
+ EXPECT_EQ("3,5,7,6,8,0s,1s,2s,4s,9s",
+ getNodeList("storage:10", 5, "0,1,2,3,4,5,6,7,8,9"));
+ EXPECT_EQ("3,5,7,6,8,0,1s,2s,4s,9s",
+ getNodeList("storage:10", 6, "0,1,2,3,4,5,6,7,8,9"));
+ EXPECT_EQ("3,5,7,6,8,0,9,1s,2s,4s",
+ getNodeList("storage:10", 7, "0,1,2,3,4,5,6,7,8,9"));
+ EXPECT_EQ("3,5,7,6,8,0,9,2,1s,4s",
+ getNodeList("storage:10", 8, "0,1,2,3,4,5,6,7,8,9"));
+ EXPECT_EQ("3,5,7,6,8,0,9,2,1,4s",
+ getNodeList("storage:10", 9, "0,1,2,3,4,5,6,7,8,9"));
+ EXPECT_EQ("3,5,7,6,8,0,9,2,1,4",
+ getNodeList("storage:10", 10, "0,1,2,3,4,5,6,7,8,9"));
+ EXPECT_EQ("3,9s,8s,7s,6s,5s,4s,2s,1s,0s",
+ getNodeList("storage:10", 1, "9,8,7,6,5,4,3,2,1,0"));
+ EXPECT_EQ("3,5,9s,8s,7s,6s,4s,2s,1s,0s",
+ getNodeList("storage:10", 2, "9,8,7,6,5,4,3,2,1,0"));
+ EXPECT_EQ("3,5,7,9s,8s,6s,4s,2s,1s,0s",
+ getNodeList("storage:10", 3, "9,8,7,6,5,4,3,2,1,0"));
+ EXPECT_EQ("3,5,7,6,9s,8s,4s,2s,1s,0s",
+ getNodeList("storage:10", 4, "9,8,7,6,5,4,3,2,1,0"));
+ EXPECT_EQ("3,5,7,6,8,9s,4s,2s,1s,0s",
+ getNodeList("storage:10", 5, "9,8,7,6,5,4,3,2,1,0"));
+ EXPECT_EQ("3,5,7,6,8,0,9s,4s,2s,1s",
+ getNodeList("storage:10", 6, "9,8,7,6,5,4,3,2,1,0"));
+ EXPECT_EQ("3,5,7,6,8,0,9,4s,2s,1s",
+ getNodeList("storage:10", 7, "9,8,7,6,5,4,3,2,1,0"));
+ EXPECT_EQ("3,5,7,6,8,0,9,2,4s,1s",
+ getNodeList("storage:10", 8, "9,8,7,6,5,4,3,2,1,0"));
+ EXPECT_EQ("3,5,7,6,8,0,9,2,1,4s",
+ getNodeList("storage:10", 9, "9,8,7,6,5,4,3,2,1,0"));
+ EXPECT_EQ("3,5,7,6,8,0,9,2,1,4",
+ getNodeList("storage:10", 10, "9,8,7,6,5,4,3,2,1,0"));
// Trusted copies can be source-only if they are in the non-ideal node set.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0,9,1s,2s,4s"),
- getNodeList("storage:10", 7, "0,1t,2t,3,4,5,6,7,8,9"));
+ EXPECT_EQ("3,5,7,6,8,0,9,1s,2s,4s",
+ getNodeList("storage:10", 7, "0,1t,2t,3,4,5,6,7,8,9"));
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6,8,0,9,1s,2s,4s"),
- getNodeList("storage:10", 7, "0,1,2t,3,4,5,6,7,8,9"));
+ EXPECT_EQ("3,5,7,6,8,0,9,1s,2s,4s",
+ getNodeList("storage:10", 7, "0,1,2t,3,4,5,6,7,8,9"));
// Retired nodes are not in ideal state
// Ideal: 5,7
- CPPUNIT_ASSERT_EQUAL(
- std::string("0,2,3s"),
- getNodeList("storage:10 .3.s:r", 2, "0,2,3"));
+ EXPECT_EQ("0,2,3s",
+ getNodeList("storage:10 .3.s:r", 2, "0,2,3"));
// Ideal: 5,7,6
- CPPUNIT_ASSERT_EQUAL(
- std::string("0,2,3"),
- getNodeList("storage:10 .3.s:r", 3, "0,2,3"));
+ EXPECT_EQ("0,2,3",
+ getNodeList("storage:10 .3.s:r", 3, "0,2,3"));
}
-void
-MergeOperationTest::doNotRemoveCopiesWithPendingMessages() {
+TEST_F(MergeOperationTest, do_not_remove_copies_with_pending_messages) {
document::BucketId bucket(16, 1);
getClock().setAbsoluteTimeInSeconds(10);
@@ -318,20 +243,20 @@ MergeOperationTest::doNotRemoveCopiesWithPendingMessages() {
"cluster state version: 0, nodes: [0, 2, 1 (source only)], chain: [], "
"reasons to start: ) => 0");
- CPPUNIT_ASSERT_EQUAL(merge, _sender.getLastCommand(true));
+ ASSERT_EQ(merge, _sender.getLastCommand(true));
// Suddenly a wild operation appears to the source only copy!
// Removes are blocked by all and any operation types, so can just choose
// at will.
- api::StorageMessage::SP msg(
- new api::SetBucketStateCommand(makeDocumentBucket(bucket), api::SetBucketStateCommand::ACTIVE));
+ auto msg = std::make_shared<api::SetBucketStateCommand>(
+ makeDocumentBucket(bucket), api::SetBucketStateCommand::ACTIVE);
msg->setAddress(api::StorageMessageAddress("storage", lib::NodeType::STORAGE, 1));
_pendingTracker->insert(msg);
sendReply(op);
// Should not be a remove here!
- CPPUNIT_ASSERT_EQUAL(merge, _sender.getLastCommand(true));
- CPPUNIT_ASSERT(!op.ok());
+ ASSERT_EQ(merge, _sender.getLastCommand(true));
+ EXPECT_FALSE(op.ok());
}
/*
@@ -359,9 +284,7 @@ MergeOperationTest::doNotRemoveCopiesWithPendingMessages() {
* should be an uncommon edge case and it's arguably better than to never
* activate the ideal replicas at all.
*/
-void
-MergeOperationTest::allow_deleting_active_source_only_replica()
-{
+TEST_F(MergeOperationTest, allow_deleting_active_source_only_replica) {
getClock().setAbsoluteTimeInSeconds(10);
addNodesToBucketDB(document::BucketId(16, 1),
@@ -379,111 +302,92 @@ MergeOperationTest::allow_deleting_active_source_only_replica()
"MergeBucketCommand(BucketId(0x4000000000000001), to time "
"10000000, cluster state version: 0, nodes: [0, 2, 1 "
"(source only)], chain: [], reasons to start: ) => 0");
- CPPUNIT_ASSERT_EQUAL(merge, _sender.getLastCommand(true));
+ ASSERT_EQ(merge, _sender.getLastCommand(true));
sendReply(op);
- CPPUNIT_ASSERT_EQUAL(
- std::string("DeleteBucketCommand(BucketId(0x4000000000000001)) "
- "Reasons to start: => 1"),
- _sender.getLastCommand(true));
+ ASSERT_EQ("DeleteBucketCommand(BucketId(0x4000000000000001)) "
+ "Reasons to start: => 1",
+ _sender.getLastCommand(true));
}
-void
-MergeOperationTest::testMarkRedundantTrustedCopiesAsSourceOnly()
-{
+TEST_F(MergeOperationTest, MarkRedundantTrustedCopiesAsSourceOnly) {
// This test uses the same distribution as testGenerateNodeList(), i.e.
// an ideal state sequence of [3, 5, 7, 6, 8, 0, 9, 2, 1, 4]
// 3 redundancy, 5 trusted -> 2 trusted source only.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6s,8s"),
- getNodeList("storage:10", 3, "3t,5t,7t,6t,8t"));
+ EXPECT_EQ("3,5,7,6s,8s",
+ getNodeList("storage:10", 3, "3t,5t,7t,6t,8t"));
// 3 redundancy, 4 trusted -> 1 trusted source only.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6s,8s"),
- getNodeList("storage:10", 3, "3t,5t,7t,6t,8"));
+ EXPECT_EQ("3,5,7,6s,8s",
+ getNodeList("storage:10", 3, "3t,5t,7t,6t,8"));
// 3 redundancy, 3 trusted -> 0 trusted source only, 2 non-trusted sources.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6s,8s"),
- getNodeList("storage:10", 3, "3t,5t,7t,6,8"));
+ EXPECT_EQ("3,5,7,6s,8s",
+ getNodeList("storage:10", 3, "3t,5t,7t,6,8"));
// Trusted-ness should not be taken into account when marking nodes as source-only.
// 2 out of 3 ideal replicas trusted.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6s,8s"),
- getNodeList("storage:10", 3, "3t,5t,7,6t,8t"));
+ EXPECT_EQ("3,5,7,6s,8s",
+ getNodeList("storage:10", 3, "3t,5t,7,6t,8t"));
// 1 out of 3 ideal replicas trusted.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6s,8s"),
- getNodeList("storage:10", 3, "3t,5,7,6t,8t"));
+ EXPECT_EQ("3,5,7,6s,8s",
+ getNodeList("storage:10", 3, "3t,5,7,6t,8t"));
// 0 out of 3 ideal replicas trusted.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6s,8s"),
- getNodeList("storage:10", 3, "3,5,7,6t,8t"));
+ EXPECT_EQ("3,5,7,6s,8s",
+ getNodeList("storage:10", 3, "3,5,7,6t,8t"));
// #redundancy of trusted, but none are ideal. Non-ideal trusted may be
// marked as source only.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6s,8s,0s,9s"),
- getNodeList("storage:10", 3, "3,5,7,6,8t,0t,9t"));
+ EXPECT_EQ("3,5,7,6s,8s,0s,9s",
+ getNodeList("storage:10", 3, "3,5,7,6,8t,0t,9t"));
// Allow for removing excess trusted, non-ideal copies.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6s,8s,0s,9s"),
- getNodeList("storage:10", 3, "3,5,7,6t,8t,0t,9t"));
+ EXPECT_EQ("3,5,7,6s,8s,0s,9s",
+ getNodeList("storage:10", 3, "3,5,7,6t,8t,0t,9t"));
}
-void
-MergeOperationTest::onlyMarkRedundantRetiredReplicasAsSourceOnly()
-{
+TEST_F(MergeOperationTest, only_mark_redundant_retired_replicas_as_source_only) {
// No nodes in ideal state and all nodes are retired. With redundancy of 2
// we can only mark the last replica in the DB as source-only. Retired
// nodes are meant as source-only due to being migrated away from, but
// source-only nodes will have their replica removed after a successful
// merge, which we cannot allow to happen here.
- CPPUNIT_ASSERT_EQUAL(
- std::string("1,0,2s"),
- getNodeList("storage:3 .0.s:r .1.s:r .2.s:r", 2, "1,0,2"));
+ EXPECT_EQ("1,0,2s",
+ getNodeList("storage:3 .0.s:r .1.s:r .2.s:r", 2, "1,0,2"));
}
-void MergeOperationTest::mark_post_merge_redundant_replicas_source_only() {
+TEST_F(MergeOperationTest, mark_post_merge_redundant_replicas_source_only) {
// Ideal state sequence is [3, 5, 7, 6, 8, 0, 9, 2, 1, 4]
// Retired node 7 is not part of the #redundancy ideal state and should be moved
// to node 6. Once the merge is done we'll end up with too many replicas unless
// we allow marking the to-be-moved replica as source only.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,6,7s"),
- getNodeList("storage:10 .7.s:r", 3, "3t,5t,7t,6"));
+ EXPECT_EQ("3,5,6,7s",
+ getNodeList("storage:10 .7.s:r", 3, "3t,5t,7t,6"));
// Should be allowed to mark as source only even if retired replica is the
// only trusted replica at the time the merge starts.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,6,7s"),
- getNodeList("storage:10 .7.s:r", 3, "3,5,7t,6"));
+ EXPECT_EQ("3,5,6,7s",
+ getNodeList("storage:10 .7.s:r", 3, "3,5,7t,6"));
// This extends to multiple retired nodes.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,6,8,5s,7s"),
- getNodeList("storage:10 .5.s:r .7.s:r", 3, "3t,5t,7t,6,8"));
+ EXPECT_EQ("3,6,8,5s,7s",
+ getNodeList("storage:10 .5.s:r .7.s:r", 3, "3t,5t,7t,6,8"));
// If number of post-merge ideal nodes is lower than desired redundancy, don't
// mark any as source only.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6"),
- getNodeList("storage:10", 5, "3,5,7,6"));
+ EXPECT_EQ("3,5,7,6",
+ getNodeList("storage:10", 5, "3,5,7,6"));
// Same applies to when post-merge ideal nodes is _equal_ to desired redundancy.
- CPPUNIT_ASSERT_EQUAL(
- std::string("3,5,7,6"),
- getNodeList("storage:10", 4, "3,5,7,6"));
+ EXPECT_EQ("3,5,7,6",
+ getNodeList("storage:10", 4, "3,5,7,6"));
}
-void MergeOperationTest::merge_operation_is_blocked_by_any_busy_target_node() {
+TEST_F(MergeOperationTest, merge_operation_is_blocked_by_any_busy_target_node) {
getClock().setAbsoluteTimeInSeconds(10);
addNodesToBucketDB(document::BucketId(16, 1), "0=10/1/1/t,1=20/1/1,2=10/1/1/t");
enableDistributorClusterState("distributor:1 storage:3");
@@ -492,21 +396,21 @@ void MergeOperationTest::merge_operation_is_blocked_by_any_busy_target_node() {
// Should not block on nodes _not_ included in operation node set
_pendingTracker->getNodeInfo().setBusy(3, std::chrono::seconds(10));
- CPPUNIT_ASSERT(!op.isBlocked(*_pendingTracker));
+ EXPECT_FALSE(op.isBlocked(*_pendingTracker));
// Node 1 is included in operation node set and should cause a block
_pendingTracker->getNodeInfo().setBusy(0, std::chrono::seconds(10));
- CPPUNIT_ASSERT(op.isBlocked(*_pendingTracker));
+ EXPECT_TRUE(op.isBlocked(*_pendingTracker));
getClock().addSecondsToTime(11);
- CPPUNIT_ASSERT(!op.isBlocked(*_pendingTracker)); // No longer busy
+ EXPECT_FALSE(op.isBlocked(*_pendingTracker)); // No longer busy
// Should block on other operation nodes than the first listed as well
_pendingTracker->getNodeInfo().setBusy(1, std::chrono::seconds(10));
- CPPUNIT_ASSERT(op.isBlocked(*_pendingTracker));
+ EXPECT_TRUE(op.isBlocked(*_pendingTracker));
}
-void MergeOperationTest::missing_replica_is_included_in_limited_node_list() {
+TEST_F(MergeOperationTest, missing_replica_is_included_in_limited_node_list) {
setupDistributor(Redundancy(4), NodeCount(4), "distributor:1 storage:4");
getClock().setAbsoluteTimeInSeconds(10);
addNodesToBucketDB(document::BucketId(16, 1), "1=0/0/0/t,2=0/0/0/t,3=0/0/0/t");
@@ -516,12 +420,10 @@ void MergeOperationTest::missing_replica_is_included_in_limited_node_list() {
op.start(_sender, framework::MilliSecTime(0));
// Must include missing node 0 and not just 2 existing replicas
- CPPUNIT_ASSERT_EQUAL(
- std::string("MergeBucketCommand(BucketId(0x4000000000000001), to time 10000000, "
- "cluster state version: 0, nodes: [0, 1], chain: [], "
- "reasons to start: ) => 0"),
- _sender.getLastCommand(true));
+ EXPECT_EQ("MergeBucketCommand(BucketId(0x4000000000000001), to time 10000000, "
+ "cluster state version: 0, nodes: [0, 1], chain: [], "
+ "reasons to start: ) => 0",
+ _sender.getLastCommand(true));
}
-} // distributor
-} // storage
+} // storage::distributor