Files
mongo/jstests/libs/mongodb_database_tools.js
Philip Stoev 749e7c3fc9 SERVER-119723 Allow a jstest to access the TPC-H dataset (#48158)
GitOrigin-RevId: 16528783332a63273179fbb602936be8b57dca18
2026-03-10 05:48:37 +00:00

57 lines
1.2 KiB
JavaScript

/**
* Allows the execution of the MongoDB Database Tools from within a jstest.
*
* The "fetch database tools" evergreen command makes those tools available
* in the environment.
*
* @class
*/
export class Mongorestore {
constructor() {
this.uri = "mongodb://" + db.getMongo().host;
}
execute({
archive,
nsFrom = undefined,
nsTo = undefined,
drop = true,
maintainInsertionOrder = true,
gzip = true,
} = {}) {
if (archive === undefined) {
throw new Error("Archive must be provided to Mongorestore.execute()");
}
let args = [
TestData.inEvergreen ? "../mongodb_database_tools/bin/mongorestore" : "mongorestore",
"--uri",
this.uri,
];
if (nsFrom) {
args.push(`--nsFrom=${nsFrom}`);
}
if (nsTo) {
args.push(`--nsTo=${nsTo}`);
}
if (maintainInsertionOrder) {
args.push("--maintainInsertionOrder");
}
if (gzip) {
args.push("--gzip");
}
if (drop) {
args.push("--drop");
}
args.push(`--archive=${archive}`);
assert.eq(runNonMongoProgram(...args), 0);
}
}