summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/libs/index_build.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/libs/index_build.js')
-rw-r--r--jstests/noPassthrough/libs/index_build.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/jstests/noPassthrough/libs/index_build.js b/jstests/noPassthrough/libs/index_build.js
new file mode 100644
index 00000000000..3bb78889055
--- /dev/null
+++ b/jstests/noPassthrough/libs/index_build.js
@@ -0,0 +1,13 @@
+// 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;
+}