summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2018-09-22 15:46:43 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2018-09-22 15:46:43 -0400
commit189dd0a7a0a15efb98d5a0349964ac4ca92e06bb (patch)
treeeb19b146c5be657027dc8983d650a94cf93f18c8
parent571c94f277492978b5e51fbb88e943288f2e9505 (diff)
downloadmongo-189dd0a7a0a15efb98d5a0349964ac4ca92e06bb.tar.gz
SERVER-36069 Create script to vendor mongo-perf test cases.
The JavaScript test cases are converted into mongoebench-compatible JSON config files by using the benchrun.py script's --generateMongoeBenchConfigFiles command line option. (cherry picked from commit 34f4a07baf2e164f604ce53fd092b7dc1792e9db)
-rwxr-xr-xsrc/third_party/scripts/mongo-perf_get_sources.sh60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/third_party/scripts/mongo-perf_get_sources.sh b/src/third_party/scripts/mongo-perf_get_sources.sh
new file mode 100755
index 00000000000..a0b79b20d15
--- /dev/null
+++ b/src/third_party/scripts/mongo-perf_get_sources.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+# This script downloads the mongodb/mongo-perf repository and generates mongoebench-compatible JSON
+# config files equivalent to the JavaScript test cases.
+#
+# Turn on strict error checking, like perl use 'strict'.
+set -xeuo pipefail
+IFS=$'\n\t'
+
+if [ "$#" -ne 0 ]; then
+ echo "This script does not take any arguments"
+ exit 1
+fi
+
+# We add the current working directory to the PATH because that is where the mongo shell may have
+# been installed. The benchrun.py script is going to run the mongo shell binary that's on the PATH.
+PATH=$PATH:$(pwd)
+
+# The mongo shell processes spawned by the benchrun.py script will attempt to connect to a mongod,
+# so we just error out if we find that one isn't already running.
+mongo --eval 'db.adminCommand({ping: 1})' && rc=$? || rc=$?
+if [ "$rc" -ne 0 ]; then
+ echo "This script requires a mongod to be running on port 27017"
+ exit 2
+fi
+
+NAME=mongo-perf
+SRC_ROOT=$(mktemp -d /tmp/$NAME.XXXXXX)
+trap "rm -rf $SRC_ROOT" EXIT
+DEST_DIR=$(git rev-parse --show-toplevel)/src/third_party/$NAME
+
+git clone --branch=master https://github.com/mongodb/mongo-perf.git $SRC_ROOT
+
+pushd $SRC_ROOT
+
+# We pin to a particular commit of the mongodb/mongo-perf repository to make it clear what version
+# of the JavaScript test cases we are running.
+git checkout 824f1672b4e684ea4fdb4399e14374c5969467f9
+
+# We use Python to get the number of CPUs in a platform-agnostic way.
+NUM_CPUS=$(python -c 'import multiprocessing; print(multiprocessing.cpu_count())')
+
+# Generating the JSON config files sequentially takes ~6 minutes due to how certain JavaScript test
+# cases build up very large documents only to eventually realize upon trying to serialize them out
+# to a file that they are too big. We use `xargs -P` to speed up generating the JSON config files.
+#
+# We don't generate JSON config files for tests that are tagged with "capped" or "where" because
+# they aren't supported by embedded.
+find testcases -type f -print0 | xargs -0 -I% -n1 -P$NUM_CPUS \
+ python2 benchrun.py --testfiles % \
+ --threads 1 \
+ --excludeFilter capped \
+ --excludeFilter where \
+ --generateMongoeBenchConfigFiles mongoebench/
+
+popd
+
+test -d $DEST_DIR && rm -r $DEST_DIR
+mkdir -p $DEST_DIR
+
+mv $SRC_ROOT/mongoebench/ $DEST_DIR/