diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-11-22 12:15:49 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-11-22 12:15:49 +0000 |
commit | 78eefb4a7e496449bd0e2a3322026b634c55c9bf (patch) | |
tree | d5797da0946ddd799e5f7ad95a22a00a50ef7914 /searchcore/src/tests/proton | |
parent | 8e72772625e0487fb750e9cd9b80a57ed2362940 (diff) |
Differentiate the levels of sync required.
Diffstat (limited to 'searchcore/src/tests/proton')
4 files changed, 41 insertions, 29 deletions
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 a9faeceab48..e3e6ac6321e 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 @@ -325,6 +325,10 @@ struct FixtureBase void runInMasterAndSync(FunctionType func) { proton::test::runInMasterAndSync(_writeService, func); } + template <typename FunctionType> + void runInMaster(FunctionType func) { + proton::test::runInMaster(_writeService, func); + } void init() { DocumentSubDbInitializer::SP task = _subDb.createInitializer(*_snapshot->_cfg, Traits::configSerial(), IndexConfig()); @@ -783,7 +787,7 @@ struct DocumentHandler void putDoc(PutOperation &op) { IFeedView::SP feedView = _f._subDb.getFeedView(); vespalib::Gate gate; - _f.runInMasterAndSync([&]() { + _f.runInMaster([&]() { feedView->preparePut(op); feedView->handlePut(FeedToken(), op); feedView->forceCommit(CommitParam(op.getSerialNum()), std::make_shared<vespalib::GateCallback>(gate)); @@ -793,7 +797,7 @@ struct DocumentHandler void moveDoc(MoveOperation &op) { IFeedView::SP feedView = _f._subDb.getFeedView(); vespalib::Gate gate; - _f.runInMasterAndSync([&]() { + _f.runInMaster([&]() { auto onDone = std::make_shared<vespalib::GateCallback>(gate); feedView->handleMove(op, onDone); feedView->forceCommit(CommitParam(op.getSerialNum()), onDone); @@ -804,7 +808,7 @@ struct DocumentHandler { IFeedView::SP feedView = _f._subDb.getFeedView(); vespalib::Gate gate; - _f.runInMasterAndSync([&]() { + _f.runInMaster([&]() { feedView->prepareRemove(op); feedView->handleRemove(FeedToken(), op); feedView->forceCommit(CommitParam(op.getSerialNum()), std::make_shared<vespalib::GateCallback>(gate)); diff --git a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp index cda70729712..09627dfa001 100644 --- a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp @@ -512,8 +512,12 @@ struct FixtureBase } template <typename FunctionType> - void runInMasterAndSync(FunctionType func) { - test::runInMasterAndSync(_writeService, func); + void runInMasterAndSyncAll(FunctionType func) { + test::runInMasterAndSyncAll(_writeService, func); + } + template <typename FunctionType> + void runInMaster(FunctionType func) { + test::runInMaster(_writeService, func); } virtual IFeedView &getFeedView() = 0; @@ -558,7 +562,7 @@ struct FixtureBase void putAndWait(const DocumentContext &docCtx) { FeedTokenContext token(_tracer); PutOperation op(docCtx.bid, docCtx.ts, docCtx.doc); - runInMasterAndSync([this, ft = std::move(token.ft), &op]() mutable { performPut(std::move(ft), op); }); + runInMaster([this, ft = std::move(token.ft), &op]() mutable { performPut(std::move(ft), op); }); token.mt.await(); } @@ -571,7 +575,7 @@ struct FixtureBase void updateAndWait(const DocumentContext &docCtx) { FeedTokenContext token(_tracer); UpdateOperation op(docCtx.bid, docCtx.ts, docCtx.upd); - runInMasterAndSync([this, ft = std::move(token.ft), &op]() mutable { performUpdate(std::move(ft), op); }); + runInMaster([this, ft = std::move(token.ft), &op]() mutable { performUpdate(std::move(ft), op); }); token.mt.await(); } @@ -586,7 +590,7 @@ struct FixtureBase void removeAndWait(const DocumentContext &docCtx) { FeedTokenContext token(_tracer); RemoveOperationWithDocId op(docCtx.bid, docCtx.ts, docCtx.doc->getId()); - runInMasterAndSync([this, ft = std::move(token.ft), &op]() mutable { performRemove(std::move(ft), op); }); + runInMaster([this, ft = std::move(token.ft), &op]() mutable { performRemove(std::move(ft), op); }); token.mt.await(); } @@ -604,7 +608,7 @@ struct FixtureBase void moveAndWait(const DocumentContext &docCtx, uint32_t fromLid, uint32_t toLid) { MoveOperation op(docCtx.bid, docCtx.ts, docCtx.doc, DbDocumentId(pc._params._subDbId, fromLid), pc._params._subDbId); op.setTargetLid(toLid); - runInMasterAndSync([&]() { performMove(op); }); + runInMasterAndSyncAll([&]() { performMove(op); }); } void performDeleteBucket(DeleteBucketOperation &op) { @@ -615,7 +619,7 @@ struct FixtureBase void performForceCommit() { getFeedView().forceCommit(serial); } void forceCommitAndWait() { - runInMasterAndSync([&]() { performForceCommit(); }); + runInMasterAndSyncAll([&]() { performForceCommit(); }); } bool assertTrace(const vespalib::string &exp) { @@ -642,7 +646,7 @@ struct FixtureBase fv.handleCompactLidSpace(op); } void compactLidSpaceAndWait(uint32_t wantedLidLimit) { - runInMasterAndSync([&]() { performCompactLidSpace(wantedLidLimit); }); + runInMasterAndSyncAll([&]() { performCompactLidSpace(wantedLidLimit); }); } void assertChangeHandler(document::GlobalId expGid, uint32_t expLid, uint32_t expChanges) { _gidToLidChangeHandler->assertChanges(expGid, expLid, expChanges); @@ -931,7 +935,7 @@ TEST_F("require that handleDeleteBucket() removes documents", SearchableFeedView // delete bucket for user 1 DeleteBucketOperation op(docs[0].bid); - f.runInMasterAndSync([&]() { f.performDeleteBucket(op); }); + f.runInMasterAndSyncAll([&]() { f.performDeleteBucket(op); }); f.dms_commit(); EXPECT_EQUAL(0u, f.getBucketDB()->get(docs[0].bid).getDocumentCount()); @@ -1034,7 +1038,7 @@ TEST_F("require that removes are not remembered", SearchableFeedViewFixture) TEST_F("require that heartbeat propagates to index- and attributeadapter", SearchableFeedViewFixture) { - f.runInMasterAndSync([&]() { f.fv.heartBeat(2); }); + f.runInMasterAndSyncAll([&]() { f.fv.heartBeat(2); }); EXPECT_EQUAL(1, f.miw._heartBeatCount); EXPECT_EQUAL(1, f.maw._heartBeatCount); } @@ -1146,7 +1150,7 @@ TEST_F("require that compactLidSpace() doesn't propagate to " EXPECT_TRUE(assertThreadObserver(5, 4, 4, f.writeServiceObserver())); CompactLidSpaceOperation op(0, 2); op.setSerialNum(0); - f.runInMasterAndSync([&]() { f.fv.handleCompactLidSpace(op); }); + f.runInMasterAndSyncAll([&]() { f.fv.handleCompactLidSpace(op); }); // Delayed holdUnblockShrinkLidSpace() in index thread, then master thread EXPECT_TRUE(assertThreadObserver(6, 5, 4, f.writeServiceObserver())); EXPECT_EQUAL(0u, f.metaStoreObserver()._compactLidSpaceLidLimit); @@ -1154,24 +1158,21 @@ TEST_F("require that compactLidSpace() doesn't propagate to " EXPECT_EQUAL(0u, f.metaStoreObserver()._holdUnblockShrinkLidSpaceCnt); } -TEST_F("require that compactLidSpace() propagates to attributeadapter", - FastAccessFeedViewFixture) +TEST_F("require that compactLidSpace() propagates to attributeadapter", FastAccessFeedViewFixture) { f.populateBeforeCompactLidSpace(); f.compactLidSpaceAndWait(2); EXPECT_EQUAL(2u, f.maw._wantedLidLimit); } -TEST_F("require that compactLidSpace() propagates to index writer", - SearchableFeedViewFixture) +TEST_F("require that compactLidSpace() propagates to index writer", SearchableFeedViewFixture) { f.populateBeforeCompactLidSpace(); f.compactLidSpaceAndWait(2); EXPECT_EQUAL(2u, f.miw._wantedLidLimit); } -TEST_F("require that commit is not implicitly called", - SearchableFeedViewFixture) +TEST_F("require that commit is not implicitly called", SearchableFeedViewFixture) { DocumentContext dc = f.doc1(); f.putAndWait(dc); @@ -1191,8 +1192,7 @@ TEST_F("require that commit is not implicitly called", f.forceCommitAndWait(); } -TEST_F("require that forceCommit updates docid limit", - SearchableFeedViewFixture) +TEST_F("require that forceCommit updates docid limit", SearchableFeedViewFixture) { DocumentContext dc = f.doc1(); f.putAndWait(dc); diff --git a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp index 8ccf4f792c5..7ccaa6e9fbf 100644 --- a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp @@ -241,13 +241,21 @@ struct FixtureBase { } template <typename FunctionType> + void runInMasterAndSyncAll(FunctionType func) { + test::runInMasterAndSyncAll(writeService, func); + } + template <typename FunctionType> void runInMasterAndSync(FunctionType func) { test::runInMasterAndSync(writeService, func); } + template <typename FunctionType> + void runInMaster(FunctionType func) { + test::runInMaster(writeService, func); + } void force_commit() { vespalib::Gate gate; - runInMasterAndSync([this, &gate]() { + runInMaster([this, &gate]() { feedview->forceCommit(search::CommitParam(serial_num), std::make_shared<vespalib::GateCallback>(gate)); }); gate.await(); @@ -314,7 +322,7 @@ TEST_F("require that handleMove() adds document to target and removes it from so MoveOperation::UP op = makeMoveOp(DbDocumentId(subdb_id + 1, 1), subdb_id); TEST_DO(f.assertPutCount(0)); f.runInMasterAndSync([&]() { f.feedview->prepareMove(*op); }); - f.runInMasterAndSync([&]() { f.feedview->handleMove(*op, f.beginMoveOp()); }); + f.runInMasterAndSyncAll([&]() { f.feedview->handleMove(*op, f.beginMoveOp()); }); TEST_DO(f.assertPutCount(1)); TEST_DO(f.assertAndClearMoveOp()); lid = op->getDbDocumentId().getLid(); @@ -326,7 +334,7 @@ TEST_F("require that handleMove() adds document to target and removes it from so MoveOperation::UP op = makeMoveOp(DbDocumentId(subdb_id, 1), subdb_id + 1); op->setDbDocumentId(DbDocumentId(subdb_id + 1, 1)); TEST_DO(f.assertRemoveCount(0)); - f.runInMasterAndSync([&]() { f.feedview->handleMove(*op, f.beginMoveOp()); }); + f.runInMasterAndSyncAll([&]() { f.feedview->handleMove(*op, f.beginMoveOp()); }); EXPECT_FALSE(f.metaStore->validLid(lid)); TEST_DO(f.assertRemoveCount(1)); TEST_DO(f.assertAndClearMoveOp()); @@ -354,7 +362,7 @@ TEST_F("require that handleMove() handles move within same subdb and propagates op->setTargetLid(1); TEST_DO(f.assertPutCount(0)); TEST_DO(f.assertRemoveCount(0)); - f.runInMasterAndSync([&]() { f.feedview->handleMove(*op, f.beginMoveOp()); }); + f.runInMasterAndSyncAll([&]() { f.feedview->handleMove(*op, f.beginMoveOp()); }); TEST_DO(f.assertPutCount(1)); TEST_DO(f.assertRemoveCount(1)); TEST_DO(f.assertAndClearMoveOp()); @@ -374,7 +382,7 @@ TEST_F("require that prune removed documents removes documents", PruneRemovedDocumentsOperation op(lids->getDocIdLimit(), subdb_id); op.setLidsToRemove(lids); op.setSerialNum(1); // allows use of meta store. - f.runInMasterAndSync([&]() { f.feedview->handlePruneRemovedDocuments(op); }); + f.runInMasterAndSyncAll([&]() { f.feedview->handlePruneRemovedDocuments(op); }); EXPECT_EQUAL(2, f.removeCount); EXPECT_FALSE(f.metaStore->validLid(1)); @@ -390,7 +398,7 @@ TEST_F("require that heartbeat propagates and commits meta store", Fixture) EXPECT_EQUAL(0, f.feedview->heartBeatIndexedFieldsCount); EXPECT_EQUAL(0, f.feedview->heartBeatAttributesCount); EXPECT_EQUAL(0, f.heartbeatCount); - f.runInMasterAndSync([&]() { f.feedview->heartBeat(2); }); + f.runInMasterAndSyncAll([&]() { f.feedview->heartBeat(2); }); EXPECT_EQUAL(2u, f.metaStore->getStatus().getLastSyncToken()); EXPECT_EQUAL(1, f.feedview->heartBeatIndexedFieldsCount); EXPECT_EQUAL(1, f.feedview->heartBeatAttributesCount); diff --git a/searchcore/src/tests/proton/documentmetastore/lidreusedelayer/lidreusedelayer_test.cpp b/searchcore/src/tests/proton/documentmetastore/lidreusedelayer/lidreusedelayer_test.cpp index 7be591099bc..74738c7abc0 100644 --- a/searchcore/src/tests/proton/documentmetastore/lidreusedelayer/lidreusedelayer_test.cpp +++ b/searchcore/src/tests/proton/documentmetastore/lidreusedelayer/lidreusedelayer_test.cpp @@ -137,7 +137,7 @@ public: template <typename FunctionType> void runInMasterAndSync(FunctionType func) { - test::runInMasterAndSync(_writeService, func); + test::runInMasterAndSyncAll(_writeService, func); } void cycledLids(const std::vector<uint32_t> &lids) { |