diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2020-02-26 10:37:05 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-26 17:55:41 +0000 |
commit | 86e9d861dd056cdd71ff191ad032cc392bf9071a (patch) | |
tree | 32c6ef992429d7636d6a758e7e8a3ea4990c0eac /src/mongo/db/index_builds_coordinator_mongod_test.cpp | |
parent | 757b2175f7bf761db1170c7c1be17983d81c2389 (diff) | |
download | mongo-86e9d861dd056cdd71ff191ad032cc392bf9071a.tar.gz |
SERVER-46123 Remove ScopedStopNewDatabaseIndexBuilds/ScopedStopNewCollectionIndexBuilds and add the ability to abort index builds on the database without having to wait
Diffstat (limited to 'src/mongo/db/index_builds_coordinator_mongod_test.cpp')
-rw-r--r-- | src/mongo/db/index_builds_coordinator_mongod_test.cpp | 172 |
1 files changed, 0 insertions, 172 deletions
diff --git a/src/mongo/db/index_builds_coordinator_mongod_test.cpp b/src/mongo/db/index_builds_coordinator_mongod_test.cpp index 8a9939579b4..8709041d43f 100644 --- a/src/mongo/db/index_builds_coordinator_mongod_test.cpp +++ b/src/mongo/db/index_builds_coordinator_mongod_test.cpp @@ -258,178 +258,6 @@ TEST_F(IndexBuildsCoordinatorMongodTest, Registration) { ASSERT_NOT_EQUALS(_testFooNss, _othertestFooNss); } -// Exercises the stopIndexBuildsOnCollection/Database() and allowIndexBuildsOnCollection/Database() -// functions, checking that they correctly disallow and allow index builds when -// ScopedStopNewCollectionIndexBuilds and ScopedStopNewDatabaseIndexBuilds are present on a -// collection or database name. -TEST_F(IndexBuildsCoordinatorMongodTest, DisallowNewBuildsOnNamespace) { - { - _indexBuildsCoord->sleepIndexBuilds_forTestOnly(true); - - // Create a scoped object to block new index builds ONLY on _testFooNss. - ScopedStopNewCollectionIndexBuilds scopedStop(_indexBuildsCoord.get(), _testFooUUID); - - // Registering an index build on _testFooNss should fail. - ASSERT_EQ(ErrorCodes::CannotCreateIndex, - _indexBuildsCoord - ->startIndexBuild(operationContext(), - _testFooNss.db().toString(), - _testFooUUID, - makeSpecs(_testFooNss, {"a", "b"}), - UUID::gen(), - IndexBuildProtocol::kTwoPhase, - _indexBuildOptions) - .getStatus()); - - // Registering index builds on other collections and databases should still succeed. - auto testBarFuture = - assertGet(_indexBuildsCoord->startIndexBuild(operationContext(), - _testBarNss.db().toString(), - _testBarUUID, - makeSpecs(_testBarNss, {"c", "d"}), - UUID::gen(), - IndexBuildProtocol::kTwoPhase, - _indexBuildOptions)); - auto othertestFooFuture = - assertGet(_indexBuildsCoord->startIndexBuild(operationContext(), - _othertestFooNss.db().toString(), - _othertestFooUUID, - makeSpecs(_othertestFooNss, {"e", "f"}), - UUID::gen(), - IndexBuildProtocol::kTwoPhase, - _indexBuildOptions)); - - _indexBuildsCoord->sleepIndexBuilds_forTestOnly(false); - - auto indexCatalogStats = unittest::assertGet(testBarFuture.getNoThrow()); - ASSERT_EQ(1, indexCatalogStats.numIndexesBefore); - ASSERT_EQ(3, indexCatalogStats.numIndexesAfter); - indexCatalogStats = unittest::assertGet(othertestFooFuture.getNoThrow()); - ASSERT_EQ(1, indexCatalogStats.numIndexesBefore); - ASSERT_EQ(3, indexCatalogStats.numIndexesAfter); - } - - { - // Check that the scoped object correctly cleared. - auto testFooFuture = - assertGet(_indexBuildsCoord->startIndexBuild(operationContext(), - _testFooNss.db().toString(), - _testFooUUID, - makeSpecs(_testFooNss, {"a", "b"}), - UUID::gen(), - IndexBuildProtocol::kTwoPhase, - _indexBuildOptions)); - auto indexCatalogStats = unittest::assertGet(testFooFuture.getNoThrow()); - ASSERT_EQ(1, indexCatalogStats.numIndexesBefore); - ASSERT_EQ(3, indexCatalogStats.numIndexesAfter); - } - - { - _indexBuildsCoord->sleepIndexBuilds_forTestOnly(true); - - // Create a scoped object to block new index builds on the 'test' database. - ScopedStopNewDatabaseIndexBuilds scopedStop(_indexBuildsCoord.get(), _testFooNss.db()); - - // Registering an index build on any collection in the 'test' database should fail. - ASSERT_EQ(ErrorCodes::CannotCreateIndex, - _indexBuildsCoord - ->startIndexBuild(operationContext(), - _testFooNss.db().toString(), - _testFooUUID, - makeSpecs(_testFooNss, {"c", "d"}), - UUID::gen(), - IndexBuildProtocol::kTwoPhase, - _indexBuildOptions) - .getStatus()); - ASSERT_EQ(ErrorCodes::CannotCreateIndex, - _indexBuildsCoord - ->startIndexBuild(operationContext(), - _testBarNss.db().toString(), - _testBarUUID, - makeSpecs(_testBarNss, {"a", "b"}), - UUID::gen(), - IndexBuildProtocol::kTwoPhase, - _indexBuildOptions) - .getStatus()); - - // Registering index builds on another database should still succeed. - auto othertestFooFuture = - assertGet(_indexBuildsCoord->startIndexBuild(operationContext(), - _othertestFooNss.db().toString(), - _othertestFooUUID, - makeSpecs(_othertestFooNss, {"g", "h"}), - UUID::gen(), - IndexBuildProtocol::kTwoPhase, - _indexBuildOptions)); - - _indexBuildsCoord->sleepIndexBuilds_forTestOnly(false); - - auto indexCatalogStats = unittest::assertGet(othertestFooFuture.getNoThrow()); - ASSERT_EQ(3, indexCatalogStats.numIndexesBefore); - ASSERT_EQ(5, indexCatalogStats.numIndexesAfter); - } - - { - // Check that the scoped object correctly cleared. - auto testFooFuture = - assertGet(_indexBuildsCoord->startIndexBuild(operationContext(), - _testFooNss.db().toString(), - _testFooUUID, - makeSpecs(_testFooNss, {"c", "d"}), - UUID::gen(), - IndexBuildProtocol::kTwoPhase, - _indexBuildOptions)); - auto indexCatalogStats = unittest::assertGet(testFooFuture.getNoThrow()); - ASSERT_EQ(3, indexCatalogStats.numIndexesBefore); - ASSERT_EQ(5, indexCatalogStats.numIndexesAfter); - } - - { - // Test concurrency of multiple scoped objects to block an index builds. - - ScopedStopNewCollectionIndexBuilds scopedStop(_indexBuildsCoord.get(), _testFooUUID); - { - ScopedStopNewCollectionIndexBuilds scopedStop(_indexBuildsCoord.get(), _testFooUUID); - - ASSERT_EQ(ErrorCodes::CannotCreateIndex, - _indexBuildsCoord - ->startIndexBuild(operationContext(), - _testFooNss.db().toString(), - _testFooUUID, - makeSpecs(_testFooNss, {"e", "f"}), - UUID::gen(), - IndexBuildProtocol::kTwoPhase, - _indexBuildOptions) - .getStatus()); - } - ASSERT_EQ(ErrorCodes::CannotCreateIndex, - _indexBuildsCoord - ->startIndexBuild(operationContext(), - _testFooNss.db().toString(), - _testFooUUID, - makeSpecs(_testFooNss, {"e", "f"}), - UUID::gen(), - IndexBuildProtocol::kTwoPhase, - _indexBuildOptions) - .getStatus()); - } - - { - // Check that the scoped object correctly cleared. - auto testFooFuture = - assertGet(_indexBuildsCoord->startIndexBuild(operationContext(), - _testFooNss.db().toString(), - _testFooUUID, - makeSpecs(_testFooNss, {"e", "f"}), - UUID::gen(), - IndexBuildProtocol::kTwoPhase, - _indexBuildOptions)); - auto indexCatalogStats = unittest::assertGet(testFooFuture.getNoThrow()); - ASSERT_EQ(5, indexCatalogStats.numIndexesBefore); - ASSERT_EQ(7, indexCatalogStats.numIndexesAfter); - } -} - TEST_F(IndexBuildsCoordinatorMongodTest, SetCommitQuorumWithBadArguments) { _indexBuildsCoord->sleepIndexBuilds_forTestOnly(true); |