diff options
author | Eric Milkie <milkie@10gen.com> | 2019-02-21 08:43:31 -0500 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2019-02-21 12:50:32 -0500 |
commit | 2151d1d219bbaff918db0d43fcb812231c20d53a (patch) | |
tree | be41fb181fd933db41c2a3e72fd38c4607719cb6 /jstests | |
parent | 18caaa34aecc860adf797e712127b639292d8903 (diff) | |
download | mongo-2151d1d219bbaff918db0d43fcb812231c20d53a.tar.gz |
SERVER-39723 Revert "SERVER-25175 listIndexes command only includes ready indexes"r3.6.11-rc1
This reverts commit 1c922de9cac97065fb018f5d049566ecba803433.
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/noPassthrough/indexbg1.js | 5 | ||||
-rw-r--r-- | jstests/noPassthrough/libs/index_build.js | 13 | ||||
-rw-r--r-- | jstests/noPassthrough/list_indexes_only_ready_indexes.js | 53 | ||||
-rw-r--r-- | jstests/noPassthroughWithMongod/indexbg_drop.js | 8 |
4 files changed, 9 insertions, 70 deletions
diff --git a/jstests/noPassthrough/indexbg1.js b/jstests/noPassthrough/indexbg1.js index ae26b4a0494..d8a9c8e56a0 100644 --- a/jstests/noPassthrough/indexbg1.js +++ b/jstests/noPassthrough/indexbg1.js @@ -2,9 +2,6 @@ (function() { "use strict"; - - load("jstests/noPassthrough/libs/index_build.js"); - const conn = MongoRunner.runMongod({smallfiles: "", nojournal: ""}); assert.neq(null, conn, "mongod failed to start."); var db = conn.getDB("test"); @@ -60,7 +57,7 @@ // wait for indexing to start print("wait for indexing to start"); assert.soon(function() { - return getIndexBuildOpId(db) != -1; + return 2 === t.getIndexes().length; }, "no index created", 30000, 50); print("started."); sleep(1000); // there is a race between when the index build shows up in curop and diff --git a/jstests/noPassthrough/libs/index_build.js b/jstests/noPassthrough/libs/index_build.js deleted file mode 100644 index 3bb78889055..00000000000 --- a/jstests/noPassthrough/libs/index_build.js +++ /dev/null @@ -1,13 +0,0 @@ -// Returns the op id for the running index build, or -1 if there is no current index build. -function getIndexBuildOpId(db) { - const result = db.currentOp(); - assert.commandWorked(result); - let indexBuildOpId = -1; - - result.inprog.forEach(function(op) { - if (op.op == 'command' && 'createIndexes' in op.command) { - indexBuildOpId = op.opid; - } - }); - return indexBuildOpId; -} diff --git a/jstests/noPassthrough/list_indexes_only_ready_indexes.js b/jstests/noPassthrough/list_indexes_only_ready_indexes.js deleted file mode 100644 index 0e6b3dfd3fe..00000000000 --- a/jstests/noPassthrough/list_indexes_only_ready_indexes.js +++ /dev/null @@ -1,53 +0,0 @@ -// SERVER-25175: Test the listIndexes command only shows ready indexes. -(function() { - "use strict"; - - load("jstests/noPassthrough/libs/index_build.js"); - - const conn = MongoRunner.runMongod({smallfiles: "", nojournal: ""}); - assert.neq(null, conn, "mongod was unable to start up"); - - const testDB = conn.getDB("test"); - assert.commandWorked(testDB.dropDatabase()); - - function assertIndexes(coll, numIndexes, indexes) { - let res = coll.runCommand("listIndexes"); - assert.eq(numIndexes, res.cursor.firstBatch.length); - for (var i = 0; i < numIndexes; i++) { - assert.eq(indexes[i], res.cursor.firstBatch[i].name); - } - } - - let coll = testDB.list_indexes_only_ready_indexes; - coll.drop(); - assert.commandWorked(testDB.createCollection(coll.getName())); - assertIndexes(coll, 1, ["_id_"]); - assert.commandWorked(coll.createIndex({a: 1})); - assertIndexes(coll, 2, ["_id_", "a_1"]); - - assert.commandWorked( - testDB.adminCommand({configureFailPoint: 'hangAfterStartingIndexBuild', mode: 'alwaysOn'})); - const createIdx = startParallelShell( - "let coll = db.getSiblingDB('test').list_indexes_only_ready_indexes;" + - "assert.commandWorked(coll.createIndex({ b: 1 }, { background: true }));", - conn.port); - assert.soon(function() { - return getIndexBuildOpId(testDB) != -1; - }, "Index build operation not found after starting via parallelShell"); - - // Verify there is no third index. - assertIndexes(coll, 2, ["_id_", "a_1"]); - - assert.commandWorked( - testDB.adminCommand({configureFailPoint: 'hangAfterStartingIndexBuild', mode: 'off'})); - // Wait for the index build to stop. - assert.soon(function() { - return getIndexBuildOpId(testDB) == -1; - }); - const exitCode = createIdx(); - assert.eq(0, exitCode, 'expected shell to exit cleanly'); - - assertIndexes(coll, 3, ["_id_", "a_1", "b_1"]); - - MongoRunner.stopMongod(conn); -}()); diff --git a/jstests/noPassthroughWithMongod/indexbg_drop.js b/jstests/noPassthroughWithMongod/indexbg_drop.js index df346f13c9b..d7cbb4a781b 100644 --- a/jstests/noPassthroughWithMongod/indexbg_drop.js +++ b/jstests/noPassthroughWithMongod/indexbg_drop.js @@ -56,6 +56,14 @@ jsTest.log("Starting background indexing for test of: " + tojson(dc)); masterDB.getCollection(collection).ensureIndex({b: 1}); masterDB.getCollection(collection).ensureIndex({i: 1}, {background: true}); +assert.eq(3, masterDB.getCollection(collection).getIndexes().length); + +// Wait for the secondary to get the index entry +assert.soon(function() { + return 3 == secondDB.getCollection(collection).getIndexes().length; +}, "index not created on secondary (prior to drop)", 240000); + +jsTest.log("Index created and index entry exists on secondary"); // make sure the index build has started on secondary assert.soon(function() { |