diff options
author | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2016-11-06 01:33:50 -0400 |
---|---|---|
committer | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2016-11-06 01:33:50 -0400 |
commit | d23e79eb9e69bd746416d9f674dfaee59457c887 (patch) | |
tree | 7ae8940e36d5ae51bb4eadd1318860ca212e8c3f /src/mongo/s | |
parent | 0ac04999faae1d2fc0e10972aaf21082a2e48c8f (diff) | |
download | mongo-d23e79eb9e69bd746416d9f674dfaee59457c887.tar.gz |
Revert "SERVER-26202 Relax index constraints in oplog application"
This reverts commit f00448255bbb24c07e2f55e7e229f19e316350a6.
Diffstat (limited to 'src/mongo/s')
-rw-r--r-- | src/mongo/s/catalog/sharding_catalog_config_initialization_test.cpp | 29 | ||||
-rw-r--r-- | src/mongo/s/client/shard_local_test.cpp | 1 | ||||
-rw-r--r-- | src/mongo/s/config_server_test_fixture.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/sharding_mongod_test_fixture.cpp | 8 | ||||
-rw-r--r-- | src/mongo/s/sharding_mongod_test_fixture.h | 8 |
5 files changed, 14 insertions, 36 deletions
diff --git a/src/mongo/s/catalog/sharding_catalog_config_initialization_test.cpp b/src/mongo/s/catalog/sharding_catalog_config_initialization_test.cpp index 99fdcf0ecab..7f4e743b205 100644 --- a/src/mongo/s/catalog/sharding_catalog_config_initialization_test.cpp +++ b/src/mongo/s/catalog/sharding_catalog_config_initialization_test.cpp @@ -32,10 +32,6 @@ #include <vector> #include "mongo/bson/json.h" -#include "mongo/db/catalog/collection.h" -#include "mongo/db/concurrency/write_conflict_exception.h" -#include "mongo/db/curop.h" -#include "mongo/db/db_raii.h" #include "mongo/db/namespace_string.h" #include "mongo/db/operation_context.h" #include "mongo/db/repl/replication_coordinator_mock.h" @@ -220,26 +216,11 @@ TEST_F(ConfigInitializationTest, ReRunsIfDocRolledBackThenReElected) { }); operationContext()->setReplicatedWrites(false); replicationCoordinator()->setFollowerMode(repl::MemberState::RS_ROLLBACK); - auto txn = operationContext(); - auto nss = NamespaceString(VersionType::ConfigNS); - MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN { - ScopedTransaction transaction(txn, MODE_IX); - AutoGetCollection autoColl(txn, nss, MODE_IX); - auto coll = autoColl.getCollection(); - ASSERT_TRUE(coll); - auto cursor = coll->getCursor(txn); - std::vector<RecordId> recordIds; - while (auto recordId = cursor->next()) { - recordIds.push_back(recordId->id); - } - mongo::WriteUnitOfWork wuow(txn); - for (auto recordId : recordIds) { - coll->deleteDocument(txn, recordId, nullptr); - } - wuow.commit(); - ASSERT_EQUALS(0UL, coll->numRecords(txn)); - } - MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "removeConfigDocuments", nss.ns()); + ASSERT_OK( + catalogClient()->removeConfigDocuments(operationContext(), + VersionType::ConfigNS, + BSONObj(), + ShardingCatalogClient::kMajorityWriteConcern)); } // Verify the document was actually removed. diff --git a/src/mongo/s/client/shard_local_test.cpp b/src/mongo/s/client/shard_local_test.cpp index 25d4f197a2a..3bd026db9ed 100644 --- a/src/mongo/s/client/shard_local_test.cpp +++ b/src/mongo/s/client/shard_local_test.cpp @@ -86,7 +86,6 @@ void ShardLocalTest::setUp() { _shardLocal = stdx::make_unique<ShardLocal>(ShardId("config")); const repl::ReplSettings replSettings = {}; repl::setGlobalReplicationCoordinator(new repl::ReplicationCoordinatorMock(replSettings)); - repl::getGlobalReplicationCoordinator()->setFollowerMode(repl::MemberState::RS_PRIMARY); } void ShardLocalTest::tearDown() { diff --git a/src/mongo/s/config_server_test_fixture.cpp b/src/mongo/s/config_server_test_fixture.cpp index 95189db6ae5..4261d037073 100644 --- a/src/mongo/s/config_server_test_fixture.cpp +++ b/src/mongo/s/config_server_test_fixture.cpp @@ -46,7 +46,6 @@ #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/read_concern_args.h" #include "mongo/db/repl/repl_settings.h" -#include "mongo/db/repl/replication_coordinator_mock.h" #include "mongo/executor/network_interface_mock.h" #include "mongo/executor/task_executor_pool.h" #include "mongo/executor/thread_pool_task_executor_test_fixture.h" @@ -99,9 +98,6 @@ ConfigServerTestFixture::~ConfigServerTestFixture() = default; void ConfigServerTestFixture::setUp() { ShardingMongodTestFixture::setUp(); - // TODO: SERVER-26919 set the flag on the mock repl coordinator just for the window where it - // actually needs to bypass the op observer. - replicationCoordinator()->alwaysAllowWrites(true); // Initialize sharding components as a config server. serverGlobalParams.clusterRole = ClusterRole::ConfigServer; diff --git a/src/mongo/s/sharding_mongod_test_fixture.cpp b/src/mongo/s/sharding_mongod_test_fixture.cpp index 3e8c9f013d7..ae91dc4ed5e 100644 --- a/src/mongo/s/sharding_mongod_test_fixture.cpp +++ b/src/mongo/s/sharding_mongod_test_fixture.cpp @@ -120,7 +120,9 @@ void ShardingMongodTestFixture::setUp() { replSetConfig.initialize(BSON("_id" << _setName << "protocolVersion" << 1 << "version" << 3 << "members" << serversBob.arr())); - replCoordPtr->setGetConfigReturnValue(replSetConfig); + auto replCoordMockPtr = dynamic_cast<ReplicationCoordinatorMock*>(replicationCoordinator()); + invariant(replCoordMockPtr); + replCoordMockPtr->setGetConfigReturnValue(replSetConfig); repl::ReplicationCoordinator::set(serviceContext, std::move(replCoordPtr)); @@ -129,7 +131,7 @@ void ShardingMongodTestFixture::setUp() { repl::createOplog(_opCtx.get()); } -std::unique_ptr<ReplicationCoordinatorMock> ShardingMongodTestFixture::makeReplicationCoordinator( +std::unique_ptr<ReplicationCoordinator> ShardingMongodTestFixture::makeReplicationCoordinator( ReplSettings replSettings) { return stdx::make_unique<repl::ReplicationCoordinatorMock>(replSettings); } @@ -370,7 +372,7 @@ executor::TaskExecutor* ShardingMongodTestFixture::executor() const { return Grid::get(operationContext())->getExecutorPool()->getFixedExecutor(); } -repl::ReplicationCoordinatorMock* ShardingMongodTestFixture::replicationCoordinator() const { +repl::ReplicationCoordinator* ShardingMongodTestFixture::replicationCoordinator() const { invariant(_replCoord); return _replCoord; } diff --git a/src/mongo/s/sharding_mongod_test_fixture.h b/src/mongo/s/sharding_mongod_test_fixture.h index 62435c97e79..e3ffa13d582 100644 --- a/src/mongo/s/sharding_mongod_test_fixture.h +++ b/src/mongo/s/sharding_mongod_test_fixture.h @@ -58,7 +58,7 @@ class TaskExecutorPool; } // namespace executor namespace repl { -class ReplicationCoordinatorMock; +class ReplicationCoordinator; class ReplSettings; } // namespace repl @@ -117,7 +117,7 @@ public: executor::TaskExecutor* executor() const; executor::NetworkInterfaceMock* network() const; - repl::ReplicationCoordinatorMock* replicationCoordinator() const; + repl::ReplicationCoordinator* replicationCoordinator() const; /** * Returns the stored raw pointer to the DistLockCatalog, if it has been initialized. @@ -182,7 +182,7 @@ protected: /** * Base class returns ReplicationCoordinatorMock. */ - virtual std::unique_ptr<repl::ReplicationCoordinatorMock> makeReplicationCoordinator( + virtual std::unique_ptr<repl::ReplicationCoordinator> makeReplicationCoordinator( repl::ReplSettings replSettings); /** @@ -264,7 +264,7 @@ private: // store a raw pointer to it here. DistLockManager* _distLockManager = nullptr; - repl::ReplicationCoordinatorMock* _replCoord = nullptr; + repl::ReplicationCoordinator* _replCoord = nullptr; // Allows for processing tasks through the NetworkInterfaceMock/ThreadPoolMock subsystem. std::unique_ptr<executor::NetworkTestEnv> _networkTestEnv; |