diff options
author | Marcos José Grillo Ramirez <marcos.grillo@mongodb.com> | 2021-06-10 09:57:35 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-11 11:59:10 +0000 |
commit | 2ededeeda27c3b13723031e4ef7ada1e7812f046 (patch) | |
tree | 5ad691cc848463ff7bff3c4bdf96170c757ba5c7 | |
parent | 95de8844b5f79eeff5d8edcf32950a6c265b8265 (diff) | |
download | mongo-2ededeeda27c3b13723031e4ef7ada1e7812f046.tar.gz |
SERVER-54877 Move failpoint activation from setup callback to fixture initialization
(cherry picked from commit 49e1ff73fbeaaf75f36edbc87471e8d5af234115)
-rw-r--r-- | jstests/auth/commands_builtin_roles.js | 13 | ||||
-rw-r--r-- | jstests/auth/commands_user_defined_roles.js | 12 | ||||
-rw-r--r-- | jstests/auth/lib/commands_lib.js | 21 | ||||
-rw-r--r-- | jstests/noPassthrough/comment_field_passthrough.js | 12 |
4 files changed, 43 insertions, 15 deletions
diff --git a/jstests/auth/commands_builtin_roles.js b/jstests/auth/commands_builtin_roles.js index fd3b4e03b4b..3d24eb72fff 100644 --- a/jstests/auth/commands_builtin_roles.js +++ b/jstests/auth/commands_builtin_roles.js @@ -14,6 +14,7 @@ in jstests/auth/lib/commands_lib.js TestData.disableImplicitSessions = true; load("jstests/auth/lib/commands_lib.js"); +load("jstests/libs/fail_point_util.js"); var roles = [ {key: "read", role: "read", dbname: firstDbName}, @@ -93,6 +94,14 @@ function testProperAuthorization(conn, t, testcase, r) { function runOneTest(conn, t) { var failures = []; + // Some tests requires mongot, however, setting this failpoint will make search queries to + // return EOF, that way all the hassle of setting it up can be avoided. + let disableSearchFailpoint; + if (t.disableSearch) { + disableSearchFailpoint = configureFailPoint(conn.rs0 ? conn.rs0.getPrimary() : conn, + 'searchReturnEofImmediately'); + } + for (var i = 0; i < t.testcases.length; i++) { var testcase = t.testcases[i]; if (!("roles" in testcase)) { @@ -106,6 +115,10 @@ function runOneTest(conn, t) { } } + if (disableSearchFailpoint) { + disableSearchFailpoint.off(); + } + return failures; } diff --git a/jstests/auth/commands_user_defined_roles.js b/jstests/auth/commands_user_defined_roles.js index 4c1e3af4491..f214bddc9df 100644 --- a/jstests/auth/commands_user_defined_roles.js +++ b/jstests/auth/commands_user_defined_roles.js @@ -18,6 +18,7 @@ var testUser = "userDefinedRolesTestUser"; var testRole = "userDefinedRolesTestRole"; load("jstests/auth/lib/commands_lib.js"); +load("jstests/libs/fail_point_util.js"); /** * Run the command specified in 't' with the privileges specified in 'privileges'. @@ -98,6 +99,13 @@ function runOneTest(conn, t) { var failures = []; var msg; + // Some tests requires mongot, however, setting this failpoint will make search queries to + // return EOF, that way all the hassle of setting it up can be avoided. + let disableSearchFailpoint; + if (t.disableSearch) { + disableSearchFailpoint = configureFailPoint(conn.rs0 ? conn.rs0.getPrimary() : conn, + 'searchReturnEofImmediately'); + } for (var i = 0; i < t.testcases.length; i++) { var testcase = t.testcases[i]; if (!("privileges" in testcase)) { @@ -185,6 +193,10 @@ function runOneTest(conn, t) { } } + if (disableSearchFailpoint) { + disableSearchFailpoint.off(); + } + return failures; } diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js index e3309ed2d48..4618bb9320d 100644 --- a/jstests/auth/lib/commands_lib.js +++ b/jstests/auth/lib/commands_lib.js @@ -5971,11 +5971,12 @@ var authCommandsLib = { }] }, skipSharded: false, - skipTest: (conn) => true, // TODO SERVER-54877 re-enable this test case // Only enterprise knows of this aggregation stage. - //skipTest: - // (conn) => - // !conn.getDB("admin").runCommand({buildInfo: 1}).modules.includes("enterprise"), + skipTest: + (conn) => + !conn.getDB("admin").runCommand({buildInfo: 1}).modules.includes("enterprise"), + // Instead of configuring mongot, lets make the search to return EOF early. + disableSearch: true, testcases: [ { runOnDb: firstDbName, @@ -5988,17 +5989,7 @@ var authCommandsLib = { privileges: [{resource: {db: secondDbName, collection: "foo"}, actions: ["find"]}] } - ], - setup: function(db) { - // Configure the $search stage to always return EOF so we can avoid the hassle - // of giving mongod a host and port for mongot. - const cmd = {configureFailPoint: "searchReturnEofImmediately", mode: "alwaysOn"}; - FixtureHelpers.runCommandOnEachPrimary({db: db.getSiblingDB("admin"), cmdObj: cmd}); - }, - teardown: function(db) { - const cmd = {configureFailPoint: "searchReturnEofImmediately", mode: "off"}; - FixtureHelpers.runCommandOnEachPrimary({db: db.getSiblingDB("admin"), cmdObj: cmd}); - } + ] }, { testname: "startRecordingTraffic", diff --git a/jstests/noPassthrough/comment_field_passthrough.js b/jstests/noPassthrough/comment_field_passthrough.js index e0a3ff66adb..221b56f4950 100644 --- a/jstests/noPassthrough/comment_field_passthrough.js +++ b/jstests/noPassthrough/comment_field_passthrough.js @@ -14,6 +14,7 @@ "use strict"; load("jstests/auth/lib/commands_lib.js"); // Provides an exhaustive list of commands. +load("jstests/libs/fail_point_util.js"); // Helper to enable/disable failpoints easily. const tests = authCommandsLib.tests; @@ -34,6 +35,13 @@ function runTests(tests, conn, impls) { const impls = { runOneTest: function(conn, testObj) { + // Some tests requires mongot, however, setting this failpoint will make search queries to + // return EOF, that way all the hassle of setting it up can be avoided. + let disableSearchFailpoint; + if (testObj.disableSearch) { + disableSearchFailpoint = configureFailPoint(conn.rs0 ? conn.rs0.getPrimary() : conn, + 'searchReturnEofImmediately'); + } const testCase = testObj.testcases[0]; const runOnDb = conn.getDB(testCase.runOnDb); @@ -50,6 +58,10 @@ const impls = { if (testObj.teardown) { testObj.teardown(runOnDb, res); } + + if (disableSearchFailpoint) { + disableSearchFailpoint.off(); + } } }; |