aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-01-06 12:44:51 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-01-06 13:51:43 +0000
commit20abbaa6eb1b411bbc43b98c3bb5bc8e79a86153 (patch)
treed0eb22f90787408b402848f06b8b5f578542c3d4 /storage
parent3110d9380650e0f68fad2a621ea71d083519446a (diff)
Use enum class for the flags.
Diffstat (limited to 'storage')
-rw-r--r--storage/src/tests/persistence/testandsettest.cpp8
-rw-r--r--storage/src/tests/visiting/visitortest.cpp53
2 files changed, 31 insertions, 30 deletions
diff --git a/storage/src/tests/persistence/testandsettest.cpp b/storage/src/tests/persistence/testandsettest.cpp
index 56e20309c17..f6e48d6c325 100644
--- a/storage/src/tests/persistence/testandsettest.cpp
+++ b/storage/src/tests/persistence/testandsettest.cpp
@@ -74,7 +74,7 @@ struct TestAndSetTest : PersistenceTestUtils {
static std::string expectedDocEntryString(
api::Timestamp timestamp,
const document::DocumentId & testDocId,
- spi::DocumentMetaFlags removeFlag = spi::NONE);
+ spi::DocumentMetaFlags removeFlag = spi::DocumentMetaFlags::NONE);
};
TEST_F(TestAndSetTest, conditional_put_not_executed_on_condition_mismatch) {
@@ -151,7 +151,7 @@ TEST_F(TestAndSetTest, conditional_remove_executed_on_condition_match) {
ASSERT_EQ(fetchResult(asyncHandler->handleRemove(*remove, createTracker(remove, BUCKET))).getResult(), api::ReturnCode::Result::OK);
EXPECT_EQ(expectedDocEntryString(timestampOne, testDocId) +
- expectedDocEntryString(timestampTwo, testDocId, spi::REMOVE_ENTRY),
+ expectedDocEntryString(timestampTwo, testDocId, spi::DocumentMetaFlags::REMOVE_ENTRY),
dumpBucket(BUCKET_ID));
}
@@ -296,8 +296,8 @@ std::string TestAndSetTest::expectedDocEntryString(
{
std::stringstream ss;
- ss << "DocEntry(" << timestamp << ", " << removeFlag << ", ";
- if (removeFlag == spi::REMOVE_ENTRY) {
+ ss << "DocEntry(" << timestamp << ", " << int(removeFlag) << ", ";
+ if (removeFlag == spi::DocumentMetaFlags::REMOVE_ENTRY) {
ss << docId << ")\n";
} else {
ss << "Doc(" << docId << "))\n";
diff --git a/storage/src/tests/visiting/visitortest.cpp b/storage/src/tests/visiting/visitortest.cpp
index 82ccdb60736..945a08d910e 100644
--- a/storage/src/tests/visiting/visitortest.cpp
+++ b/storage/src/tests/visiting/visitortest.cpp
@@ -24,6 +24,8 @@
using namespace std::chrono_literals;
using document::test::makeBucketSpace;
+using document::Document;
+using document::DocumentId;
using namespace ::testing;
namespace storage {
@@ -55,7 +57,7 @@ struct TestParams {
struct VisitorTest : Test {
static uint32_t docCount;
- std::vector<document::Document::SP > _documents;
+ std::vector<Document::SP> _documents;
std::unique_ptr<TestVisitorMessageSessionFactory> _messageSessionFactory;
std::unique_ptr<TestServiceLayerApp> _node;
std::unique_ptr<DummyStorageLink> _top;
@@ -93,11 +95,11 @@ struct VisitorTest : Test {
void getMessagesAndReply(
int expectedCount,
TestVisitorMessageSession& session,
- std::vector<document::Document::SP >& docs,
- std::vector<document::DocumentId>& docIds,
+ std::vector<Document::SP> & docs,
+ std::vector<DocumentId>& docIds,
std::vector<std::string>& infoMessages,
api::ReturnCode::Result returnCode = api::ReturnCode::OK);
- uint32_t getMatchingDocuments(std::vector<document::Document::SP >& docs);
+ uint32_t getMatchingDocuments(std::vector<Document::SP>& docs);
protected:
void doTestVisitorInstanceHasConsistencyLevel(
@@ -213,7 +215,7 @@ VisitorTest::initializeTest(const TestParams& params)
uri << "id:test:testdoctype1:n=" << i % 10 << ":http://www.ntnu.no/"
<< i << ".html";
- _documents.push_back(document::Document::SP(
+ _documents.push_back(Document::SP(
_node->getTestDocMan().createDocument(content, uri.str())));
const document::DocumentType& type(_documents.back()->getType());
_documents.back()->setValue(type.getField("headerval"),
@@ -276,8 +278,8 @@ void
VisitorTest::getMessagesAndReply(
int expectedCount,
TestVisitorMessageSession& session,
- std::vector<document::Document::SP >& docs,
- std::vector<document::DocumentId>& docIds,
+ std::vector<Document::SP >& docs,
+ std::vector<DocumentId>& docIds,
std::vector<std::string>& infoMessages,
api::ReturnCode::Result result)
{
@@ -352,7 +354,7 @@ VisitorTest::verifyCreateVisitorReply(
}
uint32_t
-VisitorTest::getMatchingDocuments(std::vector<document::Document::SP >& docs) {
+VisitorTest::getMatchingDocuments(std::vector<Document::SP >& docs) {
uint32_t equalCount = 0;
for (uint32_t i=0; i<docs.size(); ++i) {
for (uint32_t j=0; j<_documents.size(); ++j) {
@@ -382,8 +384,7 @@ VisitorTest::sendGetIterReply(GetIterCommand& cmd,
assert(maxDocuments < _documents.size());
size_t documentCount = maxDocuments != 0 ? maxDocuments : _documents.size();
for (size_t i = 0; i < documentCount; ++i) {
- reply->getEntries().push_back(spi::DocEntry::create(spi::Timestamp(1000 + i), spi::NONE,
- document::Document::UP(_documents[i]->clone())));
+ reply->getEntries().push_back(spi::DocEntry::create(spi::Timestamp(1000 + i), Document::UP(_documents[i]->clone())));
}
if (documentCount == _documents.size() || overrideCompleted) {
reply->setCompleted();
@@ -479,8 +480,8 @@ TEST_F(VisitorTest, normal_usage) {
sendGetIterReply(*getIterCmd);
- std::vector<document::Document::SP> docs;
- std::vector<document::DocumentId> docIds;
+ std::vector<Document::SP> docs;
+ std::vector<DocumentId> docIds;
std::vector<std::string> infoMessages;
getMessagesAndReply(_documents.size(), getSession(0), docs, docIds, infoMessages);
ASSERT_EQ(0, infoMessages.size());
@@ -545,8 +546,8 @@ TEST_F(VisitorTest, document_api_client_error) {
sendGetIterReply(*getIterCmd, api::ReturnCode(api::ReturnCode::OK), 1);
}
- std::vector<document::Document::SP> docs;
- std::vector<document::DocumentId> docIds;
+ std::vector<Document::SP> docs;
+ std::vector<DocumentId> docIds;
std::vector<std::string> infoMessages;
getMessagesAndReply(1, getSession(0), docs, docIds, infoMessages,
api::ReturnCode::INTERNAL_FAILURE);
@@ -585,8 +586,8 @@ TEST_F(VisitorTest, no_document_api_resending_for_failed_visitor) {
sendGetIterReply(*getIterCmd, api::ReturnCode(api::ReturnCode::OK), 2, true);
}
- std::vector<document::Document::SP> docs;
- std::vector<document::DocumentId> docIds;
+ std::vector<Document::SP> docs;
+ std::vector<DocumentId> docIds;
std::vector<std::string> infoMessages;
// Use non-critical result. Visitor info message should be received
// after we send a NOT_CONNECTED reply. Failing this message as well
@@ -688,8 +689,8 @@ TEST_F(VisitorTest, no_visitor_notification_for_transient_failures) {
ASSERT_NO_FATAL_FAILURE(initializeTest());
ASSERT_NO_FATAL_FAILURE(sendInitialCreateVisitorAndGetIterRound());
- std::vector<document::Document::SP> docs;
- std::vector<document::DocumentId> docIds;
+ std::vector<Document::SP> docs;
+ std::vector<DocumentId> docIds;
std::vector<std::string> infoMessages;
// Have to make sure time increases in visitor thread so that resend
// times are reached.
@@ -732,8 +733,8 @@ TEST_F(VisitorTest, notification_sent_if_transient_error_retried_many_times) {
ASSERT_NO_FATAL_FAILURE(initializeTest());
sendInitialCreateVisitorAndGetIterRound();
- std::vector<document::Document::SP> docs;
- std::vector<document::DocumentId> docIds;
+ std::vector<Document::SP> docs;
+ std::vector<DocumentId> docIds;
std::vector<std::string> infoMessages;
// Have to make sure time increases in visitor thread so that resend
// times are reached.
@@ -772,8 +773,8 @@ VisitorTest::doCompleteVisitingSession(
1,
true);
- std::vector<document::Document::SP> docs;
- std::vector<document::DocumentId> docIds;
+ std::vector<Document::SP> docs;
+ std::vector<DocumentId> docIds;
std::vector<std::string> infoMessages;
getMessagesAndReply(1, getSession(0), docs, docIds, infoMessages);
@@ -833,8 +834,8 @@ TEST_F(VisitorTest, no_more_iterators_sent_while_memory_used_above_limit) {
std::this_thread::sleep_for(100ms);
ASSERT_EQ(0, _bottom->getNumCommands());
- std::vector<document::Document::SP> docs;
- std::vector<document::DocumentId> docIds;
+ std::vector<Document::SP> docs;
+ std::vector<DocumentId> docIds;
std::vector<std::string> infoMessages;
getMessagesAndReply(1, getSession(0), docs, docIds, infoMessages);
@@ -896,8 +897,8 @@ struct ReindexingVisitorTest : VisitorTest {
void respond_to_client_put(api::ReturnCode::Result result) {
// Reply to the Put from "client" back to the visitor
- std::vector<document::Document::SP> docs;
- std::vector<document::DocumentId> doc_ids;
+ std::vector<Document::SP> docs;
+ std::vector<DocumentId> doc_ids;
std::vector<std::string> info_messages;
getMessagesAndReply(1, getSession(0), docs, doc_ids, info_messages, result);
}