summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Mulrow <jack.mulrow@mongodb.com>2020-11-25 04:35:02 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-25 21:19:05 +0000
commita194505325087b1e841fdee55c51312a042ce9d2 (patch)
tree601db1cc752d8eb48aee305641b16c2328edf3e5
parentd1b4d16214fa2ea17e3b741f582067a0d5ec1f95 (diff)
downloadmongo-a194505325087b1e841fdee55c51312a042ce9d2.tar.gz
SERVER-51809 Change inheritance order for ReshardingRecipientServiceTest
-rw-r--r--src/mongo/db/pipeline/document_source_merge_cursors_test.cpp5
-rw-r--r--src/mongo/db/s/resharding/resharding_recipient_service_test.cpp4
-rw-r--r--src/mongo/db/s/sharding_mongod_test_fixture.cpp12
-rw-r--r--src/mongo/db/s/sharding_mongod_test_fixture.h2
-rw-r--r--src/mongo/s/append_raw_responses_test.cpp4
-rw-r--r--src/mongo/s/cluster_identity_loader_test.cpp3
-rw-r--r--src/mongo/s/query/results_merger_test_fixture.cpp2
-rw-r--r--src/mongo/s/sharding_router_test_fixture.cpp5
-rw-r--r--src/mongo/s/sharding_task_executor_test.cpp4
-rw-r--r--src/mongo/s/sharding_test_fixture_common.cpp13
-rw-r--r--src/mongo/s/sharding_test_fixture_common.h6
11 files changed, 46 insertions, 14 deletions
diff --git a/src/mongo/db/pipeline/document_source_merge_cursors_test.cpp b/src/mongo/db/pipeline/document_source_merge_cursors_test.cpp
index a188cc3b481..2c06c7c3497 100644
--- a/src/mongo/db/pipeline/document_source_merge_cursors_test.cpp
+++ b/src/mongo/db/pipeline/document_source_merge_cursors_test.cpp
@@ -80,14 +80,15 @@ class DocumentSourceMergeCursorsTest : public ShardingTestFixture {
public:
DocumentSourceMergeCursorsTest() {
TimeZoneDatabase::set(getServiceContext(), std::make_unique<TimeZoneDatabase>());
- _expCtx = new ExpressionContext(operationContext(), nullptr, kTestNss);
- _expCtx->mongoProcessInterface = std::make_shared<StubMongoProcessInterface>(executor());
}
void setUp() override {
ShardingTestFixture::setUp();
setRemote(HostAndPort("ClientHost", 12345));
+ _expCtx = new ExpressionContext(operationContext(), nullptr, kTestNss);
+ _expCtx->mongoProcessInterface = std::make_shared<StubMongoProcessInterface>(executor());
+
configTargeter()->setFindHostReturnValue(kTestConfigShardHost);
std::vector<ShardType> shards;
diff --git a/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp b/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp
index b93ad20f007..b90b6ada773 100644
--- a/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp
+++ b/src/mongo/db/s/resharding/resharding_recipient_service_test.cpp
@@ -49,8 +49,8 @@
namespace mongo {
namespace {
-class ReshardingRecipientServiceTest : public ServiceContextMongoDTest,
- public CatalogCacheTestFixture {
+class ReshardingRecipientServiceTest : public CatalogCacheTestFixture,
+ public ServiceContextMongoDTest {
public:
const UUID kOrigUUID = UUID::gen();
const NamespaceString kOrigNss = NamespaceString("db.foo");
diff --git a/src/mongo/db/s/sharding_mongod_test_fixture.cpp b/src/mongo/db/s/sharding_mongod_test_fixture.cpp
index ebb9fae2aa9..c1e65f887ce 100644
--- a/src/mongo/db/s/sharding_mongod_test_fixture.cpp
+++ b/src/mongo/db/s/sharding_mongod_test_fixture.cpp
@@ -122,8 +122,9 @@ ShardingMongodTestFixture::ShardingMongodTestFixture() {
std::make_unique<repl::ReplicationConsistencyMarkersMock>(),
std::make_unique<repl::ReplicationRecoveryMock>()));
- ASSERT_OK(repl::ReplicationProcess::get(operationContext())
- ->initializeRollbackID(operationContext()));
+ auto uniqueOpCtx = makeOperationContext();
+ ASSERT_OK(
+ repl::ReplicationProcess::get(uniqueOpCtx.get())->initializeRollbackID(uniqueOpCtx.get()));
repl::StorageInterface::set(service, std::move(storagePtr));
@@ -132,7 +133,7 @@ ShardingMongodTestFixture::ShardingMongodTestFixture() {
opObserver->addObserver(std::make_unique<ConfigServerOpObserver>());
opObserver->addObserver(std::make_unique<ShardServerOpObserver>());
- repl::createOplog(operationContext());
+ repl::createOplog(uniqueOpCtx.get());
// Set the highest FCV because otherwise it defaults to the lower FCV. This way we default to
// testing this release's code, not backwards compatibility code.
@@ -273,6 +274,10 @@ Status ShardingMongodTestFixture::initializeGlobalShardingStateForMongodForTest(
return Status::OK();
}
+void ShardingMongodTestFixture::setUp() {
+ ShardingTestFixtureCommon::setUp();
+}
+
void ShardingMongodTestFixture::tearDown() {
ReplicaSetMonitor::cleanup();
@@ -291,6 +296,7 @@ void ShardingMongodTestFixture::tearDown() {
CollectionShardingStateFactory::clear(getServiceContext());
Grid::get(operationContext())->clearForUnitTests();
+ ShardingTestFixtureCommon::tearDown();
ServiceContextMongoDTest::tearDown();
}
diff --git a/src/mongo/db/s/sharding_mongod_test_fixture.h b/src/mongo/db/s/sharding_mongod_test_fixture.h
index 6495ee3377a..3940b46245d 100644
--- a/src/mongo/db/s/sharding_mongod_test_fixture.h
+++ b/src/mongo/db/s/sharding_mongod_test_fixture.h
@@ -56,6 +56,8 @@ protected:
ShardingMongodTestFixture();
~ShardingMongodTestFixture();
+ void setUp() override;
+
void tearDown() override;
/**
diff --git a/src/mongo/s/append_raw_responses_test.cpp b/src/mongo/s/append_raw_responses_test.cpp
index 0c9150b424e..f3d904f0215 100644
--- a/src/mongo/s/append_raw_responses_test.cpp
+++ b/src/mongo/s/append_raw_responses_test.cpp
@@ -81,7 +81,9 @@ HostAndPort makeHostAndPort(const ShardId& shardId) {
class AppendRawResponsesTest : public ShardingTestFixture {
protected:
- AppendRawResponsesTest() {
+ void setUp() {
+ ShardingTestFixture::setUp();
+
configTargeter()->setFindHostReturnValue(kTestConfigShardHost);
std::vector<std::tuple<ShardId, HostAndPort>> remoteShards;
diff --git a/src/mongo/s/cluster_identity_loader_test.cpp b/src/mongo/s/cluster_identity_loader_test.cpp
index 94fe79d4271..fbdab8f97b1 100644
--- a/src/mongo/s/cluster_identity_loader_test.cpp
+++ b/src/mongo/s/cluster_identity_loader_test.cpp
@@ -65,7 +65,8 @@ BSONObj getReplSecondaryOkMetadata() {
class ClusterIdentityTest : public ShardingTestFixture {
public:
- ClusterIdentityTest() {
+ void setUp() {
+ ShardingTestFixture::setUp();
configTargeter()->setFindHostReturnValue(configHost);
}
diff --git a/src/mongo/s/query/results_merger_test_fixture.cpp b/src/mongo/s/query/results_merger_test_fixture.cpp
index 564d7e6bf0e..33a1816d795 100644
--- a/src/mongo/s/query/results_merger_test_fixture.cpp
+++ b/src/mongo/s/query/results_merger_test_fixture.cpp
@@ -49,6 +49,8 @@ const std::vector<HostAndPort> ResultsMergerTestFixture::kTestShardHosts = {
const NamespaceString ResultsMergerTestFixture::kTestNss = NamespaceString{"testdb.testcoll"};
void ResultsMergerTestFixture::setUp() {
+ ShardingTestFixture::setUp();
+
setRemote(HostAndPort("ClientHost", 12345));
configTargeter()->setFindHostReturnValue(kTestConfigShardHost);
diff --git a/src/mongo/s/sharding_router_test_fixture.cpp b/src/mongo/s/sharding_router_test_fixture.cpp
index 084a376c59a..691a7fe571f 100644
--- a/src/mongo/s/sharding_router_test_fixture.cpp
+++ b/src/mongo/s/sharding_router_test_fixture.cpp
@@ -172,7 +172,8 @@ ShardingTestFixture::ShardingTestFixture()
auto catalogCache = std::make_unique<CatalogCache>(service, CatalogCacheLoader::get(service));
// For now initialize the global grid object. All sharding objects will be accessible from there
// until we get rid of it.
- auto const grid = Grid::get(operationContext());
+ auto uniqueOpCtx = makeOperationContext();
+ auto const grid = Grid::get(uniqueOpCtx.get());
grid->init(makeShardingCatalogClient(std::move(uniqueDistLockManager)),
std::move(catalogCache),
std::move(shardRegistry),
@@ -194,7 +195,7 @@ ShardingTestFixture::~ShardingTestFixture() {
grid->getExecutorPool()->shutdownAndJoin();
}
if (grid->catalogClient()) {
- grid->catalogClient()->shutDown(operationContext());
+ grid->catalogClient()->shutDown(makeOperationContext().get());
}
if (grid->shardRegistry()) {
grid->shardRegistry()->shutdown();
diff --git a/src/mongo/s/sharding_task_executor_test.cpp b/src/mongo/s/sharding_task_executor_test.cpp
index df0fcd5b51c..0fd57004672 100644
--- a/src/mongo/s/sharding_task_executor_test.cpp
+++ b/src/mongo/s/sharding_task_executor_test.cpp
@@ -58,7 +58,9 @@ LogicalSessionId constructFullLsid() {
class ShardingTaskExecutorTest : public ShardingTestFixture {
protected:
- ShardingTaskExecutorTest() {
+ void setUp() {
+ ShardingTestFixture::setUp();
+
configTargeter()->setFindHostReturnValue(kTestConfigShardHost);
auto netForFixedTaskExecutor = std::make_unique<executor::NetworkInterfaceMock>();
diff --git a/src/mongo/s/sharding_test_fixture_common.cpp b/src/mongo/s/sharding_test_fixture_common.cpp
index 2ac936d3977..1cc4d2f7651 100644
--- a/src/mongo/s/sharding_test_fixture_common.cpp
+++ b/src/mongo/s/sharding_test_fixture_common.cpp
@@ -41,11 +41,20 @@ using executor::NetworkTestEnv;
using executor::RemoteCommandRequest;
using unittest::assertGet;
-ShardingTestFixtureCommon::ShardingTestFixtureCommon() {
+ShardingTestFixtureCommon::ShardingTestFixtureCommon() = default;
+
+ShardingTestFixtureCommon::~ShardingTestFixtureCommon() {
+ invariant(!_opCtxHolder,
+ "ShardingTestFixtureCommon::tearDown() must have been called before destruction");
+}
+
+void ShardingTestFixtureCommon::setUp() {
_opCtxHolder = makeOperationContext();
}
-ShardingTestFixtureCommon::~ShardingTestFixtureCommon() = default;
+void ShardingTestFixtureCommon::tearDown() {
+ _opCtxHolder.reset();
+}
RoutingTableHistoryValueHandle ShardingTestFixtureCommon::makeStandaloneRoutingTableHistory(
RoutingTableHistory rt) {
diff --git a/src/mongo/s/sharding_test_fixture_common.h b/src/mongo/s/sharding_test_fixture_common.h
index 52377d7fbc5..b5df4c66ef0 100644
--- a/src/mongo/s/sharding_test_fixture_common.h
+++ b/src/mongo/s/sharding_test_fixture_common.h
@@ -61,7 +61,13 @@ protected:
ShardingTestFixtureCommon();
~ShardingTestFixtureCommon();
+ void setUp() override;
+
+ void tearDown() override;
+
OperationContext* operationContext() const {
+ invariant(_opCtxHolder,
+ "ShardingTestFixtureCommon::setUp() must have been called before this method");
return _opCtxHolder.get();
}