summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests
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-21 19:49:13 +0000
commita5341aa27ef996912766719eae263e08b9721f4c (patch)
tree702a3ca8cc62a6ea137b87cf8cd02c793501feaf /src/mongo/dbtests
parent78711c2c27c9a769670e79ade63fa616831589d2 (diff)
downloadmongo-a5341aa27ef996912766719eae263e08b9721f4c.tar.gz
SERVER-71498 QueryStageBatchedDeleteTest initializes TickSourceMock once
Diffstat (limited to 'src/mongo/dbtests')
-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());