diff options
author | David Storch <david.storch@mongodb.com> | 2022-06-10 21:50:45 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-10 22:53:08 +0000 |
commit | f6b83615b8a3435193e501424bf4b9b91f9e8a1d (patch) | |
tree | c97eb170d89b19b03392e8e5ddd1671982b2fb1a /src/mongo/db/exhaust_cursor_currentop_integration_test.cpp | |
parent | 8fca1562eae7c9441c664a5868c220b4b2aad050 (diff) | |
download | mongo-f6b83615b8a3435193e501424bf4b9b91f9e8a1d.tar.gz |
SERVER-65955 Migrate shell exhaust path onto modern internal client API
In doing so, this also fixes the shell's C++ native query
path to correctly handle negative limit. The patch also
includes additional preparatory work for deleting the
query_DEPRECATED() internal client API.
Diffstat (limited to 'src/mongo/db/exhaust_cursor_currentop_integration_test.cpp')
-rw-r--r-- | src/mongo/db/exhaust_cursor_currentop_integration_test.cpp | 79 |
1 files changed, 43 insertions, 36 deletions
diff --git a/src/mongo/db/exhaust_cursor_currentop_integration_test.cpp b/src/mongo/db/exhaust_cursor_currentop_integration_test.cpp index df60b317eb2..faa05c2b63e 100644 --- a/src/mongo/db/exhaust_cursor_currentop_integration_test.cpp +++ b/src/mongo/db/exhaust_cursor_currentop_integration_test.cpp @@ -143,42 +143,49 @@ auto startExhaustQuery( int queryOptions = 0, Milliseconds awaitDataTimeoutMS = Milliseconds(5000), const boost::optional<repl::OpTime>& lastKnownCommittedOpTime = boost::none) { - queryOptions = queryOptions | QueryOption_Exhaust; - auto queryThread = - stdx::async(stdx::launch::async, - [&queryCursor, - queryConnection, - queryOptions, - awaitDataTimeoutMS, - lastKnownCommittedOpTime] { - const auto projSpec = BSON("_id" << 0 << "a" << 1); - // Issue the initial 'find' with a batchSize of 2 and the exhaust flag set. - // We then iterate through the first batch and confirm that the results are - // as expected. - queryCursor = queryConnection->query_DEPRECATED( - testNSS, BSONObj{}, Query(), 0, 0, &projSpec, queryOptions, 2); - for (int i = 0; i < 2; ++i) { - ASSERT_BSONOBJ_EQ(queryCursor->nextSafe(), BSON("a" << i)); - } - // Having exhausted the two results returned by the initial find, we set the - // batchSize to 1 and issue a single getMore via DBClientCursor::more(). - // Because the 'exhaust' flag is set, the server will generate a series of - // internal getMores and stream them back to the client until the cursor is - // exhausted, without the client sending any further getMore requests. We - // expect this request to hang at the - // 'waitWithPinnedCursorDuringGetMoreBatch' failpoint. - queryCursor->setBatchSize(1); - if ((queryOptions & QueryOption_CursorTailable) && - (queryOptions & QueryOption_AwaitData)) { - queryCursor->setAwaitDataTimeoutMS(awaitDataTimeoutMS); - if (lastKnownCommittedOpTime) { - auto term = lastKnownCommittedOpTime.get().getTerm(); - queryCursor->setCurrentTermAndLastCommittedOpTime( - term, lastKnownCommittedOpTime); - } - } - ASSERT(queryCursor->more()); - }); + auto queryThread = stdx::async( + stdx::launch::async, + [&queryCursor, + queryConnection, + queryOptions, + awaitDataTimeoutMS, + lastKnownCommittedOpTime] { + const auto projSpec = BSON("_id" << 0 << "a" << 1); + // Issue the initial 'find' with a batchSize of 2 and the exhaust flag set. + // We then iterate through the first batch and confirm that the results are + // as expected. + FindCommandRequest findCmd{testNSS}; + findCmd.setProjection(projSpec); + findCmd.setBatchSize(2); + if (queryOptions & QueryOption_CursorTailable) { + findCmd.setTailable(true); + } + if (queryOptions & QueryOption_AwaitData) { + findCmd.setAwaitData(true); + } + + queryCursor = queryConnection->find(findCmd, ReadPreferenceSetting{}, ExhaustMode::kOn); + for (int i = 0; i < 2; ++i) { + ASSERT_BSONOBJ_EQ(queryCursor->nextSafe(), BSON("a" << i)); + } + // Having exhausted the two results returned by the initial find, we set the + // batchSize to 1 and issue a single getMore via DBClientCursor::more(). + // Because the 'exhaust' flag is set, the server will generate a series of + // internal getMores and stream them back to the client until the cursor is + // exhausted, without the client sending any further getMore requests. We + // expect this request to hang at the + // 'waitWithPinnedCursorDuringGetMoreBatch' failpoint. + queryCursor->setBatchSize(1); + if (findCmd.getTailable() && findCmd.getAwaitData()) { + queryCursor->setAwaitDataTimeoutMS(awaitDataTimeoutMS); + if (lastKnownCommittedOpTime) { + auto term = lastKnownCommittedOpTime.get().getTerm(); + queryCursor->setCurrentTermAndLastCommittedOpTime(term, + lastKnownCommittedOpTime); + } + } + ASSERT(queryCursor->more()); + }); // Wait until the parallel operation initializes its cursor. const auto startTime = clock->now(); |