summaryrefslogtreecommitdiff
path: root/jstests/libs
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2018-08-06 09:44:03 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2018-08-06 09:44:03 -0400
commit5a38e3afba9061e8be9c508cc89fd13c0f305adb (patch)
treec8b70f27a2ef2a2df10ea5e6d70a71c07dc89f0f /jstests/libs
parent349140f8d0a5457524437a101b923853a8b0ee9c (diff)
downloadmongo-5a38e3afba9061e8be9c508cc89fd13c0f305adb.tar.gz
SERVER-35537 Create mongoebench for running benchRun against mobile.
It take a JSON config file with a "pre" section for any setup logic and an "ops" section for the operations that the benchRun workers should execute repeatedly. Also removes the usage of the check function from mr_shard_version.js. (cherry picked from commit a750bf210f70dd6e15cd65a15d50aeb8cd75fa3f) (cherry picked from commit acd9fd112d1c2f591f04a31ed6489d9f4b0ec0e8)
Diffstat (limited to 'jstests/libs')
-rw-r--r--jstests/libs/mongoebench.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/jstests/libs/mongoebench.js b/jstests/libs/mongoebench.js
new file mode 100644
index 00000000000..f6feb4eb9f0
--- /dev/null
+++ b/jstests/libs/mongoebench.js
@@ -0,0 +1,49 @@
+"use strict";
+
+var {runMongoeBench} = (function() {
+
+ /**
+ * Spawns a mongoebench process with the specified options.
+ *
+ * If a plain JavaScript object is specified as the 'config' parameter, then it is serialized to
+ * a file as a JSON string which is then specified as the config file for the mongoebench
+ * process.
+ */
+ function runMongoeBench(config, options = {}) {
+ const args = ["mongoebench"];
+
+ if (typeof config === "object") {
+ const filename = MongoRunner.dataPath + "mongoebench_config.json";
+ writeFile(filename, tojson(config));
+ args.push(filename);
+ } else if (typeof config === "string") {
+ args.push(config);
+ } else {
+ throw new Error("'config' parameter must be a string or an object");
+ }
+
+ if (!options.hasOwnProperty("dbpath")) {
+ options.dbpath = MongoRunner.dataDir;
+ }
+
+ for (let key of Object.keys(options)) {
+ const value = options[key];
+ if (value === null || value === undefined) {
+ throw new Error(
+ "Value '" + value + "' for '" + key +
+ "' option is ambiguous; specify {flag: ''} to add --flag command line" +
+ " options'");
+ }
+
+ args.push("--" + key);
+ if (value !== "") {
+ args.push(value.toString());
+ }
+ }
+
+ const exitCode = _runMongoProgram(...args);
+ assert.eq(0, exitCode, "encountered an error in mongoebench");
+ }
+
+ return {runMongoeBench};
+})();