summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/documentdb
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-04-08 22:35:52 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-04-08 22:35:52 +0000
commitb971dbe48ad2111f24e7b953eaf351e9a0bb4ea1 (patch)
treed300b3d83395c6e89d395f00a7d34a772b616aee /searchcore/src/tests/proton/documentdb
parent78298d9906f214fc9e096df782bfb7ee5fa1e76d (diff)
Make RemoveOperation an interface and move implmentation to RemoveOperationWithDocId
Diffstat (limited to 'searchcore/src/tests/proton/documentdb')
-rw-r--r--searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp14
-rw-r--r--searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp6
-rw-r--r--searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp23
-rw-r--r--searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp2
-rw-r--r--searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp10
5 files changed, 27 insertions, 28 deletions
diff --git a/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp
index 958be6a4686..fd8ce978d43 100644
--- a/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp
@@ -155,9 +155,9 @@ struct Fixture
const test::Document &doc = userDocs().getDocs(userId)[0];
return PutOperation(doc.getBucket(), doc.getTimestamp(), doc.getDoc());
}
- RemoveOperation remove(uint32_t userId) {
+ RemoveOperationWithDocId remove(uint32_t userId) {
const test::Document &doc = userDocs().getDocs(userId)[0];
- return RemoveOperation(doc.getBucket(), doc.getTimestamp(), doc.getDoc()->getId());
+ return RemoveOperationWithDocId(doc.getBucket(), doc.getTimestamp(), doc.getDoc()->getId());
}
UpdateOperation update(uint32_t userId) {
const test::Document &doc = userDocs().getDocs(userId)[0];
@@ -234,7 +234,7 @@ TEST_F("require that handlePut() sends to 2 feed views", Fixture)
TEST_F("require that prepareRemove() sends to removed view", Fixture)
{
- RemoveOperation op = f.remove(1);
+ RemoveOperationWithDocId op = f.remove(1);
f._view.prepareRemove(op);
EXPECT_EQUAL(0u, f._ready._view->_prepareRemove);
EXPECT_EQUAL(1u, f._removed._view->_prepareRemove);
@@ -246,7 +246,7 @@ TEST_F("require that prepareRemove() sends to removed view", Fixture)
TEST_F("require that prepareRemove() can fill previous dbdId", Fixture)
{
f._ready.insertDocs(f.userDocs(1));
- RemoveOperation op = f.remove(1);
+ RemoveOperationWithDocId op = f.remove(1);
f._view.prepareRemove(op);
EXPECT_EQUAL(1u, op.getPrevLid());
EXPECT_EQUAL(READY, op.getPrevSubDbId());
@@ -257,7 +257,7 @@ TEST_F("require that prepareRemove() can fill previous dbdId", Fixture)
TEST_F("require that handleRemove() sends op with valid dbdId to 1 feed view", Fixture)
{
- RemoveOperation op = f.remove(1);
+ RemoveOperationWithDocId op = f.remove(1);
op.setDbDocumentId(DbDocumentId(REMOVED, 1));
f._view.handleRemove(FeedToken(), op);
EXPECT_EQUAL(0u, f._ready._view->_handleRemove);
@@ -268,7 +268,7 @@ TEST_F("require that handleRemove() sends op with valid dbdId to 1 feed view", F
TEST_F("require that handleRemove() sends op with valid dbdId to 2 feed views", Fixture)
{
- RemoveOperation op = f.remove(1);
+ RemoveOperationWithDocId op = f.remove(1);
op.setDbDocumentId(DbDocumentId(REMOVED, 1));
op.setPrevDbDocumentId(DbDocumentId(READY, 1));
f._view.handleRemove(FeedToken(), op);
@@ -280,7 +280,7 @@ TEST_F("require that handleRemove() sends op with valid dbdId to 2 feed views",
TEST_F("require that handleRemove() sends op with invalid dbdId to prev view", Fixture)
{
- RemoveOperation op = f.remove(1);
+ RemoveOperationWithDocId op = f.remove(1);
// can be used in the case where removed feed view does not remember removes.
op.setPrevDbDocumentId(DbDocumentId(READY, 1));
f._view.handleRemove(FeedToken(), op);
diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp
index 898f014cea3..2785b744265 100644
--- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp
@@ -743,13 +743,13 @@ struct DocumentHandler
op.setSerialNum(serialNum);
return op;
}
- RemoveOperation createRemove(const DocumentId &docId, Timestamp timestamp, SerialNum serialNum)
+ RemoveOperationWithDocId createRemove(const DocumentId &docId, Timestamp timestamp, SerialNum serialNum)
{
const document::GlobalId &gid = docId.getGlobalId();
BucketId bucket = gid.convertToBucketId();
bucket.setUsedBits(BUCKET_USED_BITS);
bucket = bucket.stripUnused();
- RemoveOperation op(bucket, timestamp, docId);
+ RemoveOperationWithDocId op(bucket, timestamp, docId);
op.setSerialNum(serialNum);
return op;
}
@@ -883,7 +883,7 @@ TEST_F("require that lid allocation uses lowest free lid", StoreOnlyFixture)
DocumentHandler<StoreOnlyFixture> handler(f);
Document::UP doc;
PutOperation putOp;
- RemoveOperation rmOp;
+ RemoveOperationWithDocId rmOp;
MoveOperation moveOp;
doc = handler.createEmptyDoc(1);
diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
index 6c9ffc210a1..796ec4436fe 100644
--- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
@@ -193,7 +193,7 @@ struct MyFeedView : public test::DummyFeedView {
MyFeedView(const std::shared_ptr<const DocumentTypeRepo> &dtr,
const DocTypeName &docTypeName);
~MyFeedView() override;
- void resetPutLatch(uint32_t count) { putLatch.reset(new vespalib::CountDownLatch(count)); }
+ void resetPutLatch(uint32_t count) { putLatch = std::make_unique<vespalib::CountDownLatch>(count); }
void preparePut(PutOperation &op) override {
prepareDocumentOperation(op, op.getDocument()->getId().getGlobalId());
}
@@ -532,7 +532,7 @@ TEST_F("require that heartBeat calls FeedView's heartBeat",
TEST_F("require that outdated remove is ignored", FeedHandlerFixture)
{
DocumentContext doc_context("id:ns:searchdocument::foo", *f.schema.builder);
- FeedOperation::UP op(new RemoveOperation(doc_context.bucketId, Timestamp(10), doc_context.doc->getId()));
+ auto op = std::make_unique<RemoveOperationWithDocId>(doc_context.bucketId, Timestamp(10), doc_context.doc->getId());
static_cast<DocumentOperation &>(*op).setPrevDbDocumentId(DbDocumentId(4));
static_cast<DocumentOperation &>(*op).setPrevTimestamp(Timestamp(10000));
FeedTokenContext token_context;
@@ -544,8 +544,7 @@ TEST_F("require that outdated remove is ignored", FeedHandlerFixture)
TEST_F("require that outdated put is ignored", FeedHandlerFixture)
{
DocumentContext doc_context("id:ns:searchdocument::foo", *f.schema.builder);
- FeedOperation::UP op(new PutOperation(doc_context.bucketId,
- Timestamp(10), doc_context.doc));
+ auto op =std::make_unique<PutOperation>(doc_context.bucketId, Timestamp(10), doc_context.doc);
static_cast<DocumentOperation &>(*op).setPrevTimestamp(Timestamp(10000));
FeedTokenContext token_context;
f.handler.performOperation(std::move(token_context.token), std::move(op));
@@ -556,7 +555,7 @@ TEST_F("require that outdated put is ignored", FeedHandlerFixture)
void
addLidToRemove(RemoveDocumentsOperation &op)
{
- LidVectorContext::SP lids(new LidVectorContext(42));
+ auto lids = std::make_shared<LidVectorContext>(42);
lids->addLid(4);
op.setLidsToRemove(0, lids);
}
@@ -625,7 +624,7 @@ TEST_F("require that flush cannot unprune", FeedHandlerFixture)
TEST_F("require that remove of unknown document with known data type stores remove", FeedHandlerFixture)
{
DocumentContext doc_context("id:test:searchdocument::foo", *f.schema.builder);
- FeedOperation::UP op(new RemoveOperation(doc_context.bucketId, Timestamp(10), doc_context.doc->getId()));
+ auto op = std::make_unique<RemoveOperationWithDocId>(doc_context.bucketId, Timestamp(10), doc_context.doc->getId());
FeedTokenContext token_context;
f.handler.performOperation(std::move(token_context.token), std::move(op));
EXPECT_EQUAL(1, f.feedView.remove_count);
@@ -635,7 +634,7 @@ TEST_F("require that remove of unknown document with known data type stores remo
TEST_F("require that partial update for non-existing document is tagged as such", FeedHandlerFixture)
{
UpdateContext upCtx("id:test:searchdocument::foo", *f.schema.builder);
- FeedOperation::UP op(new UpdateOperation(upCtx.bucketId, Timestamp(10), upCtx.update));
+ auto op = std::make_unique<UpdateOperation>(upCtx.bucketId, Timestamp(10), upCtx.update);
FeedTokenContext token_context;
f.handler.performOperation(std::move(token_context.token), std::move(op));
const UpdateResult *result = static_cast<const UpdateResult *>(token_context.getResult());
@@ -653,7 +652,7 @@ TEST_F("require that partial update for non-existing document is created if spec
UpdateContext upCtx("id:test:searchdocument::foo", *f.schema.builder);
upCtx.update->setCreateIfNonExistent(true);
f.feedView.metaStore.insert(upCtx.update->getId().getGlobalId(), MyDocumentMetaStore::Entry(5, 5, Timestamp(10)));
- FeedOperation::UP op(new UpdateOperation(upCtx.bucketId, Timestamp(10), upCtx.update));
+ auto op = std::make_unique<UpdateOperation>(upCtx.bucketId, Timestamp(10), upCtx.update);
FeedTokenContext token_context;
f.handler.performOperation(std::move(token_context.token), std::move(op));
const UpdateResult *result = static_cast<const UpdateResult *>(token_context.getResult());
@@ -674,7 +673,7 @@ TEST_F("require that put is rejected if resource limit is reached", FeedHandlerF
f.writeFilter._message = "Attribute resource limit reached";
DocumentContext docCtx("id:test:searchdocument::foo", *f.schema.builder);
- FeedOperation::UP op = std::make_unique<PutOperation>(docCtx.bucketId, Timestamp(10), docCtx.doc);
+ auto op = std::make_unique<PutOperation>(docCtx.bucketId, Timestamp(10), docCtx.doc);
FeedTokenContext token;
f.handler.performOperation(std::move(token.token), std::move(op));
EXPECT_EQUAL(0, f.feedView.put_count);
@@ -689,7 +688,7 @@ TEST_F("require that update is rejected if resource limit is reached", FeedHandl
f.writeFilter._message = "Attribute resource limit reached";
UpdateContext updCtx("id:test:searchdocument::foo", *f.schema.builder);
- FeedOperation::UP op = std::make_unique<UpdateOperation>(updCtx.bucketId, Timestamp(10), updCtx.update);
+ auto op = std::make_unique<UpdateOperation>(updCtx.bucketId, Timestamp(10), updCtx.update);
FeedTokenContext token;
f.handler.performOperation(std::move(token.token), std::move(op));
EXPECT_EQUAL(0, f.feedView.update_count);
@@ -705,7 +704,7 @@ TEST_F("require that remove is NOT rejected if resource limit is reached", FeedH
f.writeFilter._message = "Attribute resource limit reached";
DocumentContext docCtx("id:test:searchdocument::foo", *f.schema.builder);
- FeedOperation::UP op = std::make_unique<RemoveOperation>(docCtx.bucketId, Timestamp(10), docCtx.doc->getId());
+ auto op = std::make_unique<RemoveOperationWithDocId>(docCtx.bucketId, Timestamp(10), docCtx.doc->getId());
FeedTokenContext token;
f.handler.performOperation(std::move(token.token), std::move(op));
EXPECT_EQUAL(1, f.feedView.remove_count);
@@ -726,7 +725,7 @@ checkUpdate(FeedHandlerFixture &f, SchemaContext &schemaContext,
} else {
updCtx.update->setCreateIfNonExistent(true);
}
- FeedOperation::UP op = std::make_unique<UpdateOperation>(updCtx.bucketId, Timestamp(10), updCtx.update);
+ auto op = std::make_unique<UpdateOperation>(updCtx.bucketId, Timestamp(10), updCtx.update);
FeedTokenContext token;
f.handler.performOperation(std::move(token.token), std::move(op));
EXPECT_TRUE(dynamic_cast<const UpdateResult *>(token.getResult()));
diff --git a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp
index 6a6b05be7f0..ddf45d6a509 100644
--- a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp
@@ -620,7 +620,7 @@ struct FixtureBase
void removeAndWait(const DocumentContext &docCtx) {
FeedTokenContext token(_tracer);
- RemoveOperation op(docCtx.bid, docCtx.ts, docCtx.doc->getId());
+ RemoveOperationWithDocId op(docCtx.bid, docCtx.ts, docCtx.doc->getId());
runInMaster([&] () { performRemove(token.ft, op); });
}
diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
index d4aebd0b8a7..7e2e258476f 100644
--- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
@@ -110,7 +110,7 @@ public:
MaintenanceDocumentSubDB getSubDB();
void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &op);
void handlePut(PutOperation &op);
- void handleRemove(RemoveOperation &op);
+ void handleRemove(RemoveOperationWithDocId &op);
void prepareMove(MoveOperation &op);
void handleMove(const MoveOperation &op);
uint32_t getNumUsedLids() const;
@@ -565,11 +565,11 @@ MyDocumentSubDB::handlePut(PutOperation &op)
void
-MyDocumentSubDB::handleRemove(RemoveOperation &op)
+MyDocumentSubDB::handleRemove(RemoveOperationWithDocId &op)
{
const SerialNum serialNum = op.getSerialNum();
const DocumentId &docId = op.getDocumentId();
- const document::GlobalId &gid = docId.getGlobalId();
+ const document::GlobalId &gid = op.getGlobalId();
bool needCommit = false;
if (op.getValidDbdId(_subDBId)) {
@@ -584,7 +584,7 @@ MyDocumentSubDB::handleRemove(RemoveOperation &op)
assert(op.getLid() == putRes._lid);
const document::DocumentType *docType =
_repo->getDocumentType(_docTypeName.getName());
- Document::UP doc(new Document(*docType, docId));
+ auto doc = std::make_unique<Document>(*docType, docId);
doc->setRepo(*_repo);
_docs[op.getLid()] = std::move(doc);
needCommit = true;
@@ -948,7 +948,7 @@ MaintenanceControllerFixture::removeDocs(const test::UserDocuments &docs,
const test::BucketDocuments &bucketDocs = itr->second;
for (size_t i = 0; i < bucketDocs.getDocs().size(); ++i) {
const test::Document &testDoc = bucketDocs.getDocs()[i];
- RemoveOperation op(testDoc.getBucket(), timestamp, testDoc.getDoc()->getId());
+ RemoveOperationWithDocId op(testDoc.getBucket(), timestamp, testDoc.getDoc()->getId());
op.setDbDocumentId(DbDocumentId(_removed.getSubDBId(), testDoc.getLid()));
_fh.storeOperation(op, std::make_shared<search::IgnoreCallback>());
_removed.handleRemove(op);