summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2022-11-21 18:41:46 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-11-22 17:35:23 +0000
commit8b1d7be7abb1b7ca8c90fc904e68392a68b4351b (patch)
tree5c1e801bf559dd3e9733bfcc21aa1f571f4e4c31
parent7726d54b477aa84926f4e37ecfba6c04cb840cf3 (diff)
downloadmongo-8b1d7be7abb1b7ca8c90fc904e68392a68b4351b.tar.gz
SERVER-71498 QueryStageBatchedDeleteTest initializes TickSourceMock once
(cherry picked from commit a5341aa27ef996912766719eae263e08b9721f4c)
-rw-r--r--src/mongo/dbtests/query_stage_batched_delete.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/mongo/dbtests/query_stage_batched_delete.cpp b/src/mongo/dbtests/query_stage_batched_delete.cpp
index 95186d1fe0b..a2a313c9226 100644
--- a/src/mongo/dbtests/query_stage_batched_delete.cpp
+++ b/src/mongo/dbtests/query_stage_batched_delete.cpp
@@ -82,10 +82,14 @@ public:
class QueryStageBatchedDeleteTest : public unittest::Test {
public:
QueryStageBatchedDeleteTest() : _client(&_opCtx) {
- auto tickSource = std::make_unique<TickSourceMock<Milliseconds>>();
- tickSource->reset(1);
- _tickSource = tickSource.get();
- _opCtx.getServiceContext()->setTickSource(std::move(tickSource));
+ // Avoid churning the ticket source on the service context which is shared
+ // with background jobs such as the checkpoint thread.
+ if (!_tickSource) {
+ auto tickSource = std::make_unique<TickSourceMock<Milliseconds>>();
+ _tickSource = tickSource.get();
+ _opCtx.getServiceContext()->setTickSource(std::move(tickSource));
+ }
+ _tickSource->reset(1);
std::unique_ptr<ClockAdvancingOpObserver> opObserverUniquePtr =
std::make_unique<ClockAdvancingOpObserver>();
opObserverUniquePtr->tickSource = _tickSource;
@@ -224,12 +228,15 @@ protected:
boost::intrusive_ptr<ExpressionContext> _expCtx =
make_intrusive<ExpressionContext>(&_opCtx, nullptr, nss);
ClockAdvancingOpObserver* _opObserver;
- TickSourceMock<Milliseconds>* _tickSource;
+ static TickSourceMock<Milliseconds>* _tickSource;
private:
DBDirectClient _client;
};
+// static
+TickSourceMock<Milliseconds>* QueryStageBatchedDeleteTest::_tickSource = nullptr;
+
// Confirms batched deletes wait until a batch meets the targetBatchDocs before deleting documents.
TEST_F(QueryStageBatchedDeleteTest, BatchedDeleteTargetBatchDocsBasic) {
dbtests::WriteContextForTests ctx(&_opCtx, nss.ns());