0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-24 00:17:37 +01:00

SERVER-90234 Allow jsTestName() for SELinux tests (#22535)

GitOrigin-RevId: 2413ea8f3bec5aa5c87bb9879aefa803585d5d37
This commit is contained in:
Erwin Pe 2024-05-30 16:26:17 -04:00 committed by MongoDB Bot
parent 75671f5c00
commit dbf3bd8432
4 changed files with 21 additions and 6 deletions

View File

@ -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

View File

@ -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();

View File

@ -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);

View File

@ -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}
};
}