diff --git a/evergreen/selinux_test_setup.sh b/evergreen/selinux_test_setup.sh index c46a853f528..0553691a66a 100755 --- a/evergreen/selinux_test_setup.sh +++ b/evergreen/selinux_test_setup.sh @@ -38,3 +38,13 @@ fi if [ "$SEORDER" == "1" ]; then apply_selinux_policy fi + +# install packages needed by check_has_tag.py +PYTHON=/opt/mongodbtoolchain/v4/bin/python3 +if [[ (-f "$PYTHON" || -L "$PYTHON") && -x "$PYTHON" ]]; then + echo "==== Found python3 in $PYTHON" + $PYTHON -m pip install pyyaml +else + echo "==== Could not find $PYTHON; needed by SELinux tests" + exit 1 +fi diff --git a/jstests/core/command_let_variables_expressions.js b/jstests/core/command_let_variables_expressions.js index 200502d0eb7..53903618816 100644 --- a/jstests/core/command_let_variables_expressions.js +++ b/jstests/core/command_let_variables_expressions.js @@ -8,7 +8,7 @@ // ] import {assertArrayEq} from "jstests/aggregation/extras/utils.js"; -const coll = db.getCollection('command_let_variables_expressions'); +const coll = db.getCollection(jsTestName()); function setupColl() { coll.drop(); diff --git a/jstests/selinux/core.js b/jstests/selinux/core.js index 51e13d2dd33..f19ecf3bcb5 100644 --- a/jstests/selinux/core.js +++ b/jstests/selinux/core.js @@ -1,17 +1,19 @@ +import {getPython3Binary} from "jstests/libs/python.js"; import {SelinuxBaseTest} from "jstests/selinux/lib/selinux_base_test.js"; export class TestDefinition extends SelinuxBaseTest { async run() { - // On RHEL7 there is no python3, but check_has_tag.py will also work with python2 - const python = (0 == runNonMongoProgram("which", "python3")) ? "python3" : "python2"; + const python = getPython3Binary(); const dirs = ["jstests/core", "jstests/core_standalone"]; + const TestData = {isHintsToQuerySettingsSuite: false}; + for (let dir of dirs) { jsTest.log("Running tests in " + dir); - const all_tests = ls(dir).filter(d => !d.endsWith("/")).sort(); + const all_tests = ls(dir).filter(d => d.endsWith(".js")).sort(); assert(all_tests); assert(all_tests.length); @@ -42,9 +44,11 @@ export class TestDefinition extends SelinuxBaseTest { throw ("Failure occurred while checking tags of test: " + t); } + TestData.testName = t.substring(t.lastIndexOf('/') + 1, t.length - ".js".length); + jsTest.log("Running test: " + t); try { - let evalString = "import(" + tojson(t) + ")"; + let evalString = `TestData = ${tojson(TestData)}; load(${tojson(t)});`; let handle = startParallelShell(evalString, db.getMongo().port); let rc = handle(); assert.eq(rc, 0); diff --git a/jstests/selinux/lib/selinux_base_test.js b/jstests/selinux/lib/selinux_base_test.js index b8afaa117c9..047069c4d17 100644 --- a/jstests/selinux/lib/selinux_base_test.js +++ b/jstests/selinux/lib/selinux_base_test.js @@ -27,7 +27,8 @@ export class SelinuxBaseTest { "timeZoneInfo": "/usr/share/zoneinfo" }, "net": {"port": 27017, "bindIp": "127.0.0.1"}, - "storage": {"dbPath": "/var/lib/mongo"} + "storage": {"dbPath": "/var/lib/mongo"}, + "setParameter": {"enableTestCommands": 1} }; }