aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/tests/distributor/getoperationtest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'storage/src/tests/distributor/getoperationtest.cpp')
-rw-r--r--storage/src/tests/distributor/getoperationtest.cpp444
1 files changed, 161 insertions, 283 deletions
diff --git a/storage/src/tests/distributor/getoperationtest.cpp b/storage/src/tests/distributor/getoperationtest.cpp
index 064348539bf..4b67cf1963d 100644
--- a/storage/src/tests/distributor/getoperationtest.cpp
+++ b/storage/src/tests/distributor/getoperationtest.cpp
@@ -6,121 +6,101 @@
#include <vespa/storage/distributor/externaloperationhandler.h>
#include <vespa/storage/distributor/distributor.h>
#include <vespa/storage/distributor/distributormetricsset.h>
+#include <vespa/storage/distributor/operations/external/getoperation.h>
#include <tests/distributor/distributortestutil.h>
#include <vespa/storageapi/message/persistence.h>
#include <vespa/document/test/make_document_bucket.h>
-#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/config/helper/configgetter.hpp>
+#include <vespa/vespalib/gtest/gtest.h>
#include <iomanip>
-#include <vespa/storage/distributor/operations/external/getoperation.h>
using std::shared_ptr;
using config::ConfigGetter;
using document::DocumenttypesConfig;
using config::FileSpec;
using document::test::makeDocumentBucket;
+using namespace ::testing;
namespace storage::distributor {
-class GetOperationTest : public CppUnit::TestFixture, public DistributorTestUtil {
- CPPUNIT_TEST_SUITE(GetOperationTest);
- CPPUNIT_TEST(testSimple);
- CPPUNIT_TEST(testNotFound);
- CPPUNIT_TEST(testResendOnStorageFailure);
- CPPUNIT_TEST(testResendOnStorageFailureAllFail);
- CPPUNIT_TEST(testSendToIdealCopyIfBucketInSync);
- CPPUNIT_TEST(testReturnNotFoundWhenBucketNotInDb);
- CPPUNIT_TEST(testAskAllNodesIfBucketIsInconsistent);
- CPPUNIT_TEST(testSendToAllInvalidNodesWhenInconsistent);
- CPPUNIT_TEST(testAskTrustedNodeIfBucketIsInconsistent);
- CPPUNIT_TEST(testInconsistentSplit); // Test that we ask all nodes if a bucket is inconsistent.
- CPPUNIT_TEST(testSendToAllInvalidCopies);
- CPPUNIT_TEST(testMultiInconsistentBucket);
- CPPUNIT_TEST(testMultiInconsistentBucketFail);
- CPPUNIT_TEST(testMultiInconsistentBucketNotFound);
- CPPUNIT_TEST(testMultiInconsistentBucketNotFoundDeleted);
- CPPUNIT_TEST(testMultipleCopiesWithFailureOnLocalNode);
- CPPUNIT_TEST(canGetDocumentsWhenAllReplicaNodesRetired);
- CPPUNIT_TEST_SUITE_END();
+struct GetOperationTest : Test, DistributorTestUtil {
std::shared_ptr<const document::DocumentTypeRepo> _repo;
-
-public:
document::DocumentId docId;
document::BucketId bucketId;
std::unique_ptr<Operation> op;
- void setUp() override {
+ GetOperationTest();
+ ~GetOperationTest();
+
+ void SetUp() override {
_repo.reset(
new document::DocumentTypeRepo(*ConfigGetter<DocumenttypesConfig>::
getConfig("config-doctypes",
- FileSpec(TEST_PATH("config-doctypes.cfg")))));
+ FileSpec("../config-doctypes.cfg"))));
createLinks();
docId = document::DocumentId(document::DocIdString("test", "uri"));
bucketId = getExternalOperationHandler().getBucketId(docId);
};
- void tearDown() override {
+ void TearDown() override {
close();
op.reset();
}
void sendGet() {
- std::shared_ptr<api::GetCommand> msg(
- new api::GetCommand(makeDocumentBucket(document::BucketId(0)), docId, "[all]"));
-
- op.reset(new GetOperation(getExternalOperationHandler(),
- getDistributorBucketSpace(),
- msg,
- getDistributor().getMetrics().
- gets[msg->getLoadType()]));
+ auto msg = std::make_shared<api::GetCommand>(makeDocumentBucket(document::BucketId(0)), docId, "[all]");
+ op = std::make_unique<GetOperation>(
+ getExternalOperationHandler(), getDistributorBucketSpace(),
+ msg, getDistributor().getMetrics(). gets[msg->getLoadType()]);
op->start(_sender, framework::MilliSecTime(0));
}
+ static constexpr uint32_t LastCommand = UINT32_MAX;
+
void sendReply(uint32_t idx,
api::ReturnCode::Result result,
std::string authorVal, uint32_t timestamp)
{
- if (idx == (uint32_t)-1) {
- idx = _sender.commands.size() - 1;
+ if (idx == LastCommand) {
+ idx = _sender.commands().size() - 1;
}
- std::shared_ptr<api::StorageCommand> msg2 = _sender.commands[idx];
- CPPUNIT_ASSERT_EQUAL(api::MessageType::GET, msg2->getType());
+ std::shared_ptr<api::StorageCommand> msg2 = _sender.command(idx);
+ ASSERT_EQ(api::MessageType::GET, msg2->getType());
- api::GetCommand* tmp = static_cast<api::GetCommand*>(msg2.get());
+ auto* tmp = static_cast<api::GetCommand*>(msg2.get());
document::Document::SP doc;
- if (authorVal.length()) {
+ if (!authorVal.empty()) {
const document::DocumentType* type(_repo->getDocumentType("text/html"));
- doc = document::Document::SP(
- new document::Document(*type, docId));
+ doc = std::make_unique<document::Document>(*type, docId);
doc->setValue(doc->getField("author"),
document::StringFieldValue(authorVal));
}
- api::GetReply* reply = new api::GetReply(*tmp, doc, timestamp);
+ auto reply = std::make_shared<api::GetReply>(*tmp, doc, timestamp);
reply->setResult(result);
- op->receive(_sender, std::shared_ptr<api::StorageReply>(reply));
+ op->receive(_sender, reply);
}
void replyWithFailure() {
- sendReply(-1, api::ReturnCode::IO_FAILURE, "", 0);
+ sendReply(LastCommand, api::ReturnCode::IO_FAILURE, "", 0);
}
void replyWithNotFound() {
- sendReply(-1, api::ReturnCode::OK, "", 0);
+ sendReply(LastCommand, api::ReturnCode::OK, "", 0);
}
void replyWithDocument() {
- sendReply(-1, api::ReturnCode::OK, "foo", 100);
+ sendReply(LastCommand, api::ReturnCode::OK, "foo", 100);
}
std::string getLastReplyAuthor() {
- api::StorageMessage& msg = *_sender.replies[_sender.replies.size() - 1];
+ api::StorageMessage& msg = *_sender.replies().back();
if (msg.getType() == api::MessageType::GET_REPLY) {
document::Document::SP doc(
@@ -137,147 +117,104 @@ public:
void setClusterState(const std::string& clusterState) {
enableDistributorClusterState(clusterState);
}
-
- void testSimple();
- void testReturnNotFoundWhenBucketNotInDb();
- void testNotFound();
- void testResendOnStorageFailure();
- void testResendOnStorageFailureAllFail();
- void testSendToIdealCopyIfBucketInSync();
- void testAskAllNodesIfBucketIsInconsistent();
- void testSendToAllInvalidNodesWhenInconsistent();
- void testAskTrustedNodeIfBucketIsInconsistent();
- void testInconsistentSplit();
- void testMultiInconsistentBucket();
- void testMultiInconsistentBucketFail();
- void testMultiInconsistentBucketNotFound();
- void testMultiInconsistentBucketNotFoundDeleted();
- void testSendToAllInvalidCopies();
- void testMultipleCopiesWithFailureOnLocalNode();
- void canGetDocumentsWhenAllReplicaNodesRetired();
};
-CPPUNIT_TEST_SUITE_REGISTRATION(GetOperationTest);
+GetOperationTest::GetOperationTest() = default;
+GetOperationTest::~GetOperationTest() = default;
-void
-GetOperationTest::testSimple()
-{
+TEST_F(GetOperationTest, simple) {
setClusterState("distributor:1 storage:2");
addNodesToBucketDB(bucketId, "0=4,1=4");
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get => 0"),
- _sender.getCommands(true));
+ ASSERT_EQ("Get => 0", _sender.getCommands(true));
- replyWithDocument();
+ ASSERT_NO_FATAL_FAILURE(replyWithDocument());
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 100) ReturnCode(NONE)"),
- _sender.getLastReply());
+ EXPECT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 100) ReturnCode(NONE)",
+ _sender.getLastReply());
}
-void
-GetOperationTest::testAskTrustedNodeIfBucketIsInconsistent()
-{
+TEST_F(GetOperationTest, ask_trusted_node_if_bucket_is_inconsistent) {
setClusterState("distributor:1 storage:4");
addNodesToBucketDB(bucketId, "0=100/3/10,1=200/4/12/t");
sendGet();
- CPPUNIT_ASSERT_EQUAL(std::string("Get => 1"),
- _sender.getCommands(true));
+ ASSERT_EQ("Get => 1", _sender.getCommands(true));
- replyWithDocument();
+ ASSERT_NO_FATAL_FAILURE(replyWithDocument());
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 100) ReturnCode(NONE)"),
- _sender.getLastReply());
+ EXPECT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 100) ReturnCode(NONE)",
+ _sender.getLastReply());
}
-void
-GetOperationTest::testAskAllNodesIfBucketIsInconsistent()
-{
+TEST_F(GetOperationTest, ask_all_nodes_if_bucket_is_inconsistent) {
setClusterState("distributor:1 storage:4");
addNodesToBucketDB(bucketId, "0=100/3/10,1=200/4/12");
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get => 0,Get => 1"),
- _sender.getCommands(true));
+ ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
- sendReply(0, api::ReturnCode::OK, "newauthor", 2);
- sendReply(1, api::ReturnCode::OK, "oldauthor", 1);
+ ASSERT_NO_FATAL_FAILURE(sendReply(0, api::ReturnCode::OK, "newauthor", 2));
+ ASSERT_NO_FATAL_FAILURE(sendReply(1, api::ReturnCode::OK, "oldauthor", 1));
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 2) ReturnCode(NONE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 2) ReturnCode(NONE)",
+ _sender.getLastReply());
- CPPUNIT_ASSERT_EQUAL(std::string("newauthor"), getLastReplyAuthor());
+ EXPECT_EQ("newauthor", getLastReplyAuthor());
}
-
-void
-GetOperationTest::testSendToAllInvalidCopies()
-{
+TEST_F(GetOperationTest, send_to_all_invalid_copies) {
setClusterState("distributor:1 storage:4");
addNodesToBucketDB(bucketId, "2=0/0/1,3=0/0/1");
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get => 2,Get => 3"),
- _sender.getCommands(true));
+ ASSERT_EQ("Get => 2,Get => 3", _sender.getCommands(true));
- sendReply(0, api::ReturnCode::OK, "newauthor", 2);
- sendReply(1, api::ReturnCode::OK, "oldauthor", 1);
+ ASSERT_NO_FATAL_FAILURE(sendReply(0, api::ReturnCode::OK, "newauthor", 2));
+ ASSERT_NO_FATAL_FAILURE(sendReply(1, api::ReturnCode::OK, "oldauthor", 1));
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 2) ReturnCode(NONE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 2) ReturnCode(NONE)",
+ _sender.getLastReply());
- CPPUNIT_ASSERT_EQUAL(std::string("newauthor"), getLastReplyAuthor());
+ EXPECT_EQ("newauthor", getLastReplyAuthor());
}
-void
-GetOperationTest::testSendToAllInvalidNodesWhenInconsistent()
-{
+TEST_F(GetOperationTest, send_to_all_invalid_nodes_when_inconsistent) {
setClusterState("distributor:1 storage:4");
addNodesToBucketDB(bucketId, "0=100,1=200,2=0/0/1,3=0/0/1");
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get => 2,Get => 3,Get => 0,Get => 1"),
- _sender.getCommands(true));
+ ASSERT_EQ("Get => 2,Get => 3,Get => 0,Get => 1",
+ _sender.getCommands(true));
- sendReply(0, api::ReturnCode::OK, "newauthor", 2);
- sendReply(1, api::ReturnCode::OK, "oldauthor", 1);
- sendReply(2, api::ReturnCode::OK, "oldauthor", 1);
- sendReply(3, api::ReturnCode::OK, "oldauthor", 1);
+ ASSERT_NO_FATAL_FAILURE(sendReply(0, api::ReturnCode::OK, "newauthor", 2));
+ ASSERT_NO_FATAL_FAILURE(sendReply(1, api::ReturnCode::OK, "oldauthor", 1));
+ ASSERT_NO_FATAL_FAILURE(sendReply(2, api::ReturnCode::OK, "oldauthor", 1));
+ ASSERT_NO_FATAL_FAILURE(sendReply(3, api::ReturnCode::OK, "oldauthor", 1));
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 2) ReturnCode(NONE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 2) ReturnCode(NONE)",
+ _sender.getLastReply());
- CPPUNIT_ASSERT_EQUAL(std::string("newauthor"), getLastReplyAuthor());
+ EXPECT_EQ("newauthor", getLastReplyAuthor());
}
-void
-GetOperationTest::testInconsistentSplit()
-{
+TEST_F(GetOperationTest, inconsistent_split) {
setClusterState("distributor:1 storage:4");
addNodesToBucketDB(document::BucketId(16, 0x2a52), "0=100");
@@ -285,162 +222,126 @@ GetOperationTest::testInconsistentSplit()
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get => 0,Get => 1"),
- _sender.getCommands(true));
+ ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
- sendReply(0, api::ReturnCode::OK, "newauthor", 2);
- sendReply(1, api::ReturnCode::OK, "oldauthor", 1);
+ ASSERT_NO_FATAL_FAILURE(sendReply(0, api::ReturnCode::OK, "newauthor", 2));
+ ASSERT_NO_FATAL_FAILURE(sendReply(1, api::ReturnCode::OK, "oldauthor", 1));
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 2) ReturnCode(NONE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 2) ReturnCode(NONE)",
+ _sender.getLastReply());
- CPPUNIT_ASSERT_EQUAL(std::string("newauthor"), getLastReplyAuthor());
+ EXPECT_EQ("newauthor", getLastReplyAuthor());
}
-
-void
-GetOperationTest::testMultiInconsistentBucketNotFound()
-{
+TEST_F(GetOperationTest, multi_inconsistent_bucket_not_found) {
setClusterState("distributor:1 storage:4");
addNodesToBucketDB(bucketId, "0=100,2=100,1=200,3=200");
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get => 0,Get => 1"),
- _sender.getCommands(true));
+ ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
- sendReply(0, api::ReturnCode::OK, "newauthor", 2);
- sendReply(1, api::ReturnCode::OK, "", 0);
+ ASSERT_NO_FATAL_FAILURE(sendReply(0, api::ReturnCode::OK, "newauthor", 2));
+ ASSERT_NO_FATAL_FAILURE(sendReply(1, api::ReturnCode::OK, "", 0));
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 2) ReturnCode(NONE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 2) ReturnCode(NONE)",
+ _sender.getLastReply());
}
-void
-GetOperationTest::testMultiInconsistentBucketNotFoundDeleted()
-{
+TEST_F(GetOperationTest, multi_inconsistent_bucket_not_found_deleted) {
setClusterState("distributor:1 storage:4");
addNodesToBucketDB(bucketId, "0=100,2=100,1=200,3=200");
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get => 0,Get => 1"),
- _sender.getCommands(true));
+ ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
- sendReply(0, api::ReturnCode::OK, "newauthor", 2);
+ ASSERT_NO_FATAL_FAILURE(sendReply(0, api::ReturnCode::OK, "newauthor", 2));
// This signifies that the latest change was that the document was deleted
// at timestamp 3.
- sendReply(1, api::ReturnCode::OK, "", 3);
+ ASSERT_NO_FATAL_FAILURE(sendReply(1, api::ReturnCode::OK, "", 3));
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 3) ReturnCode(NONE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 3) ReturnCode(NONE)",
+ _sender.getLastReply());
}
-void
-GetOperationTest::testMultiInconsistentBucket()
-{
+TEST_F(GetOperationTest, multi_inconsistent_bucket) {
setClusterState("distributor:1 storage:4");
addNodesToBucketDB(bucketId, "0=100,2=100,1=200,3=200");
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get => 0,Get => 1"),
- _sender.getCommands(true));
+ ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
- sendReply(0, api::ReturnCode::OK, "newauthor", 2);
- sendReply(1, api::ReturnCode::OK, "oldauthor", 1);
+ ASSERT_NO_FATAL_FAILURE(sendReply(0, api::ReturnCode::OK, "newauthor", 2));
+ ASSERT_NO_FATAL_FAILURE(sendReply(1, api::ReturnCode::OK, "oldauthor", 1));
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 2) ReturnCode(NONE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 2) ReturnCode(NONE)",
+ _sender.getLastReply());
- CPPUNIT_ASSERT_EQUAL(std::string("newauthor"), getLastReplyAuthor());
+ EXPECT_EQ("newauthor", getLastReplyAuthor());
}
-void
-GetOperationTest::testMultiInconsistentBucketFail()
-{
+TEST_F(GetOperationTest, multi_inconsistent_bucket_fail) {
setClusterState("distributor:1 storage:4");
addNodesToBucketDB(bucketId, "0=100,2=100,1=200,3=200");
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get => 0,Get => 1"),
- _sender.getCommands(true));
+ ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
- sendReply(0, api::ReturnCode::OK, "newauthor", 1);
- sendReply(1, api::ReturnCode::DISK_FAILURE, "", 0);
+ ASSERT_NO_FATAL_FAILURE(sendReply(0, api::ReturnCode::OK, "newauthor", 1));
+ ASSERT_NO_FATAL_FAILURE(sendReply(1, api::ReturnCode::DISK_FAILURE, "", 0));
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get(BucketId(0x4000000000002a52), doc:test:uri) => 3"),
- _sender.getLastCommand());
+ ASSERT_EQ("Get(BucketId(0x4000000000002a52), doc:test:uri) => 3",
+ _sender.getLastCommand());
- replyWithDocument();
+ ASSERT_NO_FATAL_FAILURE(replyWithDocument());
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 100) ReturnCode(NONE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 100) ReturnCode(NONE)",
+ _sender.getLastReply());
}
-
-void
-GetOperationTest::testReturnNotFoundWhenBucketNotInDb()
-{
+TEST_F(GetOperationTest, return_not_found_when_bucket_not_in_db) {
setClusterState("distributor:1 storage:1");
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 0) ReturnCode(NONE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 0) ReturnCode(NONE)",
+ _sender.getLastReply());
}
-void
-GetOperationTest::testNotFound()
-{
+TEST_F(GetOperationTest, not_found) {
setClusterState("distributor:1 storage:1");
addNodesToBucketDB(bucketId, "0=100");
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get(BucketId(0x4000000000002a52), doc:test:uri) => 0"),
- _sender.getLastCommand());
+ ASSERT_EQ("Get(BucketId(0x4000000000002a52), doc:test:uri) => 0",
+ _sender.getLastCommand());
- replyWithNotFound();
+ ASSERT_NO_FATAL_FAILURE(replyWithNotFound());
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 0) ReturnCode(NONE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 0) ReturnCode(NONE)",
+ _sender.getLastReply());
- CPPUNIT_ASSERT_EQUAL(1, (int)(getDistributor().
- getMetrics().gets[documentapi::LoadType::DEFAULT].
- failures.notfound.getValue()));
+ EXPECT_EQ(1, getDistributor().getMetrics().gets[documentapi::LoadType::DEFAULT].
+ failures.notfound.getValue());
}
-void
-GetOperationTest::testResendOnStorageFailure()
-{
+TEST_F(GetOperationTest, resend_on_storage_failure) {
setClusterState("distributor:1 storage:3");
// Add two nodes that are not trusted. GET should retry each one of them
@@ -449,27 +350,22 @@ GetOperationTest::testResendOnStorageFailure()
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get(BucketId(0x4000000000002a52), doc:test:uri) => 1"),
- _sender.getLastCommand());
+ ASSERT_EQ("Get(BucketId(0x4000000000002a52), doc:test:uri) => 1",
+ _sender.getLastCommand());
- replyWithFailure();
+ ASSERT_NO_FATAL_FAILURE(replyWithFailure());
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get(BucketId(0x4000000000002a52), doc:test:uri) => 2"),
- _sender.getLastCommand());
+ ASSERT_EQ("Get(BucketId(0x4000000000002a52), doc:test:uri) => 2",
+ _sender.getLastCommand());
- replyWithDocument();
+ ASSERT_NO_FATAL_FAILURE(replyWithDocument());
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 100) ReturnCode(NONE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 100) ReturnCode(NONE)",
+ _sender.getLastReply());
}
-void
-GetOperationTest::testResendOnStorageFailureAllFail()
-{
+TEST_F(GetOperationTest, resend_on_storage_failure_all_fail) {
setClusterState("distributor:1 storage:3");
// Add two nodes that are not trusted. GET should retry each one of them
@@ -478,27 +374,22 @@ GetOperationTest::testResendOnStorageFailureAllFail()
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get(BucketId(0x4000000000002a52), doc:test:uri) => 1"),
- _sender.getLastCommand());
+ ASSERT_EQ("Get(BucketId(0x4000000000002a52), doc:test:uri) => 1",
+ _sender.getLastCommand());
- replyWithFailure();
+ ASSERT_NO_FATAL_FAILURE(replyWithFailure());
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get(BucketId(0x4000000000002a52), doc:test:uri) => 2"),
- _sender.getLastCommand());
+ ASSERT_EQ("Get(BucketId(0x4000000000002a52), doc:test:uri) => 2",
+ _sender.getLastCommand());
- replyWithFailure();
+ ASSERT_NO_FATAL_FAILURE(replyWithFailure());
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 0) ReturnCode(IO_FAILURE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 0) ReturnCode(IO_FAILURE)",
+ _sender.getLastReply());
}
-void
-GetOperationTest::testSendToIdealCopyIfBucketInSync()
-{
+TEST_F(GetOperationTest, send_to_ideal_copy_if_bucket_in_sync) {
setClusterState("distributor:1 storage:4");
addNodesToBucketDB(bucketId, "1=100,2=100,3=100");
@@ -506,21 +397,17 @@ GetOperationTest::testSendToIdealCopyIfBucketInSync()
sendGet();
// Should always send to node 1 (follow bucket db order)
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get(BucketId(0x4000000000002a52), doc:test:uri) => 1"),
- _sender.getLastCommand());
+ ASSERT_EQ("Get(BucketId(0x4000000000002a52), doc:test:uri) => 1",
+ _sender.getLastCommand());
- replyWithDocument();
+ ASSERT_NO_FATAL_FAILURE(replyWithDocument());
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 100) ReturnCode(NONE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 100) ReturnCode(NONE)",
+ _sender.getLastReply());
}
-void
-GetOperationTest::testMultipleCopiesWithFailureOnLocalNode()
-{
+TEST_F(GetOperationTest, multiple_copies_with_failure_on_local_node) {
setClusterState("distributor:1 storage:4");
// Node 0 is local copy to distributor 0 and will be preferred when
@@ -529,39 +416,30 @@ GetOperationTest::testMultipleCopiesWithFailureOnLocalNode()
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get => 0"),
- _sender.getCommands(true));
+ ASSERT_EQ("Get => 0", _sender.getCommands(true));
// Fail local node; no reply must be sent yet since we've got more nodes
// to try.
- sendReply(0, api::ReturnCode::TIMEOUT, "", 0);
+ ASSERT_NO_FATAL_FAILURE(sendReply(0, api::ReturnCode::TIMEOUT, "", 0));
// Retry with remaining copy on node 2.
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get => 0,Get => 2"),
- _sender.getCommands(true));
+ ASSERT_EQ("Get => 0,Get => 2", _sender.getCommands(true));
- sendReply(1, api::ReturnCode::OK, "newestauthor", 3);
+ ASSERT_NO_FATAL_FAILURE(sendReply(1, api::ReturnCode::OK, "newestauthor", 3));
- CPPUNIT_ASSERT_EQUAL(
- std::string("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
- "timestamp 3) ReturnCode(NONE)"),
- _sender.getLastReply());
+ ASSERT_EQ("GetReply(BucketId(0x0000000000000000), doc:test:uri, "
+ "timestamp 3) ReturnCode(NONE)",
+ _sender.getLastReply());
- CPPUNIT_ASSERT_EQUAL(std::string("newestauthor"), getLastReplyAuthor());
+ EXPECT_EQ("newestauthor", getLastReplyAuthor());
}
-void
-GetOperationTest::canGetDocumentsWhenAllReplicaNodesRetired()
-{
+TEST_F(GetOperationTest, can_get_documents_when_all_replica_nodes_retired) {
setClusterState("distributor:1 storage:2 .0.s:r .1.s:r");
addNodesToBucketDB(bucketId, "0=4,1=4");
sendGet();
- CPPUNIT_ASSERT_EQUAL(
- std::string("Get => 0"),
- _sender.getCommands(true));
+ EXPECT_EQ("Get => 0", _sender.getCommands(true));
}
}