[SERVER-41060] Change query unit tests to not create multiple service contexts Created: 08/May/19  Updated: 29/Oct/23  Resolved: 05/Mar/20

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 4.1.10
Fix Version/s: 4.7.0

Type: Improvement Priority: Minor - P4
Reporter: Ian Boros Assignee: Ruoxin Xu
Resolution: Fixed Votes: 0
Labels: neweng, qexec-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Query 2020-02-24, Query 2020-03-09
Participants:

 Description   

ExpressionContextForTest owns a service context. DocumentSourceMock will create an ExpressionContextForTest in its create() methods. This means that each time a DocumentSourceMock is created, we go through all of the work of creating an entire service context.

 

At the same time, the AggregationContextFixture inherits from ServiceContextFixture, which already makes a global ServiceContext available. This means that many of the aggregation stage unit tests actually have (at least) two service contexts: one globally and another as part of the ExpressionContextForTest.

While there is no immediate bug here, this was responsible for:

SERVER-41053

And also caused a lot of confusion while doing investigations for

SERVER-41042 and SERVER-39447

 

The ownership hierarchy should probably changed so that there's just one ServiceContext for the lifetime of the test which is threaded through ExpressionContextForTest.



 Comments   
Comment by Githook User [ 06/Mar/20 ]

Author:

{'username': 'RuoxinXu', 'name': 'Ruoxin Xu', 'email': 'ruoxin.xu@mongodb.com'}

Message: SERVER-41060 Ensure that TimeZoneDatabase is correctly set on ExpressionContextForTest
Branch: master
https://github.com/mongodb/mongo/commit/f0b3ad251b8db7b0dbbdbdb015e37db19f02160a

Comment by Githook User [ 05/Mar/20 ]

Author:

{'username': 'RuoxinXu', 'name': 'Ruoxin Xu', 'email': 'ruoxin.xu@mongodb.com'}

Message: SERVER-41060 Change query unit tests to not create multiple service contexts
Branch: master
https://github.com/mongodb/mongo/commit/7c4b875a8858c5bd5efc9bf4f285f7f440fdfdc0

Comment by Githook User [ 05/Mar/20 ]

Author:

{'username': 'RuoxinXu', 'name': 'Ruoxin Xu', 'email': 'ruoxin.xu@mongodb.com'}

Message: SERVER-41060 Change query unit tests to not create multiple service contexts
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/06b752c3a90006dd4cdff58d658d0f1cd932ee33

Generated at Thu Feb 08 04:56:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.