summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2020-03-02 19:55:13 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-03 01:06:37 +0000
commit33ba055bad586903038902825c14948038ad495e (patch)
tree00220a0d3343f1a3fda3be43d2f82f278e257ec7 /jstests/noPassthrough
parenta1f6d2eb74268b140929c3f280c37299617d596a (diff)
downloadmongo-33ba055bad586903038902825c14948038ad495e.tar.gz
SERVER-46235 log IndexDescriptor as BSON
Diffstat (limited to 'jstests/noPassthrough')
-rw-r--r--jstests/noPassthrough/index_stepdown_after_init.js18
-rw-r--r--jstests/noPassthrough/index_stepdown_before_init.js7
-rw-r--r--jstests/noPassthrough/index_stepdown_duplicate.js13
-rw-r--r--jstests/noPassthrough/index_stepdown_unique.js9
-rw-r--r--jstests/noPassthrough/indexbg_shutdown.js88
5 files changed, 109 insertions, 26 deletions
diff --git a/jstests/noPassthrough/index_stepdown_after_init.js b/jstests/noPassthrough/index_stepdown_after_init.js
index 2d2c4b96e46..f6ab28c30fa 100644
--- a/jstests/noPassthrough/index_stepdown_after_init.js
+++ b/jstests/noPassthrough/index_stepdown_after_init.js
@@ -35,10 +35,13 @@ assert.commandWorked(primary.adminCommand(
const createIdx = IndexBuildTest.startIndexBuild(primary, coll.getFullName(), {a: 1});
-if (isJsonLogNoConn()) {
- checkLog.contains(
- primary,
- /\"index build: starting on {ns} properties: {descriptor} using method: {method}\".*\"descriptor\":\"{ v: 2, key: { a:/);
+if (isJsonLog(primary)) {
+ checkLog.containsJson(primary, 20384, {
+ ns: coll.getFullName(),
+ descriptor: (desc) => {
+ return desc.name === 'a_1';
+ },
+ });
} else {
checkLog.contains(
primary,
@@ -62,9 +65,10 @@ assert.neq(0, exitCode, 'expected shell to exit abnormally due to index build be
if (!IndexBuildTest.supportsTwoPhaseIndexBuild(primary)) {
// Wait for the IndexBuildCoordinator thread, not the command thread, to report the index build
// as failed.
- if (isJsonLogNoConn()) {
- checkLog.contains(
- primary, "\"ctx\":\"IndexBuildsCoordinatorMongod-0\",\"msg\":\"Index build failed");
+ if (isJsonLog(primary)) {
+ checkLog.containsJson(primary, 20649, {
+ nss: coll.getFullName(),
+ });
} else {
checkLog.contains(primary, '[IndexBuildsCoordinatorMongod-0] Index build failed: ');
}
diff --git a/jstests/noPassthrough/index_stepdown_before_init.js b/jstests/noPassthrough/index_stepdown_before_init.js
index 3e573d7b4e7..1d17c205cdf 100644
--- a/jstests/noPassthrough/index_stepdown_before_init.js
+++ b/jstests/noPassthrough/index_stepdown_before_init.js
@@ -7,6 +7,7 @@
"use strict";
load("jstests/libs/fail_point_util.js");
+load("jstests/libs/logv2_helpers.js");
load('jstests/noPassthrough/libs/index_build.js');
const rst = new ReplSetTest({
@@ -59,7 +60,11 @@ assert.neq(0, exitCode, 'expected shell to exit abnormally due to index build be
// With both single-phase and two-phase index builds, a stepdown at this point will abort the index
// build because the builder thread cannot generate an optime. Wait for the command thread, not the
// IndexBuildsCoordinator, to report the index build as failed.
-checkLog.contains(primary, 'Index build failed: ');
+if (isJsonLog(primary)) {
+ checkLog.containsJson(primary, 20449);
+} else {
+ checkLog.contains(primary, 'Index build failed: ');
+}
// Check that no new index has been created. This verifies that the index build was aborted
// rather than successfully completed.
diff --git a/jstests/noPassthrough/index_stepdown_duplicate.js b/jstests/noPassthrough/index_stepdown_duplicate.js
index ff3db94f3d7..fb874472304 100644
--- a/jstests/noPassthrough/index_stepdown_duplicate.js
+++ b/jstests/noPassthrough/index_stepdown_duplicate.js
@@ -8,6 +8,7 @@
(function() {
"use strict";
+load('jstests/libs/logv2_helpers.js');
load('jstests/noPassthrough/libs/index_build.js');
const rst = new ReplSetTest({
@@ -37,7 +38,17 @@ assert.commandWorked(primary.adminCommand(
// Use a custom index name because we are going to reuse it later with a different key pattern.
const createIdx =
IndexBuildTest.startIndexBuild(primary, coll.getFullName(), {a: 1}, {name: 'myidx'});
-checkLog.contains(primary, new RegExp('index build: starting.*' + coll.getFullName() + '.*myidx'));
+if (isJsonLog(primary)) {
+ checkLog.containsJson(primary, 20384, {
+ ns: coll.getFullName(),
+ descriptor: (desc) => {
+ return desc.name === 'myidx';
+ },
+ });
+} else {
+ checkLog.contains(primary,
+ new RegExp('index build: starting.*' + coll.getFullName() + '.*myidx'));
+}
const newPrimary = rst.getSecondary();
diff --git a/jstests/noPassthrough/index_stepdown_unique.js b/jstests/noPassthrough/index_stepdown_unique.js
index 5a56ab5fa71..c18c7e8d0b2 100644
--- a/jstests/noPassthrough/index_stepdown_unique.js
+++ b/jstests/noPassthrough/index_stepdown_unique.js
@@ -7,6 +7,7 @@
(function() {
"use strict";
+load("jstests/libs/logv2_helpers.js");
load('jstests/noPassthrough/libs/index_build.js');
const rst = new ReplSetTest({
@@ -49,7 +50,13 @@ assert.neq(0, exitCode, 'expected shell to exit abnormally due to index build be
// Wait for the IndexBuildCoordinator thread, not the command thread, to report the index build
// as failed.
-checkLog.contains(primary, /IndexBuildsCoordinatorMongod-0.*Index build failed: /);
+if (isJsonLog(primary)) {
+ checkLog.containsJson(primary, 20649, {
+ nss: coll.getFullName(),
+ });
+} else {
+ checkLog.contains(primary, /IndexBuildsCoordinatorMongod-0.*Index build failed: /);
+}
IndexBuildTest.assertIndexes(coll, 1, ['_id_']);
rst.stopSet();
diff --git a/jstests/noPassthrough/indexbg_shutdown.js b/jstests/noPassthrough/indexbg_shutdown.js
index 0b7140eead3..30d4e543fff 100644
--- a/jstests/noPassthrough/indexbg_shutdown.js
+++ b/jstests/noPassthrough/indexbg_shutdown.js
@@ -12,6 +12,7 @@
(function() {
"use strict";
+load("jstests/libs/logv2_helpers.js");
load('jstests/noPassthrough/libs/index_build.js');
var dbname = 'bgIndexSec';
@@ -81,32 +82,87 @@ jsTestLog('Index builds started on secondary. Op ID of one of the builds: ' + op
assert.commandWorked(secondDB.killOp(opId));
// There should be a message for each index we tried to create.
-checkLog.containsWithCount(
- replTest.getSecondary(),
- new RegExp(`(index build: starting on ${
- masterColl
- .getFullName()} properties: \\{ v: 2, key: \\{ i:|index build: starting on .*"ns":"${
- masterColl.getFullName()}".*"descriptor":"\\{ v: 2, key: \\{ i)`),
- indexSpecs.length);
+if (isJsonLog(second)) {
+ checkLog.containsJson(second, 20384, {
+ ns: masterColl.getFullName(),
+ descriptor: (desc) => {
+ return desc.name === 'ij1';
+ },
+ });
+ checkLog.containsJson(second, 20384, {
+ ns: masterColl.getFullName(),
+ descriptor: (desc) => {
+ return desc.name === 'ij2';
+ },
+ });
+ checkLog.containsJson(second, 20384, {
+ ns: masterColl.getFullName(),
+ descriptor: (desc) => {
+ return desc.name === 'ij3';
+ },
+ });
+ checkLog.containsJson(second, 20384, {
+ ns: masterColl.getFullName(),
+ descriptor: (desc) => {
+ return desc.name === 'ij4';
+ },
+ });
+} else {
+ checkLog.containsWithCount(
+ second,
+ new RegExp(
+ `(index build: starting on ${
+ masterColl
+ .getFullName()} properties: \\{ v: 2, key: \\{ i:|index build: starting on .*"ns":"${
+ masterColl.getFullName()}".*"descriptor":"\\{ v: 2, key: \\{ i)`),
+ indexSpecs.length);
+}
jsTest.log("Restarting secondary to retry replication");
// Secondary should restart cleanly.
assert.commandWorked(second.adminCommand(
{configureFailPoint: 'leaveIndexBuildUnfinishedForShutdown', mode: 'alwaysOn'}));
IndexBuildTest.resumeIndexBuilds(second);
-replTest.restart(secondaryId, {}, /*wait=*/true);
+second = replTest.restart(secondaryId, {}, /*wait=*/true);
// There should again be a message for each index we tried to create, because the server
// restarts the interrupted index build upon process startup. Note, the RAMLog is reset on
// restart, so there should just be one set of messages in the RAMLog after restart, even though
// the message was logged twice in total.
-checkLog.containsWithCount(
- replTest.getSecondary(),
- new RegExp(`(index build: starting on ${
- masterColl
- .getFullName()} properties: \\{ v: 2, key: \\{ i:|index build: starting on .*"ns":"${
- masterColl.getFullName()}".*"descriptor":"\\{ v: 2, key: \\{ i)`),
- indexSpecs.length);
-
+if (isJsonLog(second)) {
+ checkLog.containsJson(second, 20384, {
+ ns: masterColl.getFullName(),
+ descriptor: (desc) => {
+ return desc.name === 'ij1';
+ },
+ });
+ checkLog.containsJson(second, 20384, {
+ ns: masterColl.getFullName(),
+ descriptor: (desc) => {
+ return desc.name === 'ij2';
+ },
+ });
+ checkLog.containsJson(second, 20384, {
+ ns: masterColl.getFullName(),
+ descriptor: (desc) => {
+ return desc.name === 'ij3';
+ },
+ });
+ checkLog.containsJson(second, 20384, {
+ ns: masterColl.getFullName(),
+ descriptor: (desc) => {
+ return desc.name === 'ij4';
+ },
+ });
+} else {
+ checkLog.containsWithCount(
+ replTest.getSecondary(),
+ new RegExp(
+ `(index build: starting on ${
+ masterColl
+ .getFullName()} properties: \\{ v: 2, key: \\{ i:|index build: starting on .*"ns":"${
+ masterColl.getFullName()}".*"descriptor":"\\{ v: 2, key: \\{ i)`),
+ indexSpecs.length);
+}
replTest.stopSet();
}());