summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-07-06 11:30:04 -0400
committerBenety Goh <benety@mongodb.com>2019-07-06 11:30:27 -0400
commitfc04ae1ec734645c1f8e2828c0a367192d5bc0ec (patch)
tree0576b3e4b189d93b2e068968d5e3c9dbed113284
parent82177ac1ee32044a733be742b8244eff9389a9fc (diff)
downloadmongo-fc04ae1ec734645c1f8e2828c0a367192d5bc0ec.tar.gz
SERVER-41968 fix db.currentOp() query in index build tests to work with IndexBuildsCoordinator
-rw-r--r--jstests/noPassthrough/closeAll_with_background_ops_fails_safely.js10
-rw-r--r--jstests/noPassthrough/index_builds_ignore_prepare_conflicts.js2
-rw-r--r--jstests/noPassthrough/list_indexes_ready_and_in_progress.js2
-rw-r--r--jstests/noPassthrough/lock_stats_suboperation_curop.js8
-rw-r--r--jstests/noPassthroughWithMongod/collstats_shows_ready_and_in_progress_indexes.js8
5 files changed, 21 insertions, 9 deletions
diff --git a/jstests/noPassthrough/closeAll_with_background_ops_fails_safely.js b/jstests/noPassthrough/closeAll_with_background_ops_fails_safely.js
index 9e138eda22a..c43076d76ea 100644
--- a/jstests/noPassthrough/closeAll_with_background_ops_fails_safely.js
+++ b/jstests/noPassthrough/closeAll_with_background_ops_fails_safely.js
@@ -7,6 +7,9 @@
(function() {
"use strict";
+
+ load('jstests/noPassthrough/libs/index_build.js');
+
let replSet = new ReplSetTest({name: "server35671", nodes: 1});
let setFailpointBool = (failpointName, alwaysOn, times) => {
if (times) {
@@ -27,10 +30,9 @@
replSet.ports[0]);
// Let the createIndex start to run.
- assert.soon(function() {
- // Need to do getDB because getPrimary returns something slightly different.
- let res = db.getDB("test").currentOp({"command.createIndexes": "coll"});
- return res['ok'] === 1 && res["inprog"].length > 0;
+ IndexBuildTest.waitForIndexBuildToStart(db.getDB('test'), 'coll', 'a_1_b_1', {
+ 'locks.Global': {$exists: false},
+ progress: {$exists: true},
});
// Repeated calls should continue to fail without crashing.
diff --git a/jstests/noPassthrough/index_builds_ignore_prepare_conflicts.js b/jstests/noPassthrough/index_builds_ignore_prepare_conflicts.js
index e46177d35b0..817bdf5901c 100644
--- a/jstests/noPassthrough/index_builds_ignore_prepare_conflicts.js
+++ b/jstests/noPassthrough/index_builds_ignore_prepare_conflicts.js
@@ -52,7 +52,7 @@
// Start and pause an index build.
IndexBuildTest.pauseIndexBuilds(conn);
const awaitBuild = IndexBuildTest.startIndexBuild(primary, coll.getFullName(), {i: 1});
- const opId = IndexBuildTest.waitForIndexBuildToStart(testDB, collName, "i_1");
+ const opId = IndexBuildTest.waitForIndexBuildToScanCollection(testDB, collName, 'i_1');
// This insert will block until the index build pauses and releases its exclusive lock.
// This guarantees that the subsequent transaction can immediately acquire a lock and not
diff --git a/jstests/noPassthrough/list_indexes_ready_and_in_progress.js b/jstests/noPassthrough/list_indexes_ready_and_in_progress.js
index 0ec11308b8a..0988bb7027d 100644
--- a/jstests/noPassthrough/list_indexes_ready_and_in_progress.js
+++ b/jstests/noPassthrough/list_indexes_ready_and_in_progress.js
@@ -22,7 +22,7 @@
IndexBuildTest.pauseIndexBuilds(conn);
const createIdx =
IndexBuildTest.startIndexBuild(conn, coll.getFullName(), {b: 1}, {background: true});
- IndexBuildTest.waitForIndexBuildToStart(testDB);
+ IndexBuildTest.waitForIndexBuildToScanCollection(testDB, coll.getName(), 'b_1');
// The listIndexes command supports returning all indexes, including ones that are not ready.
IndexBuildTest.assertIndexes(coll, 3, ["_id_", "a_1"], ["b_1"], {includeBuildUUIDs: true});
diff --git a/jstests/noPassthrough/lock_stats_suboperation_curop.js b/jstests/noPassthrough/lock_stats_suboperation_curop.js
index 5d1b804d917..a6dba3116cc 100644
--- a/jstests/noPassthrough/lock_stats_suboperation_curop.js
+++ b/jstests/noPassthrough/lock_stats_suboperation_curop.js
@@ -66,8 +66,12 @@
// Wait for sub-operation createIndex to get blocked after acquiring all the locks.
let res;
assert.soon(function() {
- res = db.currentOp(
- {"command.createIndexes": {$exists: true}, "lockStats.Global": {$exists: true}});
+ res = db.currentOp({
+ 'command.createIndexes': {$exists: true},
+ 'lockStats.Global': {$exists: true},
+ 'locks.Global': {$exists: true},
+ progress: {$exists: true},
+ });
return res.inprog.length == 1;
});
jsTestLog(tojson(res.inprog[0]));
diff --git a/jstests/noPassthroughWithMongod/collstats_shows_ready_and_in_progress_indexes.js b/jstests/noPassthroughWithMongod/collstats_shows_ready_and_in_progress_indexes.js
index b6b4a9fc93d..586b4c8872f 100644
--- a/jstests/noPassthroughWithMongod/collstats_shows_ready_and_in_progress_indexes.js
+++ b/jstests/noPassthroughWithMongod/collstats_shows_ready_and_in_progress_indexes.js
@@ -37,7 +37,13 @@
// Note that we cannot use checkLog here to wait for the failpoint logging because this test
// shares a mongod with other tests that might have already provoked identical failpoint
// logging.
- IndexBuildTest.waitForIndexBuildToStart(testDB);
+ // Due to the hangAfterStartingIndexBuildUnlocked fail point, we cannot use the test helper
+ // IndexBuildTest.waitForIndexBuildToScanCollection() because locks will not be held while
+ // the fail point is active.
+ IndexBuildTest.waitForIndexBuildToStart(testDB, testColl.getName(), 'b_1', {
+ 'locks.Global': {$exists: false},
+ progress: {$exists: true},
+ });
jsTest.log("Running collStats on collection '" + collName +
"' to check for expected 'indexSizes', 'nindexes' and 'indexBuilds' results");