From dbf4a2fcc177f64452ce84eff82a3bd165edc546 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Sun, 7 Jan 2018 14:52:50 -0500 Subject: [PATCH 01/39] fix(test-environments): ensure all servers run on separate ports NODE-884 --- test/environments.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/environments.js b/test/environments.js index 0536a5fd6..54708057c 100644 --- a/test/environments.js +++ b/test/environments.js @@ -37,11 +37,11 @@ class ReplicaSetEnvironment extends EnvironmentBase { 'mongod', [ genReplsetConfig(31000, { tags: { loc: 'ny' } }), - genReplsetConfig(31000, { tags: { loc: 'sf' } }), + genReplsetConfig(31001, { tags: { loc: 'sf' } }), genReplsetConfig(31002, { tags: { loc: 'sf' } }), genReplsetConfig(31003, { tags: { loc: 'sf' } }), - genReplsetConfig(31000, { tags: { loc: 'sf' } }), - genReplsetConfig(31000, { arbiter: true }) + genReplsetConfig(31004, { tags: { loc: 'sf' } }), + genReplsetConfig(31005, { arbiter: true }) ], { replSet: 'rs' From 3e9675e998b1e61796ae0547b9d65ed2d77710cb Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 8 Jan 2018 09:23:41 -0500 Subject: [PATCH 02/39] test(environment): add compat names for mongo orchestration This just makes our evergreen configuration look a little more like other drivers at very little cost to us. NODE-884 --- test/environments.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/environments.js b/test/environments.js index 54708057c..518644a1c 100644 --- a/test/environments.js +++ b/test/environments.js @@ -190,5 +190,10 @@ module.exports = { replicaset: ReplicaSetEnvironment, sharded: ShardedEnvironment, auth: AuthEnvironment, - snappy: SnappyEnvironment + snappy: SnappyEnvironment, + + // compat for mongo orchestration + server: SingleEnvironment, + replica_set: ReplicaSetEnvironment, + sharded_cluster: ShardedEnvironment }; From a780fa6c459e2d3499ccb20f0e5980f83d9915be Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 8 Jan 2018 09:24:47 -0500 Subject: [PATCH 03/39] chore(evergreen): add initial evergreen configuration NODE-884 --- .evg.yml | 268 +++++++++++++++++++++++++++++++++++++++++++ test/environments.js | 7 +- 2 files changed, 269 insertions(+), 6 deletions(-) create mode 100644 .evg.yml diff --git a/.evg.yml b/.evg.yml new file mode 100644 index 000000000..fa9474e6a --- /dev/null +++ b/.evg.yml @@ -0,0 +1,268 @@ +stepback: true +command_type: system + +functions: + "fetch source": + - command: git.get_project + params: + directory: "src" + + "fetch nodejs": + - command: shell.exec + type: system + params: + script: | + curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" + nvm install --lts=argon + + "run tests": + - command: shell.exec + type: system + params: + working_dir: "src" + script: | + export PATH="/opt/mongodbtoolchain/bin:$PATH" + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" + + npm install + MONGODB_VERSION=${VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test + +pre: + - func: "fetch source" + - func: "fetch nodejs" + +tasks: + - name: "test-2.6-standalone" + tags: ["2.6", "standalone"] + commands: + - func: "run tests" + vars: + VERSION: "2.6" + TOPOLOGY: "single" + + - name: "test-2.6-replica_set" + tags: ["2.6", "replica_set"] + commands: + - func: "run tests" + vars: + VERSION: "2.6" + TOPOLOGY: "replicaset" + + - name: "test-2.6-sharded_cluster" + tags: ["2.6", "sharded_cluster"] + commands: + - func: "run tests" + vars: + VERSION: "2.6" + TOPOLOGY: "sharded" + + - name: "test-3.0-standalone" + tags: ["3.0", "standalone"] + commands: + - func: "run tests" + vars: + VERSION: "3.0" + TOPOLOGY: "single" + + - name: "test-3.0-replica_set" + tags: ["3.0", "replica_set"] + commands: + - func: "run tests" + vars: + VERSION: "3.0" + TOPOLOGY: "replicaset" + + - name: "test-3.0-sharded_cluster" + tags: ["3.0", "sharded_cluster"] + commands: + - func: "run tests" + vars: + VERSION: "3.0" + TOPOLOGY: "sharded" + + - name: "test-3.2-standalone" + tags: ["3.2", "standalone"] + commands: + - func: "run tests" + vars: + VERSION: "3.2" + TOPOLOGY: "single" + + - name: "test-3.2-replica_set" + tags: ["3.2", "replica_set"] + commands: + - func: "run tests" + vars: + VERSION: "3.2" + TOPOLOGY: "replicaset" + + - name: "test-3.2-sharded_cluster" + tags: ["3.2", "sharded_cluster"] + commands: + - func: "run tests" + vars: + VERSION: "3.2" + TOPOLOGY: "sharded" + + - name: "test-3.4-standalone" + tags: ["3.4", "standalone"] + commands: + - func: "run tests" + vars: + VERSION: "3.4" + TOPOLOGY: "single" + + - name: "test-3.4-replica_set" + tags: ["3.4", "replica_set"] + commands: + - func: "run tests" + vars: + VERSION: "3.4" + TOPOLOGY: "replicaset" + + - name: "test-3.4-sharded_cluster" + tags: ["3.4", "sharded_cluster"] + commands: + - func: "run tests" + vars: + VERSION: "3.4" + TOPOLOGY: "sharded" + + - name: "test-3.6-standalone" + tags: ["3.6", "standalone"] + commands: + - func: "run tests" + vars: + VERSION: "3.6" + TOPOLOGY: "single" + + - name: "test-3.6-replica_set" + tags: ["3.6", "replica_set"] + commands: + - func: "run tests" + vars: + VERSION: "3.6" + TOPOLOGY: "replicaset" + + - name: "test-3.6-sharded_cluster" + tags: ["3.6", "sharded_cluster"] + commands: + - func: "run tests" + vars: + VERSION: "3.6" + TOPOLOGY: "sharded" + + - name: "test-latest-standalone" + tags: ["latest", "standalone"] + commands: + - func: "run tests" + vars: + VERSION: "latest" + TOPOLOGY: "single" + + - name: "test-latest-replica_set" + tags: ["latest", "replica_set"] + commands: + - func: "run tests" + vars: + VERSION: "latest" + TOPOLOGY: "replicaset" + + - name: "test-latest-sharded_cluster" + tags: ["latest", "sharded_cluster"] + commands: + - func: "run tests" + vars: + VERSION: "latest" + TOPOLOGY: "sharded" + +axes: + - id: versions + display_name: MongoDB Version + values: + - id: "latest" + display_name: "latest" + variables: + VERSION: "latest" + - id: "3.6" + display_name: "3.6" + variables: + VERSION: "3.6" + - id: "3.4" + display_name: "3.4" + variables: + VERSION: "3.4" + - id: "3.2" + display_name: "3.2" + variables: + VERSION: "3.2" + - id: "3.0" + display_name: "3.0" + variables: + VERSION: "3.0" + - id: "2.6" + display_name: "2.6" + variables: + VERSION: "2.6" + - id: os + display_name: OS + values: + - name: os_rhel62 + display_name: RHEL 6.2 + run_on: + - rhel62-test + - rhel62-build + - rhel62-large + - rhel62-small + - id: os_suse12_zseries + display_name: SUSE 12 Z Series + run_on: + - suse12-zseries-build + - suse12-zseries-test + - id: os_ubuntu1604_arm64 + display_name: Ubuntu 16.04 ARM64 + run_on: + - ubuntu1604-arm64-large + - ubuntu1604-arm64-small + - id: os_ubuntu1604_power8 + display_name: Ubuntu 16.04 Power8 + run_on: + - ubuntu1604-power8-build + - ubuntu1604-power8-test + - id: os_windows64 + display_name: Win64 + run_on: + - windows-64-vs2013-compile + - windows-64-vs2013-test + - windows-64-vs2015-compile + - windows-64-vs2015-test + - windows-64-vs2015-small + - windows-64-vs2015-large + - id: node-version + display_name: "Node.js" + values: + - id: "Argon" + display_name: "Node.js Argon LTS" + variables: + NODE_LTS: "argon" + - id: "Boron" + display_name: "Node.js Boron LTS" + variables: + NODE_LTS: "boron" + +buildvariants: +- matrix_name: "tests-all" + matrix_spec: { os: "*", node-version: '*' } + display_name: "${os} ${node-version}" + tasks: + - ".latest" + - ".3.6" + - ".3.4" + - ".3.2" + - ".3.0" + - ".2.6" diff --git a/test/environments.js b/test/environments.js index 518644a1c..54708057c 100644 --- a/test/environments.js +++ b/test/environments.js @@ -190,10 +190,5 @@ module.exports = { replicaset: ReplicaSetEnvironment, sharded: ShardedEnvironment, auth: AuthEnvironment, - snappy: SnappyEnvironment, - - // compat for mongo orchestration - server: SingleEnvironment, - replica_set: ReplicaSetEnvironment, - sharded_cluster: ShardedEnvironment + snappy: SnappyEnvironment }; From 3268a8999301f78963289bee0ee532a926998edb Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Mon, 29 Jan 2018 13:41:48 -0500 Subject: [PATCH 04/39] fix(evergreen): change nvm path to local --- .evg.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.evg.yml b/.evg.yml index fa9474e6a..1134a99e0 100644 --- a/.evg.yml +++ b/.evg.yml @@ -12,11 +12,10 @@ functions: type: system params: script: | + export NVM_DIR="$HOME/src/.nvm" curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash - export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" - nvm install --lts=argon + nvm install --lts=${NODE_LTS_NAME} "run tests": - command: shell.exec @@ -25,9 +24,8 @@ functions: working_dir: "src" script: | export PATH="/opt/mongodbtoolchain/bin:$PATH" - export NVM_DIR="$HOME/.nvm" + export NVM_DIR="$HOME/src/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" npm install MONGODB_VERSION=${VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test @@ -249,11 +247,11 @@ axes: - id: "Argon" display_name: "Node.js Argon LTS" variables: - NODE_LTS: "argon" + NODE_LTS_NAME: "argon" - id: "Boron" display_name: "Node.js Boron LTS" variables: - NODE_LTS: "boron" + NODE_LTS_NAME: "boron" buildvariants: - matrix_name: "tests-all" From 21afc38505fed93de55af152d91931c3ae3de59a Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 8 Jan 2018 09:24:47 -0500 Subject: [PATCH 05/39] chore(evergreen): add initial evergreen configuration NODE-884 --- .evg.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evg.yml b/.evg.yml index 1134a99e0..e605bd617 100644 --- a/.evg.yml +++ b/.evg.yml @@ -23,7 +23,7 @@ functions: params: working_dir: "src" script: | - export PATH="/opt/mongodbtoolchain/bin:$PATH" + export PATH="/opt/mongodbtoolchain/v2/bin:$PATH" export NVM_DIR="$HOME/src/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" From e56a82c9da7963962cf9c4dd0f1e36478c9436f8 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Tue, 30 Jan 2018 17:45:13 -0500 Subject: [PATCH 06/39] refactor(evergreen): use type `test` to reduce system failures NODE-884 --- .evg.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evg.yml b/.evg.yml index e605bd617..886fd4b7b 100644 --- a/.evg.yml +++ b/.evg.yml @@ -19,7 +19,7 @@ functions: "run tests": - command: shell.exec - type: system + type: test params: working_dir: "src" script: | From 08c395f522be5077e02e47040cf287df561ab1e8 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 8 Feb 2018 16:45:25 -0500 Subject: [PATCH 07/39] fix(evergreen): change name to id --- .evg.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evg.yml b/.evg.yml index 886fd4b7b..db1bd8de6 100644 --- a/.evg.yml +++ b/.evg.yml @@ -210,7 +210,7 @@ axes: - id: os display_name: OS values: - - name: os_rhel62 + - id: os_rhel62 display_name: RHEL 6.2 run_on: - rhel62-test From 8386f0f705b2fe8ffae3d55073150089d34c9f44 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Fri, 9 Feb 2018 11:13:21 -0500 Subject: [PATCH 08/39] feat(evergreen): use evergreen flag when running tests this will pass the option down to `mongodb-download-url` and enable detection of Linux Distributions --- .evg.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.evg.yml b/.evg.yml index db1bd8de6..7834cd49a 100644 --- a/.evg.yml +++ b/.evg.yml @@ -28,7 +28,8 @@ functions: [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" npm install - MONGODB_VERSION=${VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test + MONGODB_VERSION=${VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} + mongodb-test-runner --evergreen -t 60000 test/tests/functional pre: - func: "fetch source" From 3142eb467d92e6550faac33ad847573939e6d945 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Fri, 9 Feb 2018 11:54:13 -0500 Subject: [PATCH 09/39] fix(evergreen): pass in flag through npm scripts --- .evg.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.evg.yml b/.evg.yml index 7834cd49a..393cb5a5c 100644 --- a/.evg.yml +++ b/.evg.yml @@ -28,8 +28,7 @@ functions: [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" npm install - MONGODB_VERSION=${VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} - mongodb-test-runner --evergreen -t 60000 test/tests/functional + MONGODB_VERSION=${VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test -- --evergreen pre: - func: "fetch source" From 08839c3258c0e7d68aea74b1d08eb0424174c3ae Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Fri, 9 Mar 2018 09:38:30 -0500 Subject: [PATCH 10/39] feat(evergreen): add evergreen config based on drivers skeleton This ditches my original custom configuration in favor of one based on the skeleton provided in drivers-evergreen-tools. NODE-884 --- .evergreen/config.yml | 760 +++++++++++++++++++++++++++++ .evergreen/install-dependencies.sh | 12 + .evergreen/run-tests.sh | 33 ++ 3 files changed, 805 insertions(+) create mode 100644 .evergreen/config.yml create mode 100644 .evergreen/install-dependencies.sh create mode 100755 .evergreen/run-tests.sh diff --git a/.evergreen/config.yml b/.evergreen/config.yml new file mode 100644 index 000000000..3af4afb9a --- /dev/null +++ b/.evergreen/config.yml @@ -0,0 +1,760 @@ +# When a task that used to pass starts to fail +# Go through all versions that may have been skipped to detect +# when the task started failing +stepback: true + +# Mark a failure as a system/bootstrap failure (purple box) rather then a task +# failure by default. +# Actual testing tasks are marked with `type: test` +command_type: system + +# Protect ourself against rogue test case, or curl gone wild, that runs forever +# Good rule of thumb: the averageish length a task takes, times 5 +# That roughly accounts for variable system performance for various buildvariants +exec_timeout_secs: 1800 # 6 minutes is the longest we'll ever run + +# What to do when evergreen hits the timeout (`post:` tasks are run automatically) +timeout: + - command: shell.exec + params: + script: | + ls -la + +functions: + "fetch source": + # Executes git clone and applies the submitted patch, if any + - command: git.get_project + params: + directory: "src" + # Applies the submitted patch, if any + # Deprecated. Should be removed. But still needed for certain agents (ZAP) + - command: git.apply_patch + # Make an evergreen exapanstion file with dynamic values + - command: shell.exec + params: + working_dir: "src" + script: | + # Get the current unique version of this checkout + if [ "${is_patch}" = "true" ]; then + CURRENT_VERSION=$(git describe)-patch-${version_id} + else + CURRENT_VERSION=latest + fi + + export DRIVERS_TOOLS="$(pwd)/../drivers-tools" + export PROJECT_DIRECTORY="$(pwd)" + + # Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory + if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin + export DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS) + export PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY) + fi + + export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration" + export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" + export UPLOAD_BUCKET="${project}" + + cat < expansion.yml + CURRENT_VERSION: "$CURRENT_VERSION" + DRIVERS_TOOLS: "$DRIVERS_TOOLS" + MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME" + MONGODB_BINARIES: "$MONGODB_BINARIES" + UPLOAD_BUCKET: "$UPLOAD_BUCKET" + PROJECT_DIRECTORY: "$PROJECT_DIRECTORY" + PREPARE_SHELL: | + set -o errexit + set -o xtrace + export DRIVERS_TOOLS="$DRIVERS_TOOLS" + export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME" + export MONGODB_BINARIES="$MONGODB_BINARIES" + export UPLOAD_BUCKET="$UPLOAD_BUCKET" + export PROJECT_DIRECTORY="$PROJECT_DIRECTORY" + + export TMPDIR="$MONGO_ORCHESTRATION_HOME/db" + export PATH="$MONGODB_BINARIES:$PATH" + export PROJECT="${project}" + EOT + # See what we've done + cat expansion.yml + + # Load the expansion file to make an evergreen variable with the current unique version + - command: expansions.update + params: + file: src/expansion.yml + + "prepare resources": + - command: shell.exec + params: + script: | + ${PREPARE_SHELL} + rm -rf $DRIVERS_TOOLS + git clone git://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS + echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config + + "upload release": + - command: s3.put + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + local_file: ${project}.tar.gz + remote_file: ${UPLOAD_BUCKET}/${project}-${CURRENT_VERSION}.tar.gz + bucket: mciuploads + permissions: public-read + content_type: ${content_type|application/x-gzip} + + "exec compile script" : + - command: shell.exec + type: test + params: + working_dir: "src" + script: | + ${PREPARE_SHELL} + [ -f ${PROJECT_DIRECTORY}/${file} ] && BUILDTOOL="${buildtool}" sh ${PROJECT_DIRECTORY}/${file} || echo "${PROJECT_DIRECTORY}/${file} not available, skipping" + + "exec script" : + - command: shell.exec + type: test + params: + working_dir: "src" + script: | + ${PREPARE_SHELL} + [ -f ${PROJECT_DIRECTORY}/${file} ] && sh ${PROJECT_DIRECTORY}/${file} || echo "${PROJECT_DIRECTORY}/${file} not available, skipping" + + "bootstrap mongo-orchestration": + - command: shell.exec + params: + script: | + ${PREPARE_SHELL} + MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} SSL=${SSL} STORAGE_ENGINE=${STORAGE_ENGINE} sh ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh + # run-orchestration generates expansion file with the MONGODB_URI for the cluster + - command: expansions.update + params: + file: mo-expansion.yml + + "stop mongo-orchestration": + - command: shell.exec + params: + script: | + ${PREPARE_SHELL} + sh ${DRIVERS_TOOLS}/.evergreen/stop-orchestration.sh + + "run tests": + - command: shell.exec + type: test + params: + working_dir: "src" + script: | + ${PREPARE_SHELL} + AUTH=${AUTH} SSL=${SSL} MONGODB_URI="${MONGODB_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh + + "cleanup": + - command: shell.exec + params: + script: | + ${PREPARE_SHELL} + rm -rf $DRIVERS_TOOLS || true + + "fix absolute paths": + - command: shell.exec + params: + script: | + ${PREPARE_SHELL} + for filename in $(find ${DRIVERS_TOOLS} -name \*.json); do + perl -p -i -e "s|ABSOLUTE_PATH_REPLACEMENT_TOKEN|${DRIVERS_TOOLS}|g" $filename + done + + "windows fix": + - command: shell.exec + params: + script: | + ${PREPARE_SHELL} + for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do + cat $i | tr -d '\r' > $i.new + mv $i.new $i + done + # Copy client certificate because symlinks do not work on Windows. + cp ${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem ${MONGO_ORCHESTRATION_HOME}/lib/client.pem + + "make files executable": + - command: shell.exec + params: + script: | + ${PREPARE_SHELL} + for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do + chmod +x $i + done + + "install dependencies": + - command: shell.exec + params: + working_dir: "src" + script: | + ${PREPARE_SHELL} + file="${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh" + # Don't use ${file} syntax here because evergreen treats it as an empty expansion. + [ -f "$file" ] && sh $file || echo "$file not available, skipping" + +pre: + - func: "fetch source" + - func: "prepare resources" + - func: "windows fix" + - func: "fix absolute paths" + - func: "make files executable" + - func: "install dependencies" + +post: + - func: "stop mongo-orchestration" + - func: "cleanup" + +tasks: +# Standard test tasks {{{ + - name: "test-2.6-standalone" + tags: ["2.6", "standalone"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "2.6" + TOPOLOGY: "server" + - func: "run tests" + + - name: "test-2.6-replica_set" + tags: ["2.6", "replica_set"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "2.6" + TOPOLOGY: "replica_set" + - func: "run tests" + + - name: "test-2.6-sharded_cluster" + tags: ["2.6", "sharded_cluster"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "2.6" + TOPOLOGY: "sharded_cluster" + - func: "run tests" + + - name: "test-3.0-standalone" + tags: ["3.0", "standalone"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "3.0" + TOPOLOGY: "server" + - func: "run tests" + + - name: "test-3.0-replica_set" + tags: ["3.0", "replica_set"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "3.0" + TOPOLOGY: "replica_set" + - func: "run tests" + + - name: "test-3.0-sharded_cluster" + tags: ["3.0", "sharded_cluster"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "3.0" + TOPOLOGY: "sharded_cluster" + - func: "run tests" + + - name: "test-3.2-standalone" + tags: ["3.2", "standalone"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "3.2" + TOPOLOGY: "server" + - func: "run tests" + + - name: "test-3.2-replica_set" + tags: ["3.2", "replica_set"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "3.2" + TOPOLOGY: "replica_set" + - func: "run tests" + + - name: "test-3.2-sharded_cluster" + tags: ["3.2", "sharded_cluster"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "3.2" + TOPOLOGY: "sharded_cluster" + - func: "run tests" + + - name: "test-3.4-standalone" + tags: ["3.4", "standalone"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "3.4" + TOPOLOGY: "server" + - func: "run tests" + + - name: "test-3.4-replica_set" + tags: ["3.4", "replica_set"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "3.4" + TOPOLOGY: "replica_set" + - func: "run tests" + + - name: "test-3.4-sharded_cluster" + tags: ["3.4", "sharded_cluster"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "3.4" + TOPOLOGY: "sharded_cluster" + - func: "run tests" + - name: "test-3.6-standalone" + tags: ["3.6", "standalone"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "3.6" + TOPOLOGY: "server" + - func: "run tests" + + - name: "test-3.6-replica_set" + tags: ["3.6", "replica_set"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "3.6" + TOPOLOGY: "replica_set" + - func: "run tests" + + - name: "test-3.6-sharded_cluster" + tags: ["3.6", "sharded_cluster"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "3.6" + TOPOLOGY: "sharded_cluster" + - func: "run tests" + + - name: "test-latest-standalone" + tags: ["latest", "standalone"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "latest" + TOPOLOGY: "server" + - func: "run tests" + + - name: "test-latest-replica_set" + tags: ["latest", "replica_set"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "latest" + TOPOLOGY: "replica_set" + - func: "run tests" + + - name: "test-latest-sharded_cluster" + tags: ["latest", "sharded_cluster"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "latest" + TOPOLOGY: "sharded_cluster" + - func: "run tests" + +# }}} + +axes: + - id: versions + display_name: MongoDB Version + values: + - id: "latest" + display_name: "latest" + variables: + VERSION: "latest" + - id: "3.6" + display_name: "3.6" + variables: + VERSION: "3.6" + - id: "3.4" + display_name: "3.4" + variables: + VERSION: "3.4" + - id: "3.2" + display_name: "3.2" + variables: + VERSION: "3.2" + - id: "3.0" + display_name: "3.0" + variables: + VERSION: "3.0" + - id: "2.6" + display_name: "2.6" + variables: + VERSION: "2.6" + + - id: node-version + display_name: "Node.js Version" + values: + - id: "Argon" + display_name: "argon" + variables: + NODE_LTS_NAME: "argon" + - id: "Boron" + display_name: "boron" + variables: + NODE_LTS_NAME: "boron" + - id: "Carbon" + display_name: "carbon" + variables: + NODE_LTS_NAME: "carbon" + + # OSes that support versions of MongoDB>=2.6 with SSL. + - id: os-fully-featured + display_name: OS + values: + - id: ubuntu1204-test + display_name: "Ubuntu 12.04" + run_on: ubuntu1204-test + + - id: suse11-x86-64-test + display_name: "SUSE 11 (x86_64)" + run_on: suse11-test + + - id: linux-64-amzn-test + display_name: "Amazon Linux (Enterprise)" + run_on: linux-64-amzn-test + + # OSes that support versions of MongoDB without SSL. + - id: os-nossl + display_name: OS + values: + - id: archlinux-test + display_name: "Archlinux" + run_on: archlinux-test + + - id: macos-1012 + display_name: "macOS 10.12" + run_on: macos-1012 + + - id: os-windows + display_name: OS + values: + - id: windows-64-vs2010-test + display_name: "Windows (VS2010)" + run_on: windows-64-vs2010-test + + - id: windows-64-vs2013-test + display_name: "Windows (VS2013)" + run_on: windows-64-vs2013-test + + - id: windows-64-vs2015-test + display_name: "Windows (VS2015)" + run_on: windows-64-vs2015-test + + # OSes that support versions of MongoDB>=2.6 with SSL. + - id: os-requires-26 + display_name: OS + values: + - id: ubuntu-14.04 + display_name: "Ubuntu 14.04" + run_on: ubuntu1404-test + + - id: rhel70 + display_name: "RHEL 7.0" + run_on: rhel70-small + + - id: debian71-test + display_name: "Debian 7.1" + run_on: debian71-test + + # OSes that support versions of MongoDB>=3.2 with SSL. + - id: os-requires-32 + display_name: OS + values: + - id: suse12-x86-64-test + display_name: "SUSE 12 (x86_64)" + run_on: suse12-test + + - id: ubuntu-16.04 + display_name: "Ubuntu 16.04" + run_on: ubuntu1604-test + + - id: rhel71-power8-test + display_name: "RHEL 7.1 (POWER8)" + run_on: rhel71-power8-test + + # OSes that introduced support for SSL with MongoDB>=3.2. + - id: os-ssl-requires-32 + display_name: OS + values: + - id: macos-1012 + display_name: "macOS 10.12" + run_on: macos-1012 + + # OSes that support versions of MongoDB>=3.4 with SSL. + - id: os-requires-34 + display_name: OS + values: + - id: debian81-test + display_name: "Debian 8.1" + run_on: debian81-test + + - id: rhel72-zseries-test + display_name: "RHEL 7.2 (zSeries)" + run_on: rhel72-zseries-test + + - id: suse12-zseries-test + display_name: "SUSE 12 (zSeries)" + run_on: suse12-zseries-test + + - id: ubuntu1604-arm64-small + display_name: "Ubuntu 16.04 (ARM64)" + run_on: ubuntu1604-arm64-small + + - id: ubuntu1604-power8-test + display_name: "Ubuntu 16.04 (POWER8)" + run_on: ubuntu1604-power8-test + + - id: ubuntu1604-zseries-small + display_name: "Ubuntu 16.04 (zSeries)" + run_on: ubuntu1604-zseries-small + + # OSes that support versions of MongoDB>=4.0 with SSL. + - id: os-requires-40 + display_name: OS + values: + - id: debian92-test + display_name: "Debian 9.2" + run_on: debian92-test + + - id: topology + display_name: Topology + values: + - id: standalone + display_name: Standalone + variables: + TOPOLOGY: "server" + - id: replicaset + display_name: Replica Set + variables: + TOPOLOGY: "replica_set" + - id: sharded-cluster + display_name: Sharded Cluster + variables: + TOPOLOGY: "sharded_cluster" + - id: auth + display_name: Authentication + values: + - id: auth + display_name: Auth + variables: + AUTH: "auth" + - id: noauth + display_name: NoAuth + variables: + AUTH: "noauth" + - id: ssl + display_name: SSL + values: + - id: ssl + display_name: SSL + variables: + SSL: "ssl" + - id: nossl + display_name: NoSSL + variables: + SSL: "nossl" + - id: storage-engine + display_name: Storage + values: + - id: mmapv1 + display_name: MMAPv1 + variables: + STORAGE_ENGINE: "mmapv1" + - id: wiredtiger + display_name: WiredTiger + variables: + STORAGE_ENGINE: "wiredtiger" + - id: inmemory + display_name: InMemory + variables: + STORAGE_ENGINE: "inmemory" + + +buildvariants: +- matrix_name: "tests-all" + matrix_spec: {"os-fully-featured": "*", auth: "*", ssl: "*" } + display_name: "${os-fully-featured} ${auth} ${ssl}" + tasks: + - name: "test-latest-replica_set" + - name: "test-latest-sharded_cluster" + - name: "test-latest-standalone" + - name: "test-3.6-replica_set" + - name: "test-3.6-sharded_cluster" + - name: "test-3.6-standalone" + - name: "test-3.4-replica_set" + - name: "test-3.4-sharded_cluster" + - name: "test-3.4-standalone" + - name: "test-3.2-replica_set" + - name: "test-3.2-sharded_cluster" + - name: "test-3.2-standalone" + - name: "test-3.0-replica_set" + - name: "test-3.0-sharded_cluster" + - name: "test-3.0-standalone" + - name: "test-2.6-replica_set" + - name: "test-2.6-sharded_cluster" + - name: "test-2.6-standalone" + +- matrix_name: "tests-nossl" + matrix_spec: {"os-nossl": "*", auth: "*", ssl: "nossl" } + display_name: "${os-nossl} ${auth} ${ssl}" + tasks: + - name: "test-latest-replica_set" + - name: "test-latest-sharded_cluster" + - name: "test-latest-standalone" + - name: "test-3.6-replica_set" + - name: "test-3.6-sharded_cluster" + - name: "test-3.6-standalone" + - name: "test-3.4-replica_set" + - name: "test-3.4-sharded_cluster" + - name: "test-3.4-standalone" + - name: "test-3.2-replica_set" + - name: "test-3.2-sharded_cluster" + - name: "test-3.2-standalone" + - name: "test-3.0-replica_set" + - name: "test-3.0-sharded_cluster" + - name: "test-3.0-standalone" + - name: "test-2.6-replica_set" + - name: "test-2.6-sharded_cluster" + - name: "test-2.6-standalone" + +- matrix_name: "tests-os-requires-26" + matrix_spec: {"os-requires-26": "*", auth: "*", ssl: "*" } + display_name: "${os-requires-26} ${auth} ${ssl}" + tasks: + - name: "test-latest-replica_set" + - name: "test-latest-sharded_cluster" + - name: "test-latest-standalone" + - name: "test-3.6-replica_set" + - name: "test-3.6-sharded_cluster" + - name: "test-3.6-standalone" + - name: "test-3.4-replica_set" + - name: "test-3.4-sharded_cluster" + - name: "test-3.4-standalone" + - name: "test-3.2-replica_set" + - name: "test-3.2-sharded_cluster" + - name: "test-3.2-standalone" + - name: "test-3.0-replica_set" + - name: "test-3.0-sharded_cluster" + - name: "test-3.0-standalone" + - name: "test-2.6-replica_set" + - name: "test-2.6-sharded_cluster" + - name: "test-2.6-standalone" + +- matrix_name: "tests-os-requires-32" + matrix_spec: {"os-requires-32": "*", auth: "*", ssl: "*" } + display_name: "${os-requires-32} ${auth} ${ssl}" + tasks: + - name: "test-latest-replica_set" + - name: "test-latest-sharded_cluster" + - name: "test-latest-standalone" + - name: "test-3.6-replica_set" + - name: "test-3.6-sharded_cluster" + - name: "test-3.6-standalone" + - name: "test-3.4-replica_set" + - name: "test-3.4-sharded_cluster" + - name: "test-3.4-standalone" + - name: "test-3.2-replica_set" + - name: "test-3.2-sharded_cluster" + - name: "test-3.2-standalone" + +- matrix_name: "tests-ssl-requires-32" + matrix_spec: {"os-ssl-requires-32": "*", auth: "*", ssl: "ssl" } + display_name: "${os-ssl-requires-32} ${auth} ${ssl}" + tasks: + - name: "test-latest-replica_set" + - name: "test-latest-sharded_cluster" + - name: "test-latest-standalone" + - name: "test-3.6-replica_set" + - name: "test-3.6-sharded_cluster" + - name: "test-3.6-standalone" + - name: "test-3.4-replica_set" + - name: "test-3.4-sharded_cluster" + - name: "test-3.4-standalone" + - name: "test-3.2-replica_set" + - name: "test-3.2-sharded_cluster" + - name: "test-3.2-standalone" + +- matrix_name: "tests-os-requires-34" + matrix_spec: {"os-requires-34": "*", auth: "*", ssl: "*" } + display_name: "${os-requires-34} ${auth} ${ssl}" + tasks: + - name: "test-latest-replica_set" + - name: "test-latest-sharded_cluster" + - name: "test-latest-standalone" + - name: "test-3.6-replica_set" + - name: "test-3.6-sharded_cluster" + - name: "test-3.6-standalone" + - name: "test-3.4-replica_set" + - name: "test-3.4-sharded_cluster" + - name: "test-3.4-standalone" + +- matrix_name: "tests-os-requires-40" + matrix_spec: {"os-requires-40": "*", auth: "*", ssl: "*" } + display_name: "${os-requires-40} ${auth} ${ssl}" + tasks: + - name: "test-latest-replica_set" + - name: "test-latest-sharded_cluster" + - name: "test-latest-standalone" + +# Storage Engine Tests on Amazon Linux (Enterprise) +- matrix_name: "tests-storage-engines" + matrix_spec: {"os-fully-featured": "linux-64-amzn-test", storage-engine: "*" } + display_name: "${os-fully-featured} ${storage-engine}" + rules: + - if: + os-fully-featured: "*" + storage-engine: ["mmapv1", "inmemory"] + then: + add_tasks: + - "test-latest-standalone" + - "test-3.6-standalone" + - "test-3.4-standalone" + - "test-3.2-standalone" + - if: + os-fully-featured: "*" + storage-engine: "wiredtiger" + then: + add_tasks: + - "test-3.0-standalone" + +- matrix_name: "tests-windows" + matrix_spec: {os-windows: "*", auth: "*", ssl: "*" } + display_name: "${os-windows} ${auth} ${ssl}" + tasks: + - name: "test-latest-replica_set" + - name: "test-latest-sharded_cluster" + - name: "test-latest-standalone" + - name: "test-3.6-replica_set" + - name: "test-3.6-sharded_cluster" + - name: "test-3.6-standalone" + - name: "test-3.4-replica_set" + - name: "test-3.4-sharded_cluster" + - name: "test-3.4-standalone" + - name: "test-3.2-replica_set" + - name: "test-3.2-sharded_cluster" + - name: "test-3.2-standalone" + - name: "test-3.0-replica_set" + - name: "test-3.0-sharded_cluster" + - name: "test-3.0-standalone" + - name: "test-2.6-replica_set" + - name: "test-2.6-sharded_cluster" + - name: "test-2.6-standalone" diff --git a/.evergreen/install-dependencies.sh b/.evergreen/install-dependencies.sh new file mode 100644 index 000000000..1483ae2b3 --- /dev/null +++ b/.evergreen/install-dependencies.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -o xtrace # Write all commands first to stderr +set -o errexit # Exit the script with error if any of the commands fail + +# install Node.js +export NVM_DIR="$HOME/src/.nvm" +curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +nvm install --lts=${NODE_LTS_NAME} + +# install node dependencies +npm install diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh new file mode 100755 index 000000000..f5cc3bc7d --- /dev/null +++ b/.evergreen/run-tests.sh @@ -0,0 +1,33 @@ +#!/bin/sh +set -o xtrace # Write all commands first to stderr +set -o errexit # Exit the script with error if any of the commands fail + +# Supported/used environment variables: +# AUTH Set to enable authentication. Defaults to "noauth" +# SSL Set to enable SSL. Defaults to "nossl" +# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info) +# MARCH Machine Architecture. Defaults to lowercase uname -m + +AUTH=${AUTH:-noauth} +SSL=${SSL:-nossl} +MONGODB_URI=${MONGODB_URI:-} + +OS=$(uname -s | tr '[:upper:]' '[:lower:]') +[ -z "$MARCH" ] && MARCH=$(uname -m | tr '[:upper:]' '[:lower:]') + +if [ "$AUTH" != "noauth" ]; then + export MONGOC_TEST_USER="bob" + export MONGOC_TEST_PASSWORD="pwd123" +fi + +if [ "$SSL" != "nossl" ]; then + export MONGOC_TEST_SSL_PEM_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem" + export MONGOC_TEST_SSL_CA_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem" +fi + +echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI" + +export PATH="/opt/mongodbtoolchain/v2/bin:$PATH" +export NVM_DIR="$HOME/src/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +MONGODB_VERSION=${VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test -- --skipStartup --local From 2bc6ff0ecb479027e16dfe2eb22d5064cc0d24f2 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Fri, 9 Mar 2018 09:42:37 -0500 Subject: [PATCH 11/39] refactor(test): support environment aliases for evergreen NODE-884 --- test/environments.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/environments.js b/test/environments.js index 54708057c..4ebb8280d 100644 --- a/test/environments.js +++ b/test/environments.js @@ -190,5 +190,10 @@ module.exports = { replicaset: ReplicaSetEnvironment, sharded: ShardedEnvironment, auth: AuthEnvironment, - snappy: SnappyEnvironment + snappy: SnappyEnvironment, + + // for compatability with evergreen template + server: SingleEnvironment, + replica_set: ReplicaSetEnvironment, + sharded_cluster: ShardedEnvironment }; From eebada79ca2ce85881878fbd951034f18c5301e4 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Fri, 9 Mar 2018 09:56:21 -0500 Subject: [PATCH 12/39] chore(evergreen): ensure variables are passed into run-tests.sh NODE-884 --- .evergreen/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 3af4afb9a..cd1772ec8 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -145,7 +145,7 @@ functions: working_dir: "src" script: | ${PREPARE_SHELL} - AUTH=${AUTH} SSL=${SSL} MONGODB_URI="${MONGODB_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh + VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} SSL=${SSL} MONGODB_URI="${MONGODB_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh "cleanup": - command: shell.exec @@ -190,7 +190,7 @@ functions: working_dir: "src" script: | ${PREPARE_SHELL} - file="${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh" + NODE_LTS_NAME=${NODE_LTS_NAME} file="${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh" # Don't use ${file} syntax here because evergreen treats it as an empty expansion. [ -f "$file" ] && sh $file || echo "$file not available, skipping" From 0d15e6aac632091c2dd636dbeab9265238ceaad0 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Fri, 9 Mar 2018 10:45:40 -0500 Subject: [PATCH 13/39] chore(evergreen): add node-version to matrix builds --- .evergreen/config.yml | 63 ++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 43 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index cd1772ec8..6f9123f01 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -190,9 +190,7 @@ functions: working_dir: "src" script: | ${PREPARE_SHELL} - NODE_LTS_NAME=${NODE_LTS_NAME} file="${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh" - # Don't use ${file} syntax here because evergreen treats it as an empty expansion. - [ -f "$file" ] && sh $file || echo "$file not available, skipping" + NODE_LTS_NAME=${NODE_LTS_NAME} sh ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh pre: - func: "fetch source" @@ -404,15 +402,15 @@ axes: display_name: "Node.js Version" values: - id: "Argon" - display_name: "argon" + display_name: "Node.js Argon" variables: NODE_LTS_NAME: "argon" - id: "Boron" - display_name: "boron" + display_name: "Node.js Boron" variables: NODE_LTS_NAME: "boron" - id: "Carbon" - display_name: "carbon" + display_name: "Node.js Carbon" variables: NODE_LTS_NAME: "carbon" @@ -591,8 +589,8 @@ axes: buildvariants: - matrix_name: "tests-all" - matrix_spec: {"os-fully-featured": "*", auth: "*", ssl: "*" } - display_name: "${os-fully-featured} ${auth} ${ssl}" + matrix_spec: {"os-fully-featured": "*", auth: "*", ssl: "*", node-version: "*" } + display_name: "${node-version} ${os-fully-featured} ${auth} ${ssl}" tasks: - name: "test-latest-replica_set" - name: "test-latest-sharded_cluster" @@ -614,8 +612,8 @@ buildvariants: - name: "test-2.6-standalone" - matrix_name: "tests-nossl" - matrix_spec: {"os-nossl": "*", auth: "*", ssl: "nossl" } - display_name: "${os-nossl} ${auth} ${ssl}" + matrix_spec: {"os-nossl": "*", auth: "*", ssl: "nossl", node-version: "*" } + display_name: "${node-version} ${os-nossl} ${auth} ${ssl}" tasks: - name: "test-latest-replica_set" - name: "test-latest-sharded_cluster" @@ -637,8 +635,8 @@ buildvariants: - name: "test-2.6-standalone" - matrix_name: "tests-os-requires-26" - matrix_spec: {"os-requires-26": "*", auth: "*", ssl: "*" } - display_name: "${os-requires-26} ${auth} ${ssl}" + matrix_spec: {"os-requires-26": "*", auth: "*", ssl: "*", node-version: "*" } + display_name: "${node-version} ${os-requires-26} ${auth} ${ssl}" tasks: - name: "test-latest-replica_set" - name: "test-latest-sharded_cluster" @@ -660,8 +658,8 @@ buildvariants: - name: "test-2.6-standalone" - matrix_name: "tests-os-requires-32" - matrix_spec: {"os-requires-32": "*", auth: "*", ssl: "*" } - display_name: "${os-requires-32} ${auth} ${ssl}" + matrix_spec: {"os-requires-32": "*", auth: "*", ssl: "*", node-version: "*" } + display_name: "${node-version} ${os-requires-32} ${auth} ${ssl}" tasks: - name: "test-latest-replica_set" - name: "test-latest-sharded_cluster" @@ -677,8 +675,8 @@ buildvariants: - name: "test-3.2-standalone" - matrix_name: "tests-ssl-requires-32" - matrix_spec: {"os-ssl-requires-32": "*", auth: "*", ssl: "ssl" } - display_name: "${os-ssl-requires-32} ${auth} ${ssl}" + matrix_spec: {"os-ssl-requires-32": "*", auth: "*", ssl: "ssl", node-version: "*" } + display_name: "${node-version} ${os-ssl-requires-32} ${auth} ${ssl}" tasks: - name: "test-latest-replica_set" - name: "test-latest-sharded_cluster" @@ -694,8 +692,8 @@ buildvariants: - name: "test-3.2-standalone" - matrix_name: "tests-os-requires-34" - matrix_spec: {"os-requires-34": "*", auth: "*", ssl: "*" } - display_name: "${os-requires-34} ${auth} ${ssl}" + matrix_spec: {"os-requires-34": "*", auth: "*", ssl: "*", node-version: "*" } + display_name: "${node-version} ${os-requires-34} ${auth} ${ssl}" tasks: - name: "test-latest-replica_set" - name: "test-latest-sharded_cluster" @@ -708,37 +706,16 @@ buildvariants: - name: "test-3.4-standalone" - matrix_name: "tests-os-requires-40" - matrix_spec: {"os-requires-40": "*", auth: "*", ssl: "*" } - display_name: "${os-requires-40} ${auth} ${ssl}" + matrix_spec: {"os-requires-40": "*", auth: "*", ssl: "*", node-version: "*" } + display_name: "${node-version} ${os-requires-40} ${auth} ${ssl}" tasks: - name: "test-latest-replica_set" - name: "test-latest-sharded_cluster" - name: "test-latest-standalone" -# Storage Engine Tests on Amazon Linux (Enterprise) -- matrix_name: "tests-storage-engines" - matrix_spec: {"os-fully-featured": "linux-64-amzn-test", storage-engine: "*" } - display_name: "${os-fully-featured} ${storage-engine}" - rules: - - if: - os-fully-featured: "*" - storage-engine: ["mmapv1", "inmemory"] - then: - add_tasks: - - "test-latest-standalone" - - "test-3.6-standalone" - - "test-3.4-standalone" - - "test-3.2-standalone" - - if: - os-fully-featured: "*" - storage-engine: "wiredtiger" - then: - add_tasks: - - "test-3.0-standalone" - - matrix_name: "tests-windows" - matrix_spec: {os-windows: "*", auth: "*", ssl: "*" } - display_name: "${os-windows} ${auth} ${ssl}" + matrix_spec: {os-windows: "*", auth: "*", ssl: "*", node-version: "*" } + display_name: "${node-version} ${os-windows} ${auth} ${ssl}" tasks: - name: "test-latest-replica_set" - name: "test-latest-sharded_cluster" From b6b4632198a9aea51737f56ea53403886e0cd9a1 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Fri, 9 Mar 2018 14:52:16 -0500 Subject: [PATCH 14/39] chore(evergreen): name environments to property alias for evg NODE-884 --- test/environments.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/environments.js b/test/environments.js index 4ebb8280d..e4ca488de 100644 --- a/test/environments.js +++ b/test/environments.js @@ -10,6 +10,10 @@ const ReplSetManager = topologyManagers.ReplSet; const ShardingManager = topologyManagers.Sharded; class ReplicaSetEnvironment extends EnvironmentBase { + static get displayName() { + return 'replicaset'; + } + constructor() { super(); @@ -78,6 +82,10 @@ const genConfigServerConfig = (port, options) => { }; class ShardedEnvironment extends EnvironmentBase { + static get displayName() { + return 'sharded'; + } + constructor() { super(); @@ -148,6 +156,10 @@ class ShardedEnvironment extends EnvironmentBase { } class AuthEnvironment extends EnvironmentBase { + static get displayName() { + return 'auth'; + } + constructor() { super(); @@ -161,6 +173,10 @@ class AuthEnvironment extends EnvironmentBase { } class SingleEnvironment extends EnvironmentBase { + static get displayName() { + return 'single'; + } + constructor() { super(); @@ -173,6 +189,10 @@ class SingleEnvironment extends EnvironmentBase { } class SnappyEnvironment extends EnvironmentBase { + static get displayName() { + return 'snappy'; + } + constructor() { super(); From 27022d7628be9c3c1ffefa9fd38c91f7a3e6689a Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Fri, 9 Mar 2018 16:46:13 -0500 Subject: [PATCH 15/39] test(evergreen): disable tests that use the topology manager These tests should either be converted to using the mock server, or we need to update the test configuration to detect whether we are running on evergreen or not, and use the orchestration's rest api to do what we're asking here. NODE-884 --- .../basic_single_server_auth_tests.js | 18 ++++++++++------ .../tests/functional/client_metadata_tests.js | 3 ++- test/tests/functional/cursor_tests.js | 3 ++- test/tests/functional/pool_tests.js | 21 ++++++++++++------- test/tests/functional/server_tests.js | 9 +++++--- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/test/tests/functional/basic_single_server_auth_tests.js b/test/tests/functional/basic_single_server_auth_tests.js index a198dc47c..ebc665602 100644 --- a/test/tests/functional/basic_single_server_auth_tests.js +++ b/test/tests/functional/basic_single_server_auth_tests.js @@ -8,7 +8,8 @@ var expect = require('chai').expect, Bson = require('bson'); describe('Basic single server auth tests', function() { - it('should fail to authenticate server using scram-sha-1 using connect auth', { + // Skipped due to use of topology manager + it.skip('should fail to authenticate server using scram-sha-1 using connect auth', { metadata: { requires: { topology: 'auth' } }, test: function(done) { @@ -56,7 +57,8 @@ describe('Basic single server auth tests', function() { } }); - it('should correctly authenticate server using scram-sha-1 using connect auth', { + // Skipped due to use of topology manager + it.skip('should correctly authenticate server using scram-sha-1 using connect auth', { metadata: { requires: { topology: 'auth' } }, test: function(done) { @@ -118,7 +120,8 @@ describe('Basic single server auth tests', function() { } }); - it( + // Skipped due to use of topology manager + it.skip( 'should correctly authenticate server using scram-sha-1 using connect auth and maintain auth on new connections', { metadata: { requires: { topology: 'auth' } }, @@ -217,7 +220,8 @@ describe('Basic single server auth tests', function() { } ); - it('should correctly authenticate server using scram-sha-1 using auth method', { + // Skipped due to use of topology manager + it.skip('should correctly authenticate server using scram-sha-1 using auth method', { metadata: { requires: { topology: 'auth' } }, test: function(done) { @@ -327,7 +331,8 @@ describe('Basic single server auth tests', function() { } }); - it('should correctly authenticate server using scram-sha-1 using connect auth then logout', { + // Skipped due to use of topology manager + it.skip('should correctly authenticate server using scram-sha-1 using connect auth then logout', { metadata: { requires: { topology: 'auth' } }, test: function(done) { @@ -414,7 +419,8 @@ describe('Basic single server auth tests', function() { } }); - it('should correctly have server auth wait for logout to finish', { + // Skipped due to use of topology manager + it.skip('should correctly have server auth wait for logout to finish', { metadata: { requires: { topology: 'auth' } }, test: function(done) { diff --git a/test/tests/functional/client_metadata_tests.js b/test/tests/functional/client_metadata_tests.js index 37e9adc9b..bb1cec11a 100644 --- a/test/tests/functional/client_metadata_tests.js +++ b/test/tests/functional/client_metadata_tests.js @@ -23,7 +23,8 @@ describe('Client metadata tests', function() { } }); - it('should correctly pass the configuration settings to replset', { + // Skipped due to use of topology manager + it.skip('should correctly pass the configuration settings to replset', { metadata: { requires: { topology: 'replicaset' } }, test: function(done) { diff --git a/test/tests/functional/cursor_tests.js b/test/tests/functional/cursor_tests.js index 75640eb25..28c7f7812 100644 --- a/test/tests/functional/cursor_tests.js +++ b/test/tests/functional/cursor_tests.js @@ -381,7 +381,8 @@ describe('Cursor tests', function() { } }); - it('Should fail cursor correctly after server restart', { + // Skipped due to usage of the topology manager + it.skip('Should fail cursor correctly after server restart', { metadata: { requires: { topology: ['single'] } }, diff --git a/test/tests/functional/pool_tests.js b/test/tests/functional/pool_tests.js index 47f8a6018..4a0141288 100644 --- a/test/tests/functional/pool_tests.js +++ b/test/tests/functional/pool_tests.js @@ -247,7 +247,8 @@ describe('Pool tests', function() { } }); - it('should correctly write ismaster operation to the server and handle timeout', { + // Skipped due to use of topology manager + it.skip('should correctly write ismaster operation to the server and handle timeout', { metadata: { requires: { topology: 'single' } }, test: function(done) { @@ -418,7 +419,8 @@ describe('Pool tests', function() { } }); - it('should correctly recover from a longer server outage', { + // Skipped due to use of topology manager + it.skip('should correctly recover from a longer server outage', { metadata: { requires: { topology: 'single' }, ignore: { travis: true } @@ -548,7 +550,8 @@ describe('Pool tests', function() { } }); - it('should correctly authenticate using scram-sha-1 using connect auth', { + // Skipped due to use of topology manager + it.skip('should correctly authenticate using scram-sha-1 using connect auth', { metadata: { requires: { topology: 'auth' } }, test: function(done) { @@ -611,7 +614,8 @@ describe('Pool tests', function() { } }); - it( + // Skipped due to use of topology manager + it.skip( 'should correctly authenticate using scram-sha-1 using connect auth and maintain auth on new connections', { metadata: { requires: { topology: 'auth' } }, @@ -819,7 +823,8 @@ describe('Pool tests', function() { } ); - it('should correctly authenticate using scram-sha-1 using auth method', { + // Skipped due to use of topology manager + it.skip('should correctly authenticate using scram-sha-1 using auth method', { metadata: { requires: { topology: 'auth' } }, test: function(done) { @@ -944,7 +949,8 @@ describe('Pool tests', function() { } }); - it('should correctly authenticate using scram-sha-1 using connect auth then logout', { + // Skipped due to use of topology manager + it.skip('should correctly authenticate using scram-sha-1 using connect auth then logout', { metadata: { requires: { topology: 'auth' } }, test: function(done) { @@ -1037,7 +1043,8 @@ describe('Pool tests', function() { } }); - it('should correctly have auth wait for logout to finish', { + // Skipped due to use of topology manager + it.skip('should correctly have auth wait for logout to finish', { metadata: { requires: { topology: 'auth' } }, test: function(done) { diff --git a/test/tests/functional/server_tests.js b/test/tests/functional/server_tests.js index c62674ca7..2ffa3a565 100644 --- a/test/tests/functional/server_tests.js +++ b/test/tests/functional/server_tests.js @@ -332,7 +332,8 @@ describe('Server tests', function() { } }); - it('should correctly recover with multiple restarts', { + // Skipped due to use of topology manager + it.skip('should correctly recover with multiple restarts', { metadata: { requires: { topology: ['single'] } }, @@ -880,7 +881,8 @@ describe('Server tests', function() { } }); - it( + // Skipped due to use of topology manager + it.skip( 'should correctly connect server specifying compression to single instance with authentication and insert documents', { metadata: { requires: { topology: ['auth', 'snappyCompression'] } }, @@ -949,7 +951,8 @@ describe('Server tests', function() { } ); - it( + // Skipped due to use of topology manager + it.skip( 'should fail to connect server specifying compression to single instance with incorrect authentication credentials', { metadata: { requires: { topology: ['auth', 'snappyCompression'] } }, From ccdc2d6440a3a55963326bba56b52768ef7ceb64 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Fri, 9 Mar 2018 16:47:30 -0500 Subject: [PATCH 16/39] refactor(evergreen): don't show all commands in setup/test scripts NODE-884 --- .evergreen/install-dependencies.sh | 2 +- .evergreen/run-tests.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.evergreen/install-dependencies.sh b/.evergreen/install-dependencies.sh index 1483ae2b3..8592e7e1f 100644 --- a/.evergreen/install-dependencies.sh +++ b/.evergreen/install-dependencies.sh @@ -1,5 +1,5 @@ #!/bin/sh -set -o xtrace # Write all commands first to stderr +# set -o xtrace # Write all commands first to stderr set -o errexit # Exit the script with error if any of the commands fail # install Node.js diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index f5cc3bc7d..db15ca0e5 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -1,5 +1,5 @@ #!/bin/sh -set -o xtrace # Write all commands first to stderr +# set -o xtrace # Write all commands first to stderr set -o errexit # Exit the script with error if any of the commands fail # Supported/used environment variables: From f3b2812512aa7385d6afbabc6e3236e96459c535 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Sat, 10 Mar 2018 09:41:35 -0500 Subject: [PATCH 17/39] test(evergreen): use internal topology manager for tests --- .evergreen/config.yml | 148 ++++++++++++++--------------- .evergreen/install-dependencies.sh | 17 ++++ .evergreen/run-tests.sh | 2 +- 3 files changed, 92 insertions(+), 75 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 6f9123f01..06ffd5c88 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -190,7 +190,7 @@ functions: working_dir: "src" script: | ${PREPARE_SHELL} - NODE_LTS_NAME=${NODE_LTS_NAME} sh ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh + DRIVERS_TOOLS=${DRIVERS_TOOLS} MONGODB_VERSION=${VERSION} NODE_LTS_NAME=${NODE_LTS_NAME} sh ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh pre: - func: "fetch source" @@ -201,7 +201,7 @@ pre: - func: "install dependencies" post: - - func: "stop mongo-orchestration" + # - func: "stop mongo-orchestration" - func: "cleanup" tasks: @@ -209,162 +209,162 @@ tasks: - name: "test-2.6-standalone" tags: ["2.6", "standalone"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "2.6" - TOPOLOGY: "server" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "2.6" + # TOPOLOGY: "server" - func: "run tests" - name: "test-2.6-replica_set" tags: ["2.6", "replica_set"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "2.6" - TOPOLOGY: "replica_set" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "2.6" + # TOPOLOGY: "replica_set" - func: "run tests" - name: "test-2.6-sharded_cluster" tags: ["2.6", "sharded_cluster"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "2.6" - TOPOLOGY: "sharded_cluster" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "2.6" + # TOPOLOGY: "sharded_cluster" - func: "run tests" - name: "test-3.0-standalone" tags: ["3.0", "standalone"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.0" - TOPOLOGY: "server" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "3.0" + # TOPOLOGY: "server" - func: "run tests" - name: "test-3.0-replica_set" tags: ["3.0", "replica_set"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.0" - TOPOLOGY: "replica_set" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "3.0" + # TOPOLOGY: "replica_set" - func: "run tests" - name: "test-3.0-sharded_cluster" tags: ["3.0", "sharded_cluster"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.0" - TOPOLOGY: "sharded_cluster" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "3.0" + # TOPOLOGY: "sharded_cluster" - func: "run tests" - name: "test-3.2-standalone" tags: ["3.2", "standalone"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.2" - TOPOLOGY: "server" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "3.2" + # TOPOLOGY: "server" - func: "run tests" - name: "test-3.2-replica_set" tags: ["3.2", "replica_set"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.2" - TOPOLOGY: "replica_set" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "3.2" + # TOPOLOGY: "replica_set" - func: "run tests" - name: "test-3.2-sharded_cluster" tags: ["3.2", "sharded_cluster"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.2" - TOPOLOGY: "sharded_cluster" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "3.2" + # TOPOLOGY: "sharded_cluster" - func: "run tests" - name: "test-3.4-standalone" tags: ["3.4", "standalone"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.4" - TOPOLOGY: "server" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "3.4" + # TOPOLOGY: "server" - func: "run tests" - name: "test-3.4-replica_set" tags: ["3.4", "replica_set"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.4" - TOPOLOGY: "replica_set" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "3.4" + # TOPOLOGY: "replica_set" - func: "run tests" - name: "test-3.4-sharded_cluster" tags: ["3.4", "sharded_cluster"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.4" - TOPOLOGY: "sharded_cluster" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "3.4" + # TOPOLOGY: "sharded_cluster" - func: "run tests" - name: "test-3.6-standalone" tags: ["3.6", "standalone"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.6" - TOPOLOGY: "server" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "3.6" + # TOPOLOGY: "server" - func: "run tests" - name: "test-3.6-replica_set" tags: ["3.6", "replica_set"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.6" - TOPOLOGY: "replica_set" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "3.6" + # TOPOLOGY: "replica_set" - func: "run tests" - name: "test-3.6-sharded_cluster" tags: ["3.6", "sharded_cluster"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.6" - TOPOLOGY: "sharded_cluster" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "3.6" + # TOPOLOGY: "sharded_cluster" - func: "run tests" - name: "test-latest-standalone" tags: ["latest", "standalone"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "latest" - TOPOLOGY: "server" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "latest" + # TOPOLOGY: "server" - func: "run tests" - name: "test-latest-replica_set" tags: ["latest", "replica_set"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "latest" - TOPOLOGY: "replica_set" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "latest" + # TOPOLOGY: "replica_set" - func: "run tests" - name: "test-latest-sharded_cluster" tags: ["latest", "sharded_cluster"] commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "latest" - TOPOLOGY: "sharded_cluster" + # - func: "bootstrap mongo-orchestration" + # vars: + # VERSION: "latest" + # TOPOLOGY: "sharded_cluster" - func: "run tests" # }}} diff --git a/.evergreen/install-dependencies.sh b/.evergreen/install-dependencies.sh index 8592e7e1f..1bd891df9 100644 --- a/.evergreen/install-dependencies.sh +++ b/.evergreen/install-dependencies.sh @@ -2,6 +2,23 @@ # set -o xtrace # Write all commands first to stderr set -o errexit # Exit the script with error if any of the commands fail +# script args +NODE_LTS_NAME=${NODE_LTS_NAME:-carbon} +MONGODB_VERSION=${MONGODB_VERSION:-latest} +DIR=$(dirname $0) + +# install MongoDB +# Functions to fetch MongoDB binaries +. ${DRIVERS_TOOLS}/.evergreen/download-mongodb.sh + +get_distro +if [ -z "$MONGODB_DOWNLOAD_URL" ]; then + get_mongodb_download_url_for "$DISTRO" "$MONGODB_VERSION" +fi +# Even though we have the MONGODB_DOWNLOAD_URL, we still call this to get the proper EXTRACT variable +get_mongodb_download_url_for "$DISTRO" +download_and_extract "$MONGODB_DOWNLOAD_URL" "$EXTRACT" + # install Node.js export NVM_DIR="$HOME/src/.nvm" curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index db15ca0e5..ab4391deb 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -30,4 +30,4 @@ echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI" export PATH="/opt/mongodbtoolchain/v2/bin:$PATH" export NVM_DIR="$HOME/src/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" -MONGODB_VERSION=${VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test -- --skipStartup --local +MONGODB_VERSION=${VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test -- --local From c467957b68e94fd3fd5db94488a477c4489e0347 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Sat, 10 Mar 2018 10:24:28 -0500 Subject: [PATCH 18/39] test(evergreen): add variables into "run tests" tasks --- .evergreen/config.yml | 127 ++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 72 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 06ffd5c88..9d6e72efb 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -209,163 +209,146 @@ tasks: - name: "test-2.6-standalone" tags: ["2.6", "standalone"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "2.6" - # TOPOLOGY: "server" - func: "run tests" + vars: + VERSION: "2.6" + TOPOLOGY: "server" - name: "test-2.6-replica_set" tags: ["2.6", "replica_set"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "2.6" - # TOPOLOGY: "replica_set" - func: "run tests" + vars: + VERSION: "2.6" + TOPOLOGY: "replica_set" - name: "test-2.6-sharded_cluster" tags: ["2.6", "sharded_cluster"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "2.6" - # TOPOLOGY: "sharded_cluster" - func: "run tests" + vars: + VERSION: "2.6" + TOPOLOGY: "sharded_cluster" - name: "test-3.0-standalone" tags: ["3.0", "standalone"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "3.0" - # TOPOLOGY: "server" - func: "run tests" + vars: + VERSION: "3.0" + TOPOLOGY: "server" - name: "test-3.0-replica_set" tags: ["3.0", "replica_set"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "3.0" - # TOPOLOGY: "replica_set" - func: "run tests" + vars: + VERSION: "3.0" + TOPOLOGY: "replica_set" - name: "test-3.0-sharded_cluster" tags: ["3.0", "sharded_cluster"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "3.0" - # TOPOLOGY: "sharded_cluster" - func: "run tests" + vars: + VERSION: "3.0" + TOPOLOGY: "sharded_cluster" - name: "test-3.2-standalone" tags: ["3.2", "standalone"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "3.2" - # TOPOLOGY: "server" - func: "run tests" + vars: + VERSION: "3.2" + TOPOLOGY: "server" - name: "test-3.2-replica_set" tags: ["3.2", "replica_set"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "3.2" - # TOPOLOGY: "replica_set" - func: "run tests" + vars: + VERSION: "3.2" + TOPOLOGY: "replica_set" - name: "test-3.2-sharded_cluster" tags: ["3.2", "sharded_cluster"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "3.2" - # TOPOLOGY: "sharded_cluster" - func: "run tests" + vars: + VERSION: "3.2" + TOPOLOGY: "sharded_cluster" - name: "test-3.4-standalone" tags: ["3.4", "standalone"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "3.4" - # TOPOLOGY: "server" - func: "run tests" + vars: + VERSION: "3.4" + TOPOLOGY: "server" - name: "test-3.4-replica_set" tags: ["3.4", "replica_set"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "3.4" - # TOPOLOGY: "replica_set" - func: "run tests" + vars: + VERSION: "3.4" + TOPOLOGY: "replica_set" - name: "test-3.4-sharded_cluster" tags: ["3.4", "sharded_cluster"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "3.4" - # TOPOLOGY: "sharded_cluster" - func: "run tests" + vars: + VERSION: "3.4" + TOPOLOGY: "sharded_cluster" + - name: "test-3.6-standalone" tags: ["3.6", "standalone"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "3.6" - # TOPOLOGY: "server" - func: "run tests" + vars: + VERSION: "3.6" + TOPOLOGY: "server" - name: "test-3.6-replica_set" tags: ["3.6", "replica_set"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "3.6" - # TOPOLOGY: "replica_set" - func: "run tests" + vars: + VERSION: "3.6" + TOPOLOGY: "replica_set" - name: "test-3.6-sharded_cluster" tags: ["3.6", "sharded_cluster"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "3.6" - # TOPOLOGY: "sharded_cluster" - func: "run tests" + vars: + VERSION: "3.6" + TOPOLOGY: "sharded_cluster" - name: "test-latest-standalone" tags: ["latest", "standalone"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "latest" - # TOPOLOGY: "server" - func: "run tests" + vars: + VERSION: "latest" + TOPOLOGY: "server" - name: "test-latest-replica_set" tags: ["latest", "replica_set"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "latest" - # TOPOLOGY: "replica_set" - func: "run tests" + vars: + VERSION: "latest" + TOPOLOGY: "replica_set" - name: "test-latest-sharded_cluster" tags: ["latest", "sharded_cluster"] commands: - # - func: "bootstrap mongo-orchestration" - # vars: - # VERSION: "latest" - # TOPOLOGY: "sharded_cluster" - func: "run tests" + vars: + VERSION: "latest" + TOPOLOGY: "sharded_cluster" # }}} From 788fff892cda67e4e7fcc1226744b7a39b57f80b Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Sat, 10 Mar 2018 10:35:16 -0500 Subject: [PATCH 19/39] test(evergreen): move mongodb download to run-tests --- .evergreen/config.yml | 30 +----------------------------- .evergreen/install-dependencies.sh | 14 -------------- .evergreen/run-tests.sh | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 43 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 9d6e72efb..4a76d6c5e 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -43,14 +43,6 @@ functions: export DRIVERS_TOOLS="$(pwd)/../drivers-tools" export PROJECT_DIRECTORY="$(pwd)" - - # Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory - if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin - export DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS) - export PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY) - fi - - export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration" export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" export UPLOAD_BUCKET="${project}" @@ -89,7 +81,6 @@ functions: ${PREPARE_SHELL} rm -rf $DRIVERS_TOOLS git clone git://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS - echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config "upload release": - command: s3.put @@ -120,24 +111,6 @@ functions: ${PREPARE_SHELL} [ -f ${PROJECT_DIRECTORY}/${file} ] && sh ${PROJECT_DIRECTORY}/${file} || echo "${PROJECT_DIRECTORY}/${file} not available, skipping" - "bootstrap mongo-orchestration": - - command: shell.exec - params: - script: | - ${PREPARE_SHELL} - MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} SSL=${SSL} STORAGE_ENGINE=${STORAGE_ENGINE} sh ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh - # run-orchestration generates expansion file with the MONGODB_URI for the cluster - - command: expansions.update - params: - file: mo-expansion.yml - - "stop mongo-orchestration": - - command: shell.exec - params: - script: | - ${PREPARE_SHELL} - sh ${DRIVERS_TOOLS}/.evergreen/stop-orchestration.sh - "run tests": - command: shell.exec type: test @@ -190,7 +163,7 @@ functions: working_dir: "src" script: | ${PREPARE_SHELL} - DRIVERS_TOOLS=${DRIVERS_TOOLS} MONGODB_VERSION=${VERSION} NODE_LTS_NAME=${NODE_LTS_NAME} sh ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh + NODE_LTS_NAME=${NODE_LTS_NAME} sh ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh pre: - func: "fetch source" @@ -201,7 +174,6 @@ pre: - func: "install dependencies" post: - # - func: "stop mongo-orchestration" - func: "cleanup" tasks: diff --git a/.evergreen/install-dependencies.sh b/.evergreen/install-dependencies.sh index 1bd891df9..ae5de4746 100644 --- a/.evergreen/install-dependencies.sh +++ b/.evergreen/install-dependencies.sh @@ -4,20 +4,6 @@ set -o errexit # Exit the script with error if any of the commands fail # script args NODE_LTS_NAME=${NODE_LTS_NAME:-carbon} -MONGODB_VERSION=${MONGODB_VERSION:-latest} -DIR=$(dirname $0) - -# install MongoDB -# Functions to fetch MongoDB binaries -. ${DRIVERS_TOOLS}/.evergreen/download-mongodb.sh - -get_distro -if [ -z "$MONGODB_DOWNLOAD_URL" ]; then - get_mongodb_download_url_for "$DISTRO" "$MONGODB_VERSION" -fi -# Even though we have the MONGODB_DOWNLOAD_URL, we still call this to get the proper EXTRACT variable -get_mongodb_download_url_for "$DISTRO" -download_and_extract "$MONGODB_DOWNLOAD_URL" "$EXTRACT" # install Node.js export NVM_DIR="$HOME/src/.nvm" diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index ab4391deb..3ed1d1f3d 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -11,7 +11,22 @@ set -o errexit # Exit the script with error if any of the commands fail AUTH=${AUTH:-noauth} SSL=${SSL:-nossl} MONGODB_URI=${MONGODB_URI:-} +VERSION=${VERSION:-} +DRIVERS_TOOLS=${DRIVERS_TOOLS:-} +# install MongoDB +# Functions to fetch MongoDB binaries +. ${DRIVERS_TOOLS}/.evergreen/download-mongodb.sh + +get_distro +if [ -z "$MONGODB_DOWNLOAD_URL" ]; then + get_mongodb_download_url_for "$DISTRO" "$VERSION" +fi +# Even though we have the MONGODB_DOWNLOAD_URL, we still call this to get the proper EXTRACT variable +get_mongodb_download_url_for "$DISTRO" +download_and_extract "$MONGODB_DOWNLOAD_URL" "$EXTRACT" + +# run tests OS=$(uname -s | tr '[:upper:]' '[:lower:]') [ -z "$MARCH" ] && MARCH=$(uname -m | tr '[:upper:]' '[:lower:]') From e1619a12f6b83abdb222c18cf3ceb67391182a39 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Sat, 10 Mar 2018 11:07:35 -0500 Subject: [PATCH 20/39] test(evergreen): VERSION -> MONGODB_VERSION --- .evergreen/config.yml | 2 +- .evergreen/run-tests.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 4a76d6c5e..af4b15acb 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -118,7 +118,7 @@ functions: working_dir: "src" script: | ${PREPARE_SHELL} - VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} SSL=${SSL} MONGODB_URI="${MONGODB_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh + MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} SSL=${SSL} MONGODB_URI="${MONGODB_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh "cleanup": - command: shell.exec diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index 3ed1d1f3d..de0ce2158 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -11,8 +11,8 @@ set -o errexit # Exit the script with error if any of the commands fail AUTH=${AUTH:-noauth} SSL=${SSL:-nossl} MONGODB_URI=${MONGODB_URI:-} -VERSION=${VERSION:-} DRIVERS_TOOLS=${DRIVERS_TOOLS:-} +MONGODB_VERSION=${MONGODB_VERSION:-} # install MongoDB # Functions to fetch MongoDB binaries @@ -20,7 +20,7 @@ DRIVERS_TOOLS=${DRIVERS_TOOLS:-} get_distro if [ -z "$MONGODB_DOWNLOAD_URL" ]; then - get_mongodb_download_url_for "$DISTRO" "$VERSION" + get_mongodb_download_url_for "$DISTRO" "$MONGODB_VERSION" fi # Even though we have the MONGODB_DOWNLOAD_URL, we still call this to get the proper EXTRACT variable get_mongodb_download_url_for "$DISTRO" @@ -45,4 +45,4 @@ echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI" export PATH="/opt/mongodbtoolchain/v2/bin:$PATH" export NVM_DIR="$HOME/src/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" -MONGODB_VERSION=${VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test -- --local +MONGODB_VERSION=${MONGODB_VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test -- --local From 6f9ed15726e4eca8da09068d6303326f01993efb Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 12 Mar 2018 09:02:16 -0400 Subject: [PATCH 21/39] test(evergreen): make matrix parity with python driver --- .evergreen/config.yml | 119 ++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 75 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index af4b15acb..2c4420285 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -373,76 +373,62 @@ axes: - id: os-fully-featured display_name: OS values: - - id: ubuntu1204-test - display_name: "Ubuntu 12.04" - run_on: ubuntu1204-test - - id: suse11-x86-64-test display_name: "SUSE 11 (x86_64)" run_on: suse11-test + batchtime: 10080 # 7 days - id: linux-64-amzn-test display_name: "Amazon Linux (Enterprise)" run_on: linux-64-amzn-test + batchtime: 10080 # 7 days - # OSes that support versions of MongoDB without SSL. - - id: os-nossl - display_name: OS - values: - - id: archlinux-test - display_name: "Archlinux" - run_on: archlinux-test - - - id: macos-1012 - display_name: "macOS 10.12" - run_on: macos-1012 - - - id: os-windows - display_name: OS - values: - - id: windows-64-vs2010-test - display_name: "Windows (VS2010)" - run_on: windows-64-vs2010-test - - - id: windows-64-vs2013-test - display_name: "Windows (VS2013)" - run_on: windows-64-vs2013-test - - - id: windows-64-vs2015-test - display_name: "Windows (VS2015)" - run_on: windows-64-vs2015-test - - # OSes that support versions of MongoDB>=2.6 with SSL. - - id: os-requires-26 - display_name: OS - values: - id: ubuntu-14.04 display_name: "Ubuntu 14.04" run_on: ubuntu1404-test + batchtime: 10080 # 7 days - id: rhel70 display_name: "RHEL 7.0" run_on: rhel70-small + batchtime: 10080 # 7 days - id: debian71-test display_name: "Debian 7.1" run_on: debian71-test + batchtime: 10080 # 7 days + + # OSes that support versions of MongoDB without SSL. + - id: os-nossl + display_name: OS + values: + - id: archlinux-test + display_name: "Archlinux" + run_on: archlinux-test + batchtime: 10080 # 7 days + + - id: macos-1012 + display_name: "macOS 10.12" + run_on: macos-1012 # OSes that support versions of MongoDB>=3.2 with SSL. - id: os-requires-32 display_name: OS values: - - id: suse12-x86-64-test - display_name: "SUSE 12 (x86_64)" - run_on: suse12-test - - id: ubuntu-16.04 display_name: "Ubuntu 16.04" run_on: ubuntu1604-test + batchtime: 10080 # 7 days + + - id: suse12-x86-64-test + display_name: "SUSE 12 (x86_64)" + run_on: suse12-test + batchtime: 10080 # 7 days - id: rhel71-power8-test display_name: "RHEL 7.1 (POWER8)" run_on: rhel71-power8-test + batchtime: 10080 # 7 days # OSes that introduced support for SSL with MongoDB>=3.2. - id: os-ssl-requires-32 @@ -459,34 +445,48 @@ axes: - id: debian81-test display_name: "Debian 8.1" run_on: debian81-test + batchtime: 10080 # 7 days - id: rhel72-zseries-test display_name: "RHEL 7.2 (zSeries)" run_on: rhel72-zseries-test + batchtime: 10080 # 7 days - id: suse12-zseries-test display_name: "SUSE 12 (zSeries)" run_on: suse12-zseries-test + batchtime: 10080 # 7 days - id: ubuntu1604-arm64-small display_name: "Ubuntu 16.04 (ARM64)" run_on: ubuntu1604-arm64-small + batchtime: 10080 # 7 days - id: ubuntu1604-power8-test display_name: "Ubuntu 16.04 (POWER8)" run_on: ubuntu1604-power8-test + batchtime: 10080 # 7 days - id: ubuntu1604-zseries-small display_name: "Ubuntu 16.04 (zSeries)" run_on: ubuntu1604-zseries-small + batchtime: 10080 # 7 days - # OSes that support versions of MongoDB>=4.0 with SSL. - - id: os-requires-40 + - id: os-windows display_name: OS values: - - id: debian92-test - display_name: "Debian 9.2" - run_on: debian92-test + - id: windows-64-vs2010-test + display_name: "Windows (VS2010)" + run_on: windows-64-vs2010-test + + - id: windows-64-vs2013-test + display_name: "Windows (VS2013)" + run_on: windows-64-vs2013-test + + - id: windows-64-vs2015-test + display_name: "Windows (VS2015)" + run_on: windows-64-vs2015-test + - id: topology display_name: Topology @@ -589,29 +589,6 @@ buildvariants: - name: "test-2.6-sharded_cluster" - name: "test-2.6-standalone" -- matrix_name: "tests-os-requires-26" - matrix_spec: {"os-requires-26": "*", auth: "*", ssl: "*", node-version: "*" } - display_name: "${node-version} ${os-requires-26} ${auth} ${ssl}" - tasks: - - name: "test-latest-replica_set" - - name: "test-latest-sharded_cluster" - - name: "test-latest-standalone" - - name: "test-3.6-replica_set" - - name: "test-3.6-sharded_cluster" - - name: "test-3.6-standalone" - - name: "test-3.4-replica_set" - - name: "test-3.4-sharded_cluster" - - name: "test-3.4-standalone" - - name: "test-3.2-replica_set" - - name: "test-3.2-sharded_cluster" - - name: "test-3.2-standalone" - - name: "test-3.0-replica_set" - - name: "test-3.0-sharded_cluster" - - name: "test-3.0-standalone" - - name: "test-2.6-replica_set" - - name: "test-2.6-sharded_cluster" - - name: "test-2.6-standalone" - - matrix_name: "tests-os-requires-32" matrix_spec: {"os-requires-32": "*", auth: "*", ssl: "*", node-version: "*" } display_name: "${node-version} ${os-requires-32} ${auth} ${ssl}" @@ -660,14 +637,6 @@ buildvariants: - name: "test-3.4-sharded_cluster" - name: "test-3.4-standalone" -- matrix_name: "tests-os-requires-40" - matrix_spec: {"os-requires-40": "*", auth: "*", ssl: "*", node-version: "*" } - display_name: "${node-version} ${os-requires-40} ${auth} ${ssl}" - tasks: - - name: "test-latest-replica_set" - - name: "test-latest-sharded_cluster" - - name: "test-latest-standalone" - - matrix_name: "tests-windows" matrix_spec: {os-windows: "*", auth: "*", ssl: "*", node-version: "*" } display_name: "${node-version} ${os-windows} ${auth} ${ssl}" From 93ab85f571244e2183cc3224887b02e0edda2ff9 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 12 Mar 2018 14:40:57 -0400 Subject: [PATCH 22/39] test(evergreen): enable verbose logging for npm install --- .evergreen/install-dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/install-dependencies.sh b/.evergreen/install-dependencies.sh index ae5de4746..a165cd2d1 100644 --- a/.evergreen/install-dependencies.sh +++ b/.evergreen/install-dependencies.sh @@ -12,4 +12,4 @@ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | b nvm install --lts=${NODE_LTS_NAME} # install node dependencies -npm install +npm install --verbose From 68fdaebfa3b485dade0794574782e4edc3faf202 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 12 Mar 2018 15:01:16 -0400 Subject: [PATCH 23/39] test(evergreen): store all node related artifacts in a local folder --- .evergreen/install-dependencies.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.evergreen/install-dependencies.sh b/.evergreen/install-dependencies.sh index a165cd2d1..ea531cf97 100644 --- a/.evergreen/install-dependencies.sh +++ b/.evergreen/install-dependencies.sh @@ -2,14 +2,21 @@ # set -o xtrace # Write all commands first to stderr set -o errexit # Exit the script with error if any of the commands fail -# script args NODE_LTS_NAME=${NODE_LTS_NAME:-carbon} +NODE_ARTIFACTS_PATH="${HOME}/src/node" +NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm" +NPM_CACHE_DIR="${NODE_ARTIFACTS_PATH}/npm" + +# create node artifacts path if needed +mkdir -p ${NODE_ARTIFACTS_PATH} # install Node.js -export NVM_DIR="$HOME/src/.nvm" curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" nvm install --lts=${NODE_LTS_NAME} +# setup npm cache in a local directory +npm config set cache "${NPM_CACHE_DIR}" + # install node dependencies -npm install --verbose +npm install From 679b6e46764591c6947f4584e3e9c53911c990dd Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 12 Mar 2018 15:07:30 -0400 Subject: [PATCH 24/39] test(evergreen): need to re-export NVM_DIR after curl'd install --- .evergreen/install-dependencies.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.evergreen/install-dependencies.sh b/.evergreen/install-dependencies.sh index ea531cf97..bb2bdf6f4 100644 --- a/.evergreen/install-dependencies.sh +++ b/.evergreen/install-dependencies.sh @@ -1,10 +1,9 @@ #!/bin/sh -# set -o xtrace # Write all commands first to stderr +set -o xtrace # Write all commands first to stderr set -o errexit # Exit the script with error if any of the commands fail NODE_LTS_NAME=${NODE_LTS_NAME:-carbon} NODE_ARTIFACTS_PATH="${HOME}/src/node" -NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm" NPM_CACHE_DIR="${NODE_ARTIFACTS_PATH}/npm" # create node artifacts path if needed @@ -12,6 +11,7 @@ mkdir -p ${NODE_ARTIFACTS_PATH} # install Node.js curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash +export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm" [ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" nvm install --lts=${NODE_LTS_NAME} From 3ad7eddce2b335ca21e1146a52b0005e6cea1a8f Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 12 Mar 2018 17:12:29 -0400 Subject: [PATCH 25/39] test(evergreen): ensure all node files are relegated to a single directory --- .evergreen/install-dependencies.sh | 15 +++++++++++---- .evergreen/run-tests.sh | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.evergreen/install-dependencies.sh b/.evergreen/install-dependencies.sh index bb2bdf6f4..3b87db019 100644 --- a/.evergreen/install-dependencies.sh +++ b/.evergreen/install-dependencies.sh @@ -1,22 +1,29 @@ #!/bin/sh -set -o xtrace # Write all commands first to stderr +# set -o xtrace # Write all commands first to stderr set -o errexit # Exit the script with error if any of the commands fail NODE_LTS_NAME=${NODE_LTS_NAME:-carbon} NODE_ARTIFACTS_PATH="${HOME}/src/node" NPM_CACHE_DIR="${NODE_ARTIFACTS_PATH}/npm" +# this needs to be explicitly exported for the nvm install below +export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm" + # create node artifacts path if needed mkdir -p ${NODE_ARTIFACTS_PATH} +mkdir -p ${NPM_CACHE_DIR} # install Node.js curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash -export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm" [ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" nvm install --lts=${NODE_LTS_NAME} # setup npm cache in a local directory -npm config set cache "${NPM_CACHE_DIR}" +cat < .npmrc +devdir=${NPM_CACHE_DIR}/.node-gyp +init-module=${NPM_CACHE_DIR}/.npm-init.js +cache=${NPM_CACHE_DIR} +EOT # install node dependencies -npm install +npm install --verbose diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index de0ce2158..c90354985 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -43,6 +43,6 @@ fi echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI" export PATH="/opt/mongodbtoolchain/v2/bin:$PATH" -export NVM_DIR="$HOME/src/.nvm" +export NVM_DIR="${HOME}/src/node/nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" MONGODB_VERSION=${MONGODB_VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test -- --local From e8ec9422f218c2fb8e6e9e7be967051d135a4356 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 12 Mar 2018 17:46:50 -0400 Subject: [PATCH 26/39] test(evergreen): use $PROJECT_DIRECTORY for temporary node folder --- .evergreen/config.yml | 29 ----------------------------- .evergreen/install-dependencies.sh | 7 +++++-- .evergreen/run-tests.sh | 3 ++- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 2c4420285..16107d8d7 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -82,35 +82,6 @@ functions: rm -rf $DRIVERS_TOOLS git clone git://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS - "upload release": - - command: s3.put - params: - aws_key: ${aws_key} - aws_secret: ${aws_secret} - local_file: ${project}.tar.gz - remote_file: ${UPLOAD_BUCKET}/${project}-${CURRENT_VERSION}.tar.gz - bucket: mciuploads - permissions: public-read - content_type: ${content_type|application/x-gzip} - - "exec compile script" : - - command: shell.exec - type: test - params: - working_dir: "src" - script: | - ${PREPARE_SHELL} - [ -f ${PROJECT_DIRECTORY}/${file} ] && BUILDTOOL="${buildtool}" sh ${PROJECT_DIRECTORY}/${file} || echo "${PROJECT_DIRECTORY}/${file} not available, skipping" - - "exec script" : - - command: shell.exec - type: test - params: - working_dir: "src" - script: | - ${PREPARE_SHELL} - [ -f ${PROJECT_DIRECTORY}/${file} ] && sh ${PROJECT_DIRECTORY}/${file} || echo "${PROJECT_DIRECTORY}/${file} not available, skipping" - "run tests": - command: shell.exec type: test diff --git a/.evergreen/install-dependencies.sh b/.evergreen/install-dependencies.sh index 3b87db019..5ea5f7226 100644 --- a/.evergreen/install-dependencies.sh +++ b/.evergreen/install-dependencies.sh @@ -3,8 +3,9 @@ set -o errexit # Exit the script with error if any of the commands fail NODE_LTS_NAME=${NODE_LTS_NAME:-carbon} -NODE_ARTIFACTS_PATH="${HOME}/src/node" +NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts" NPM_CACHE_DIR="${NODE_ARTIFACTS_PATH}/npm" +NPM_TMP_DIR="${NODE_ARTIFATS_PATH}/tmp" # this needs to be explicitly exported for the nvm install below export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm" @@ -12,6 +13,7 @@ export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm" # create node artifacts path if needed mkdir -p ${NODE_ARTIFACTS_PATH} mkdir -p ${NPM_CACHE_DIR} +mkdir -p "${NPM_TMP_DIR}" # install Node.js curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash @@ -23,7 +25,8 @@ cat < .npmrc devdir=${NPM_CACHE_DIR}/.node-gyp init-module=${NPM_CACHE_DIR}/.npm-init.js cache=${NPM_CACHE_DIR} +tmp=${NPM_TMP_DIR} EOT # install node dependencies -npm install --verbose +npm install diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index c90354985..bc3f7e0cf 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -43,6 +43,7 @@ fi echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI" export PATH="/opt/mongodbtoolchain/v2/bin:$PATH" -export NVM_DIR="${HOME}/src/node/nvm" +NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts" +export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" MONGODB_VERSION=${MONGODB_VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test -- --local From 322d93153c958e687e96dbab3ca88683dae2ce0d Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 19 Mar 2018 09:09:06 -0400 Subject: [PATCH 27/39] test(evergreen): temporarily disable auth/ssl builds --- .evergreen/config.yml | 84 +++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 16107d8d7..2f193ce5e 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -515,7 +515,7 @@ axes: buildvariants: - matrix_name: "tests-all" - matrix_spec: {"os-fully-featured": "*", auth: "*", ssl: "*", node-version: "*" } + matrix_spec: {"os-fully-featured": "*", node-version: "*" } # auth: "*", ssl: "*", display_name: "${node-version} ${os-fully-featured} ${auth} ${ssl}" tasks: - name: "test-latest-replica_set" @@ -537,31 +537,31 @@ buildvariants: - name: "test-2.6-sharded_cluster" - name: "test-2.6-standalone" -- matrix_name: "tests-nossl" - matrix_spec: {"os-nossl": "*", auth: "*", ssl: "nossl", node-version: "*" } - display_name: "${node-version} ${os-nossl} ${auth} ${ssl}" - tasks: - - name: "test-latest-replica_set" - - name: "test-latest-sharded_cluster" - - name: "test-latest-standalone" - - name: "test-3.6-replica_set" - - name: "test-3.6-sharded_cluster" - - name: "test-3.6-standalone" - - name: "test-3.4-replica_set" - - name: "test-3.4-sharded_cluster" - - name: "test-3.4-standalone" - - name: "test-3.2-replica_set" - - name: "test-3.2-sharded_cluster" - - name: "test-3.2-standalone" - - name: "test-3.0-replica_set" - - name: "test-3.0-sharded_cluster" - - name: "test-3.0-standalone" - - name: "test-2.6-replica_set" - - name: "test-2.6-sharded_cluster" - - name: "test-2.6-standalone" +# - matrix_name: "tests-nossl" +# matrix_spec: {"os-nossl": "*", auth: "*", ssl: "nossl", node-version: "*" } +# display_name: "${node-version} ${os-nossl} ${auth} ${ssl}" +# tasks: +# - name: "test-latest-replica_set" +# - name: "test-latest-sharded_cluster" +# - name: "test-latest-standalone" +# - name: "test-3.6-replica_set" +# - name: "test-3.6-sharded_cluster" +# - name: "test-3.6-standalone" +# - name: "test-3.4-replica_set" +# - name: "test-3.4-sharded_cluster" +# - name: "test-3.4-standalone" +# - name: "test-3.2-replica_set" +# - name: "test-3.2-sharded_cluster" +# - name: "test-3.2-standalone" +# - name: "test-3.0-replica_set" +# - name: "test-3.0-sharded_cluster" +# - name: "test-3.0-standalone" +# - name: "test-2.6-replica_set" +# - name: "test-2.6-sharded_cluster" +# - name: "test-2.6-standalone" - matrix_name: "tests-os-requires-32" - matrix_spec: {"os-requires-32": "*", auth: "*", ssl: "*", node-version: "*" } + matrix_spec: {"os-requires-32": "*", node-version: "*" } # auth: "*", ssl: "*", display_name: "${node-version} ${os-requires-32} ${auth} ${ssl}" tasks: - name: "test-latest-replica_set" @@ -577,25 +577,25 @@ buildvariants: - name: "test-3.2-sharded_cluster" - name: "test-3.2-standalone" -- matrix_name: "tests-ssl-requires-32" - matrix_spec: {"os-ssl-requires-32": "*", auth: "*", ssl: "ssl", node-version: "*" } - display_name: "${node-version} ${os-ssl-requires-32} ${auth} ${ssl}" - tasks: - - name: "test-latest-replica_set" - - name: "test-latest-sharded_cluster" - - name: "test-latest-standalone" - - name: "test-3.6-replica_set" - - name: "test-3.6-sharded_cluster" - - name: "test-3.6-standalone" - - name: "test-3.4-replica_set" - - name: "test-3.4-sharded_cluster" - - name: "test-3.4-standalone" - - name: "test-3.2-replica_set" - - name: "test-3.2-sharded_cluster" - - name: "test-3.2-standalone" +# - matrix_name: "tests-ssl-requires-32" +# matrix_spec: {"os-ssl-requires-32": "*", auth: "*", ssl: "ssl", node-version: "*" } +# display_name: "${node-version} ${os-ssl-requires-32} ${auth} ${ssl}" +# tasks: +# - name: "test-latest-replica_set" +# - name: "test-latest-sharded_cluster" +# - name: "test-latest-standalone" +# - name: "test-3.6-replica_set" +# - name: "test-3.6-sharded_cluster" +# - name: "test-3.6-standalone" +# - name: "test-3.4-replica_set" +# - name: "test-3.4-sharded_cluster" +# - name: "test-3.4-standalone" +# - name: "test-3.2-replica_set" +# - name: "test-3.2-sharded_cluster" +# - name: "test-3.2-standalone" - matrix_name: "tests-os-requires-34" - matrix_spec: {"os-requires-34": "*", auth: "*", ssl: "*", node-version: "*" } + matrix_spec: {"os-requires-34": "*", node-version: "*" } # auth: "*", ssl: "*", display_name: "${node-version} ${os-requires-34} ${auth} ${ssl}" tasks: - name: "test-latest-replica_set" @@ -609,7 +609,7 @@ buildvariants: - name: "test-3.4-standalone" - matrix_name: "tests-windows" - matrix_spec: {os-windows: "*", auth: "*", ssl: "*", node-version: "*" } + matrix_spec: {os-windows: "*", node-version: "*" } # ssl: "*", auth: "*" display_name: "${node-version} ${os-windows} ${auth} ${ssl}" tasks: - name: "test-latest-replica_set" From e321367239a78d4508e01d4d427dcc449103f3ae Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 19 Mar 2018 17:14:23 -0400 Subject: [PATCH 28/39] refactor(pool): emit a signal for state changes This is a low-impact change that allows us to potentially make far more accurate assessments of when certain events have completed in the pool. This also allows us to reduce the chances of flakey pool tests --- lib/connection/pool.js | 1 + test/tests/functional/pool_tests.js | 13 ++++++++----- test/tests/unit/single/sessions_tests.js | 17 ++++++++++------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/connection/pool.js b/lib/connection/pool.js index c0613e2fd..c87ecb919 100644 --- a/lib/connection/pool.js +++ b/lib/connection/pool.js @@ -210,6 +210,7 @@ function stateTransition(self, newState) { // Get current state var legalStates = legalTransitions[self.state]; if (legalStates && legalStates.indexOf(newState) !== -1) { + self.emit('stateChanged', self.state, newState); self.state = newState; } else { self.logger.error( diff --git a/test/tests/functional/pool_tests.js b/test/tests/functional/pool_tests.js index 4a0141288..b93b48992 100644 --- a/test/tests/functional/pool_tests.js +++ b/test/tests/functional/pool_tests.js @@ -140,6 +140,13 @@ describe('Pool tests', function() { bson: new Bson() }); + pool.on('stateChanged', (oldState, newState) => { + if (newState !== 'destroyed') return; + expect(Object.keys(Connection.connections()).length).to.equal(0); + Connection.disableConnectionAccounting(); + done(); + }); + var messageHandler = function(err, result) { index = index + 1; @@ -149,11 +156,7 @@ describe('Pool tests', function() { // Did we receive an answer for all the messages if (index === 100) { expect(pool.allConnections().length).to.equal(5); - - pool.destroy(); - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); + pool.destroy(); // destroy pool, check for `destroyed` event above } }; diff --git a/test/tests/unit/single/sessions_tests.js b/test/tests/unit/single/sessions_tests.js index 89bb43a7a..a32cb7ad9 100644 --- a/test/tests/unit/single/sessions_tests.js +++ b/test/tests/unit/single/sessions_tests.js @@ -322,13 +322,16 @@ describe('Sessions (Single)', function() { client.on('error', done); client.once('connect', () => { - client.command('admin.$cmd', { ping: 1 }, { session: session }, err => { - expect(err).to.not.exist; - expect(command.lsid).to.eql(session.id); - expect(session.serverSession.lastUse).to.not.eql(initialLastUse); - - done(); - }); + // we want to run this a little bit later just in case it runs immediately + setTimeout(() => { + client.command('admin.$cmd', { ping: 1 }, { session: session }, err => { + expect(err).to.not.exist; + expect(command.lsid).to.eql(session.id); + expect(session.serverSession.lastUse).to.not.eql(initialLastUse); + + done(); + }); + }, 250); }); client.connect(); From 9bddb5e8159214157d2167a013dde9bbb4e100b9 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Tue, 20 Mar 2018 09:55:58 -0400 Subject: [PATCH 29/39] test(evergreen): remove suse 11 because its version of git is too old --- .evergreen/config.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 2f193ce5e..77af2898b 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -344,11 +344,6 @@ axes: - id: os-fully-featured display_name: OS values: - - id: suse11-x86-64-test - display_name: "SUSE 11 (x86_64)" - run_on: suse11-test - batchtime: 10080 # 7 days - - id: linux-64-amzn-test display_name: "Amazon Linux (Enterprise)" run_on: linux-64-amzn-test From ea2f171c07b525ac83ad471ecb16523504aa011c Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Tue, 20 Mar 2018 09:57:15 -0400 Subject: [PATCH 30/39] test(evergreen): disable windows builds until we have an nvm alternative --- .evergreen/config.yml | 93 ++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 77af2898b..cd7e7a5d6 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -107,17 +107,17 @@ functions: perl -p -i -e "s|ABSOLUTE_PATH_REPLACEMENT_TOKEN|${DRIVERS_TOOLS}|g" $filename done - "windows fix": - - command: shell.exec - params: - script: | - ${PREPARE_SHELL} - for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do - cat $i | tr -d '\r' > $i.new - mv $i.new $i - done - # Copy client certificate because symlinks do not work on Windows. - cp ${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem ${MONGO_ORCHESTRATION_HOME}/lib/client.pem + # "windows fix": + # - command: shell.exec + # params: + # script: | + # ${PREPARE_SHELL} + # for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do + # cat $i | tr -d '\r' > $i.new + # mv $i.new $i + # done + # # Copy client certificate because symlinks do not work on Windows. + # cp ${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem ${MONGO_ORCHESTRATION_HOME}/lib/client.pem "make files executable": - command: shell.exec @@ -139,7 +139,7 @@ functions: pre: - func: "fetch source" - func: "prepare resources" - - func: "windows fix" + # - func: "windows fix" - func: "fix absolute paths" - func: "make files executable" - func: "install dependencies" @@ -438,20 +438,21 @@ axes: run_on: ubuntu1604-zseries-small batchtime: 10080 # 7 days - - id: os-windows - display_name: OS - values: - - id: windows-64-vs2010-test - display_name: "Windows (VS2010)" - run_on: windows-64-vs2010-test + # NOTE: reenable this when nvm supports windows, or we settle on an alternative + # - id: os-windows + # display_name: OS + # values: + # - id: windows-64-vs2010-test + # display_name: "Windows (VS2010)" + # run_on: windows-64-vs2010-test - - id: windows-64-vs2013-test - display_name: "Windows (VS2013)" - run_on: windows-64-vs2013-test + # - id: windows-64-vs2013-test + # display_name: "Windows (VS2013)" + # run_on: windows-64-vs2013-test - - id: windows-64-vs2015-test - display_name: "Windows (VS2015)" - run_on: windows-64-vs2015-test + # - id: windows-64-vs2015-test + # display_name: "Windows (VS2015)" + # run_on: windows-64-vs2015-test - id: topology @@ -603,25 +604,25 @@ buildvariants: - name: "test-3.4-sharded_cluster" - name: "test-3.4-standalone" -- matrix_name: "tests-windows" - matrix_spec: {os-windows: "*", node-version: "*" } # ssl: "*", auth: "*" - display_name: "${node-version} ${os-windows} ${auth} ${ssl}" - tasks: - - name: "test-latest-replica_set" - - name: "test-latest-sharded_cluster" - - name: "test-latest-standalone" - - name: "test-3.6-replica_set" - - name: "test-3.6-sharded_cluster" - - name: "test-3.6-standalone" - - name: "test-3.4-replica_set" - - name: "test-3.4-sharded_cluster" - - name: "test-3.4-standalone" - - name: "test-3.2-replica_set" - - name: "test-3.2-sharded_cluster" - - name: "test-3.2-standalone" - - name: "test-3.0-replica_set" - - name: "test-3.0-sharded_cluster" - - name: "test-3.0-standalone" - - name: "test-2.6-replica_set" - - name: "test-2.6-sharded_cluster" - - name: "test-2.6-standalone" +# - matrix_name: "tests-windows" +# matrix_spec: {os-windows: "*", node-version: "*" } # ssl: "*", auth: "*" +# display_name: "${node-version} ${os-windows} ${auth} ${ssl}" +# tasks: +# - name: "test-latest-replica_set" +# - name: "test-latest-sharded_cluster" +# - name: "test-latest-standalone" +# - name: "test-3.6-replica_set" +# - name: "test-3.6-sharded_cluster" +# - name: "test-3.6-standalone" +# - name: "test-3.4-replica_set" +# - name: "test-3.4-sharded_cluster" +# - name: "test-3.4-standalone" +# - name: "test-3.2-replica_set" +# - name: "test-3.2-sharded_cluster" +# - name: "test-3.2-standalone" +# - name: "test-3.0-replica_set" +# - name: "test-3.0-sharded_cluster" +# - name: "test-3.0-standalone" +# - name: "test-2.6-replica_set" +# - name: "test-2.6-sharded_cluster" +# - name: "test-2.6-standalone" From 5734e5a38b296011ba2bfd454af6f9327f4b59ba Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Sat, 24 Mar 2018 13:03:56 -0400 Subject: [PATCH 31/39] test(evergreen): only run boron and carbon builds for ZAP architectures --- .evergreen/config.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index cd7e7a5d6..99b5afb1a 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -413,10 +413,11 @@ axes: run_on: debian81-test batchtime: 10080 # 7 days - - id: rhel72-zseries-test - display_name: "RHEL 7.2 (zSeries)" - run_on: rhel72-zseries-test - batchtime: 10080 # 7 days + # NOTE: reenable when these are actually running 7.2, or we release a 7.4 rpm + # - id: rhel72-zseries-test + # display_name: "RHEL 7.2 (zSeries)" + # run_on: rhel72-zseries-test + # batchtime: 10080 # 7 days - id: suse12-zseries-test display_name: "SUSE 12 (zSeries)" @@ -438,7 +439,7 @@ axes: run_on: ubuntu1604-zseries-small batchtime: 10080 # 7 days - # NOTE: reenable this when nvm supports windows, or we settle on an alternative + # NOTE: reenable this when nvm supports windows, or we settle on an alternative tool # - id: os-windows # display_name: OS # values: @@ -591,7 +592,7 @@ buildvariants: # - name: "test-3.2-standalone" - matrix_name: "tests-os-requires-34" - matrix_spec: {"os-requires-34": "*", node-version: "*" } # auth: "*", ssl: "*", + matrix_spec: {"os-requires-34": "*", node-version: ["Boron", "Carbon"]} # auth: "*", ssl: "*", display_name: "${node-version} ${os-requires-34} ${auth} ${ssl}" tasks: - name: "test-latest-replica_set" From 3c545baa5e27d27ffda865dc7623002c98da9ee5 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Sat, 24 Mar 2018 16:45:41 -0400 Subject: [PATCH 32/39] test(config): ensure that error messages are not truncated --- test/config.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/config.js b/test/config.js index 51e4377f6..c36110d3c 100644 --- a/test/config.js +++ b/test/config.js @@ -2,6 +2,11 @@ const ConfigurationBase = require('mongodb-test-runner').ConfigurationBase; const f = require('util').format; +const chai = require('chai'); +chai.config.includeStack = true; +chai.config.showDiff = true; +chai.config.truncateThreshold = 0; + // Configuration for mongodb-core class CoreConfiguration extends ConfigurationBase { constructor(options) { From 4edfbb5d6f2f3bb1962c260fec400bb8ade230a2 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Sat, 24 Mar 2018 16:56:12 -0400 Subject: [PATCH 33/39] test(pool): attempt to correct more pool-related flakey tests --- test/tests/functional/pool_tests.js | 122 +++++++++++++++++++--------- 1 file changed, 82 insertions(+), 40 deletions(-) diff --git a/test/tests/functional/pool_tests.js b/test/tests/functional/pool_tests.js index b93b48992..654fea6cf 100644 --- a/test/tests/functional/pool_tests.js +++ b/test/tests/functional/pool_tests.js @@ -374,6 +374,13 @@ describe('Pool tests', function() { }, 10); } + pool.on('stateChanged', (oldState, newState) => { + if (newState !== 'destroyed') return; + expect(Object.keys(Connection.connections()).length).to.equal(0); + Connection.disableConnectionAccounting(); + done(); + }); + var messageHandler = function(err) { if (err) errorCount = errorCount + 1; index = index + 1; @@ -383,10 +390,6 @@ describe('Pool tests', function() { executed = true; expect(errorCount).to.be.at.least(0); pool.destroy(); - - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); }); } }; @@ -450,6 +453,16 @@ describe('Pool tests', function() { var stopped = false; var started = false; + pool.on('stateChanged', (oldState, newState) => { + if (newState !== 'destroyed') return; + expect(Object.keys(Connection.connections()).length).to.equal(0); + Connection.disableConnectionAccounting(); + expect(stopped).to.be.true; + expect(started).to.be.true; + expect(reconnect).to.be.true; + done(); + }); + var messageHandler = function(err) { if (err) errorCount = errorCount + 1; index = index + 1; @@ -457,12 +470,6 @@ describe('Pool tests', function() { if (index === 500) { expect(errorCount).to.be.at.least(0); pool.destroy(); - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - expect(stopped).to.be.true; - expect(started).to.be.true; - expect(reconnect).to.be.true; - done(); } }; @@ -539,15 +546,18 @@ describe('Pool tests', function() { }); }); - pool.on('timeout', function() { - expect(index).to.equal(0); - - pool.destroy(); + pool.on('stateChanged', (oldState, newState) => { + if (newState !== 'destroyed') return; expect(Object.keys(Connection.connections()).length).to.equal(0); Connection.disableConnectionAccounting(); done(); }); + pool.on('timeout', function() { + expect(index).to.equal(0); + pool.destroy(); + }); + // Start connection pool.connect(); } @@ -588,6 +598,13 @@ describe('Pool tests', function() { }); // Add event listeners + pool.on('stateChanged', (oldState, newState) => { + if (newState !== 'destroyed') return; + expect(Object.keys(Connection.connections()).length).to.equal(0); + Connection.disableConnectionAccounting(); + done(); + }); + pool.on('connect', function(_pool) { executeCommand( self.configuration, @@ -601,9 +618,6 @@ describe('Pool tests', function() { expect(dropUserErr).to.be.null; _pool.destroy(true); - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); } ); }); @@ -670,6 +684,13 @@ describe('Pool tests', function() { var index = 0; + pool.on('stateChanged', (oldState, newState) => { + if (newState !== 'destroyed') return; + expect(Object.keys(Connection.connections()).length).to.equal(0); + Connection.disableConnectionAccounting(); + done(); + }); + var messageHandler = function(handlerErr, handlerResult) { index = index + 1; @@ -679,11 +700,7 @@ describe('Pool tests', function() { // Did we receive an answer for all the messages if (index === 100) { expect(pool.socketCount()).to.equal(5); - pool.destroy(true); - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); } }; @@ -878,6 +895,13 @@ describe('Pool tests', function() { var index = 0; var error = false; + pool.on('stateChanged', (oldState, newState) => { + if (newState !== 'destroyed') return; + expect(Object.keys(Connection.connections()).length).to.equal(0); + Connection.disableConnectionAccounting(); + done(); + }); + var messageHandler = function(handlerErr, handlerResult) { index = index + 1; @@ -891,9 +915,6 @@ describe('Pool tests', function() { pool.destroy(true); // console.log('=================== ' + Object.keys(Connection.connections()).length) - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); } }; @@ -1001,6 +1022,13 @@ describe('Pool tests', function() { }); // Add event listeners + pool.on('stateChanged', (oldState, newState) => { + if (newState !== 'destroyed') return; + expect(Object.keys(Connection.connections()).length).to.equal(0); + Connection.disableConnectionAccounting(); + done(); + }); + pool.on('connect', function(_pool) { var query = new Query( new Bson(), @@ -1027,9 +1055,6 @@ describe('Pool tests', function() { expect(postLogoutWriteRes).to.not.exist; _pool.destroy(true); - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); }); }); }); @@ -1096,6 +1121,13 @@ describe('Pool tests', function() { }); // Add event listeners + pool.on('stateChanged', (oldState, newState) => { + if (newState !== 'destroyed') return; + expect(Object.keys(Connection.connections()).length).to.equal(0); + Connection.disableConnectionAccounting(); + done(); + }); + pool.on('connect', function(_pool) { var query = new Query( new Bson(), @@ -1130,9 +1162,6 @@ describe('Pool tests', function() { expect(postLogoutWriteErr).to.be.null; _pool.destroy(true); - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); }); }); }); @@ -1167,6 +1196,12 @@ describe('Pool tests', function() { }); // Add event listeners + pool.on('stateChanged', (oldState, newState) => { + if (newState !== 'destroyed') return; + Connection.disableConnectionAccounting(); + done(); + }); + pool.on('connect', function(_pool) { // Execute ismaster should not cause cpu to start spinning var query = new Query( @@ -1196,9 +1231,6 @@ describe('Pool tests', function() { con.destroy(); _pool.destroy(); - - Connection.disableConnectionAccounting(); - done(); }); }); }); @@ -1218,6 +1250,15 @@ describe('Pool tests', function() { bson: new Bson() }); + let writeErrorChecked = false; + pool.on('stateChanged', (oldState, newState) => { + if (newState !== 'destroyed') return; + expect(Object.keys(Connection.connections())).to.have.length(0); + Connection.disableConnectionAccounting(); + expect(writeErrorChecked).to.be.true; + done(); + }); + pool.on('connect', () => { var query = new Query( new Bson(), @@ -1230,10 +1271,7 @@ describe('Pool tests', function() { expect(err).to.exist; expect(err).to.match(/Pool was force destroyed/); expect(result).to.not.exist; - - expect(Object.keys(Connection.connections())).to.have.length(0); - Connection.disableConnectionAccounting(); - done(); + writeErrorChecked = true; }); pool.destroy({ force: true }); @@ -1267,6 +1305,13 @@ describe('Pool tests', function() { { numberToSkip: 0, numberToReturn: 1 } ); + pool.on('stateChanged', (oldState, newState) => { + if (newState !== 'destroyed') return; + expect(Object.keys(Connection.connections())).to.have.length(0); + Connection.disableConnectionAccounting(); + done(); + }); + pool.on('connect', function() { pool.write(query, { monitoring: true }, function() {}); @@ -1284,9 +1329,6 @@ describe('Pool tests', function() { expect(pool.inUseConnections).to.have.length(0); pool.destroy(true); - expect(Object.keys(Connection.connections())).to.have.length(0); - Connection.disableConnectionAccounting(); - done(); }); }, 500); }); From fab8a527cf120620a53c85dd4e1f62767ab938a8 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Sun, 25 Mar 2018 08:11:17 -0400 Subject: [PATCH 34/39] test(pool): use `ConnectionSpy` to reduce flakiness of tests --- test/tests/functional/pool_tests.js | 308 ++++++++++------------------ 1 file changed, 107 insertions(+), 201 deletions(-) diff --git a/test/tests/functional/pool_tests.js b/test/tests/functional/pool_tests.js index 654fea6cf..28006c59a 100644 --- a/test/tests/functional/pool_tests.js +++ b/test/tests/functional/pool_tests.js @@ -8,16 +8,27 @@ var expect = require('chai').expect, Query = require('../../../lib/connection/commands').Query, Bson = require('bson'), co = require('co'), - mock = require('mongodb-mock-server'); + mock = require('mongodb-mock-server'), + ConnectionSpy = require('./shared').ConnectionSpy; +const test = {}; describe('Pool tests', function() { - it.skip('should correctly connect pool to single server', { + beforeEach(() => { + test.spy = new ConnectionSpy(); + Connection.enableConnectionAccounting(test.spy); + }); + + afterEach(() => { + return mock.cleanup(test.spy).then(() => { + test.spy = undefined; + Connection.disableConnectionAccounting(); + }); + }); + + it('should correctly connect pool to single server', { metadata: { requires: { topology: 'single' } }, test: function(done) { - // Enable connections accounting - Connection.enableConnectionAccounting(); - // Attempt to connect var pool = new Pool(null, { host: this.configuration.host, @@ -27,10 +38,8 @@ describe('Pool tests', function() { }); // Add event listeners - pool.on('connect', function(_pool) { - _pool.destroy(); - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); + pool.on('connect', function() { + pool.destroy(); done(); }); @@ -43,9 +52,6 @@ describe('Pool tests', function() { metadata: { requires: { topology: 'single' } }, test: function(done) { - // Enable connections accounting - Connection.enableConnectionAccounting(); - // Attempt to connect var pool = new Pool(null, { host: this.configuration.host, @@ -57,8 +63,8 @@ describe('Pool tests', function() { let connection; // Add event listeners - pool.on('connect', function(_pool) { - var connections = _pool.allConnections(); + pool.on('connect', function() { + var connections = pool.allConnections(); process.nextTick(() => { // Now that we are in next tick, connection should still exist, but there @@ -66,11 +72,7 @@ describe('Pool tests', function() { expect(connection.connection.listenerCount('connect')).to.equal(0); expect(connections).to.have.lengthOf(1); - _pool.destroy(); - - // Connection should be gone after destroy - expect(_pool.allConnections()).to.have.lengthOf(0); - Connection.disableConnectionAccounting(); + pool.destroy(); done(); }); }); @@ -90,9 +92,6 @@ describe('Pool tests', function() { metadata: { requires: { topology: 'single' } }, test: function(done) { - // Enable connections accounting - Connection.enableConnectionAccounting(); - // Attempt to connect var pool = new Pool(null, { host: this.configuration.host, @@ -101,19 +100,18 @@ describe('Pool tests', function() { }); // Add event listeners - pool.on('connect', function(_pool) { + pool.on('connect', function() { var query = new Query( new Bson(), 'system.$cmd', { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, function(err, result) { + + pool.write(query, function(err, result) { expect(err).to.be.null; expect(result.result.ismaster).to.be.true; - _pool.destroy(); - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); + pool.destroy(); done(); }); }); @@ -127,9 +125,6 @@ describe('Pool tests', function() { metadata: { requires: { topology: 'single' } }, test: function(done) { - // Enable connections accounting - Connection.enableConnectionAccounting(); - // Index var index = 0; @@ -140,13 +135,6 @@ describe('Pool tests', function() { bson: new Bson() }); - pool.on('stateChanged', (oldState, newState) => { - if (newState !== 'destroyed') return; - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); - }); - var messageHandler = function(err, result) { index = index + 1; @@ -156,12 +144,13 @@ describe('Pool tests', function() { // Did we receive an answer for all the messages if (index === 100) { expect(pool.allConnections().length).to.equal(5); - pool.destroy(); // destroy pool, check for `destroyed` event above + pool.destroy(); + done(); } }; // Add event listeners - pool.on('connect', function(_pool) { + pool.on('connect', function() { for (var i = 0; i < 10; i++) { var query = new Query( new Bson(), @@ -169,7 +158,7 @@ describe('Pool tests', function() { { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, messageHandler); + pool.write(query, messageHandler); query = new Query( new Bson(), @@ -177,7 +166,7 @@ describe('Pool tests', function() { { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, messageHandler); + pool.write(query, messageHandler); query = new Query( new Bson(), @@ -185,7 +174,7 @@ describe('Pool tests', function() { { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, messageHandler); + pool.write(query, messageHandler); query = new Query( new Bson(), @@ -193,7 +182,7 @@ describe('Pool tests', function() { { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, messageHandler); + pool.write(query, messageHandler); query = new Query( new Bson(), @@ -201,7 +190,7 @@ describe('Pool tests', function() { { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, messageHandler); + pool.write(query, messageHandler); query = new Query( new Bson(), @@ -209,7 +198,7 @@ describe('Pool tests', function() { { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, messageHandler); + pool.write(query, messageHandler); query = new Query( new Bson(), @@ -217,7 +206,7 @@ describe('Pool tests', function() { { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, messageHandler); + pool.write(query, messageHandler); query = new Query( new Bson(), @@ -225,7 +214,7 @@ describe('Pool tests', function() { { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, messageHandler); + pool.write(query, messageHandler); query = new Query( new Bson(), @@ -233,7 +222,7 @@ describe('Pool tests', function() { { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, messageHandler); + pool.write(query, messageHandler); query = new Query( new Bson(), @@ -241,7 +230,7 @@ describe('Pool tests', function() { { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, messageHandler); + pool.write(query, messageHandler); } }); @@ -251,7 +240,7 @@ describe('Pool tests', function() { }); // Skipped due to use of topology manager - it.skip('should correctly write ismaster operation to the server and handle timeout', { + it('should correctly write ismaster operation to the server and handle timeout', { metadata: { requires: { topology: 'single' } }, test: function(done) { @@ -267,14 +256,15 @@ describe('Pool tests', function() { }); // Add event listeners - pool.on('connect', function(_pool) { + pool.on('connect', function() { var query = new Query( new Bson(), 'system.$cmd', { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, function() {}); + + pool.write(query, function() {}); }); pool.on('timeout', function() { @@ -291,9 +281,6 @@ describe('Pool tests', function() { metadata: { requires: { topology: 'single' } }, test: function(done) { - // Enable connections accounting - Connection.enableConnectionAccounting(); - // Attempt to connect var pool = new Pool(null, { host: this.configuration.host, @@ -311,7 +298,6 @@ describe('Pool tests', function() { if (index === 500) { expect(errorCount).to.be.at.least(250); pool.destroy(); - Connection.disableConnectionAccounting(); done(); } }; @@ -349,9 +335,6 @@ describe('Pool tests', function() { test: function(done) { var self = this; - // Enable connections accounting - Connection.enableConnectionAccounting(); - // Attempt to connect var pool = new Pool(null, { host: this.configuration.host, @@ -374,13 +357,6 @@ describe('Pool tests', function() { }, 10); } - pool.on('stateChanged', (oldState, newState) => { - if (newState !== 'destroyed') return; - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); - }); - var messageHandler = function(err) { if (err) errorCount = errorCount + 1; index = index + 1; @@ -390,6 +366,7 @@ describe('Pool tests', function() { executed = true; expect(errorCount).to.be.at.least(0); pool.destroy(); + done(); }); } }; @@ -435,9 +412,6 @@ describe('Pool tests', function() { test: function(done) { var self = this; - // Enable connections accounting - Connection.enableConnectionAccounting(); - // Attempt to connect var pool = new Pool(null, { host: this.configuration.host, @@ -453,16 +427,6 @@ describe('Pool tests', function() { var stopped = false; var started = false; - pool.on('stateChanged', (oldState, newState) => { - if (newState !== 'destroyed') return; - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - expect(stopped).to.be.true; - expect(started).to.be.true; - expect(reconnect).to.be.true; - done(); - }); - var messageHandler = function(err) { if (err) errorCount = errorCount + 1; index = index + 1; @@ -470,6 +434,10 @@ describe('Pool tests', function() { if (index === 500) { expect(errorCount).to.be.at.least(0); pool.destroy(); + expect(stopped).to.be.true; + expect(started).to.be.true; + expect(reconnect).to.be.true; + done(); } }; @@ -517,9 +485,6 @@ describe('Pool tests', function() { metadata: { requires: { topology: 'single' } }, test: function(done) { - Connection.enableConnectionAccounting(); - - // Attempt to connect var pool = new Pool(null, { host: this.configuration.host, port: this.configuration.port, @@ -531,31 +496,24 @@ describe('Pool tests', function() { var index = 0; // Add event listeners - pool.on('connect', function(_pool) { - // console.log('============================== 3') + pool.on('connect', function() { var query = new Query( new Bson(), 'system.$cmd', { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, { immediateRelease: true }, function(err) { - console.log('============================== 4'); - console.dir(err); + + pool.write(query, { immediateRelease: true }, function(err) { + expect(err).to.not.exist; index = index + 1; }); }); - pool.on('stateChanged', (oldState, newState) => { - if (newState !== 'destroyed') return; - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); - }); - pool.on('timeout', function() { expect(index).to.equal(0); pool.destroy(); + done(); }); // Start connection @@ -564,15 +522,12 @@ describe('Pool tests', function() { }); // Skipped due to use of topology manager - it.skip('should correctly authenticate using scram-sha-1 using connect auth', { + it('should correctly authenticate using scram-sha-1 using connect auth', { metadata: { requires: { topology: 'auth' } }, test: function(done) { var self = this; - // Enable connections accounting - Connection.enableConnectionAccounting(); - // Restart instance self.configuration.manager.restart(true).then(function() { locateAuthMethod(self.configuration, function(err, method) { @@ -598,14 +553,7 @@ describe('Pool tests', function() { }); // Add event listeners - pool.on('stateChanged', (oldState, newState) => { - if (newState !== 'destroyed') return; - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); - }); - - pool.on('connect', function(_pool) { + pool.on('connect', function() { executeCommand( self.configuration, 'admin', @@ -617,7 +565,8 @@ describe('Pool tests', function() { expect(dropUserRes).to.exist; expect(dropUserErr).to.be.null; - _pool.destroy(true); + pool.destroy(true); + done(); } ); }); @@ -640,9 +589,6 @@ describe('Pool tests', function() { test: function(done) { var self = this; - // Enable connections accounting - Connection.enableConnectionAccounting(); - // Restart instance self.configuration.manager.restart(true).then(function() { locateAuthMethod(self.configuration, function(err, method) { @@ -684,13 +630,6 @@ describe('Pool tests', function() { var index = 0; - pool.on('stateChanged', (oldState, newState) => { - if (newState !== 'destroyed') return; - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); - }); - var messageHandler = function(handlerErr, handlerResult) { index = index + 1; @@ -701,11 +640,12 @@ describe('Pool tests', function() { if (index === 100) { expect(pool.socketCount()).to.equal(5); pool.destroy(true); + done(); } }; // Add event listeners - pool.on('connect', function(_pool) { + pool.on('connect', function() { for (var i = 0; i < 10; i++) { process.nextTick(function() { var query = new Query( @@ -714,7 +654,8 @@ describe('Pool tests', function() { { insert: 'test', documents: [{ a: 1 }] }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write( + + pool.write( query, { command: true, requestId: query.requestId }, messageHandler @@ -726,7 +667,8 @@ describe('Pool tests', function() { { insert: 'test', documents: [{ a: 1 }] }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write( + + pool.write( query, { command: true, requestId: query.requestId }, messageHandler @@ -738,7 +680,8 @@ describe('Pool tests', function() { { insert: 'test', documents: [{ a: 1 }] }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write( + + pool.write( query, { command: true, requestId: query.requestId }, messageHandler @@ -750,7 +693,8 @@ describe('Pool tests', function() { { insert: 'test', documents: [{ a: 1 }] }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write( + + pool.write( query, { command: true, requestId: query.requestId }, messageHandler @@ -762,7 +706,8 @@ describe('Pool tests', function() { { insert: 'test', documents: [{ a: 1 }] }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write( + + pool.write( query, { command: true, requestId: query.requestId }, messageHandler @@ -774,7 +719,8 @@ describe('Pool tests', function() { { insert: 'test', documents: [{ a: 1 }] }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write( + + pool.write( query, { command: true, requestId: query.requestId }, messageHandler @@ -786,7 +732,8 @@ describe('Pool tests', function() { { insert: 'test', documents: [{ a: 1 }] }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write( + + pool.write( query, { command: true, requestId: query.requestId }, messageHandler @@ -798,7 +745,8 @@ describe('Pool tests', function() { { insert: 'test', documents: [{ a: 1 }] }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write( + + pool.write( query, { command: true, requestId: query.requestId }, messageHandler @@ -810,7 +758,8 @@ describe('Pool tests', function() { { insert: 'test', documents: [{ a: 1 }] }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write( + + pool.write( query, { command: true, requestId: query.requestId }, messageHandler @@ -822,7 +771,8 @@ describe('Pool tests', function() { { insert: 'test', documents: [{ a: 1 }] }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write( + + pool.write( query, { command: true, requestId: query.requestId }, messageHandler @@ -895,13 +845,6 @@ describe('Pool tests', function() { var index = 0; var error = false; - pool.on('stateChanged', (oldState, newState) => { - if (newState !== 'destroyed') return; - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); - }); - var messageHandler = function(handlerErr, handlerResult) { index = index + 1; @@ -914,12 +857,12 @@ describe('Pool tests', function() { expect(error).to.be.false; pool.destroy(true); - // console.log('=================== ' + Object.keys(Connection.connections()).length) + done(); } }; // Add event listeners - pool.on('connect', function(_pool) { + pool.on('connect', function() { pool.auth(method, 'test', 'admin', 'admin', function(authErr, authRes) { expect(authRes).to.exist; expect(authErr).to.not.exist; @@ -931,7 +874,8 @@ describe('Pool tests', function() { { insert: 'test', documents: [{ a: 1 }] }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write( + + pool.write( query, { command: true, requestId: query.requestId }, messageHandler @@ -950,9 +894,8 @@ describe('Pool tests', function() { { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, { command: true, requestId: query.requestId }, function( - e - ) { + + pool.write(query, { command: true, requestId: query.requestId }, function(e) { if (e) error = e; }); }; @@ -980,9 +923,6 @@ describe('Pool tests', function() { test: function(done) { var self = this; - // Enable connections accounting - Connection.enableConnectionAccounting(); - // Restart instance self.configuration.manager.restart(true).then(function() { locateAuthMethod(self.configuration, function(err, method) { @@ -1022,21 +962,15 @@ describe('Pool tests', function() { }); // Add event listeners - pool.on('stateChanged', (oldState, newState) => { - if (newState !== 'destroyed') return; - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); - }); - - pool.on('connect', function(_pool) { + pool.on('connect', function() { var query = new Query( new Bson(), 'test.$cmd', { insert: 'test', documents: [{ a: 1 }] }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, { command: true, requestId: query.requestId }, function( + + pool.write(query, { command: true, requestId: query.requestId }, function( loginErr, loginRes ) { @@ -1044,17 +978,18 @@ describe('Pool tests', function() { expect(loginRes).to.exist; // Logout pool - _pool.logout('test', function(logoutErr) { + pool.logout('test', function(logoutErr) { expect(logoutErr).to.be.null; - _pool.write(query, { command: true, requestId: query.requestId }, function( + pool.write(query, { command: true, requestId: query.requestId }, function( postLogoutWriteErr, postLogoutWriteRes ) { expect(postLogoutWriteErr).to.not.be.null; expect(postLogoutWriteRes).to.not.exist; - _pool.destroy(true); + pool.destroy(true); + done(); }); }); }); @@ -1078,9 +1013,6 @@ describe('Pool tests', function() { test: function(done) { var self = this; - // Enable connections accounting - Connection.enableConnectionAccounting(); - // Restart instance self.configuration.manager.restart(true).then(function() { locateAuthMethod(self.configuration, function(err, method) { @@ -1121,29 +1053,20 @@ describe('Pool tests', function() { }); // Add event listeners - pool.on('stateChanged', (oldState, newState) => { - if (newState !== 'destroyed') return; - expect(Object.keys(Connection.connections()).length).to.equal(0); - Connection.disableConnectionAccounting(); - done(); - }); - - pool.on('connect', function(_pool) { + pool.on('connect', function() { var query = new Query( new Bson(), 'test.$cmd', { insert: 'test', documents: [{ a: 1 }] }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, { requestId: query.requestId }, function( - loginErr, - loginRes - ) { + + pool.write(query, { requestId: query.requestId }, function(loginErr, loginRes) { expect(loginRes).to.exist; expect(loginErr).to.be.null; // Logout pool - _pool.logout('test', function(logoutErr) { + pool.logout('test', function(logoutErr) { expect(logoutErr).to.be.null; }); @@ -1154,14 +1077,15 @@ describe('Pool tests', function() { expect(testMethodRes).to.exist; expect(testMethodErr).to.be.null; - _pool.write(query, { requestId: query.requestId }, function( + pool.write(query, { requestId: query.requestId }, function( postLogoutWriteErr, postLogoutWriteRes ) { expect(postLogoutWriteRes).to.exist; expect(postLogoutWriteErr).to.be.null; - _pool.destroy(true); + pool.destroy(true); + done(); }); }); }); @@ -1196,13 +1120,7 @@ describe('Pool tests', function() { }); // Add event listeners - pool.on('stateChanged', (oldState, newState) => { - if (newState !== 'destroyed') return; - Connection.disableConnectionAccounting(); - done(); - }); - - pool.on('connect', function(_pool) { + pool.on('connect', function() { // Execute ismaster should not cause cpu to start spinning var query = new Query( new Bson(), @@ -1210,7 +1128,8 @@ describe('Pool tests', function() { { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, function(initalQueryErr, initalQueryRes) { + + pool.write(query, function(initalQueryErr, initalQueryRes) { expect(initalQueryRes).to.exist; expect(initalQueryErr).to.be.null; @@ -1225,12 +1144,14 @@ describe('Pool tests', function() { { ismaster: true }, { numberToSkip: 0, numberToReturn: 1 } ); - _pool.write(query, function(secondQueryErr, secondQueryRes) { + + pool.write(query, function(secondQueryErr, secondQueryRes) { expect(secondQueryRes).to.exist; expect(secondQueryErr).to.be.null; con.destroy(); - _pool.destroy(); + pool.destroy(); + done(); }); }); }); @@ -1250,15 +1171,6 @@ describe('Pool tests', function() { bson: new Bson() }); - let writeErrorChecked = false; - pool.on('stateChanged', (oldState, newState) => { - if (newState !== 'destroyed') return; - expect(Object.keys(Connection.connections())).to.have.length(0); - Connection.disableConnectionAccounting(); - expect(writeErrorChecked).to.be.true; - done(); - }); - pool.on('connect', () => { var query = new Query( new Bson(), @@ -1271,7 +1183,7 @@ describe('Pool tests', function() { expect(err).to.exist; expect(err).to.match(/Pool was force destroyed/); expect(result).to.not.exist; - writeErrorChecked = true; + done(); }); pool.destroy({ force: true }); @@ -1305,13 +1217,6 @@ describe('Pool tests', function() { { numberToSkip: 0, numberToReturn: 1 } ); - pool.on('stateChanged', (oldState, newState) => { - if (newState !== 'destroyed') return; - expect(Object.keys(Connection.connections())).to.have.length(0); - Connection.disableConnectionAccounting(); - done(); - }); - pool.on('connect', function() { pool.write(query, { monitoring: true }, function() {}); @@ -1329,6 +1234,7 @@ describe('Pool tests', function() { expect(pool.inUseConnections).to.have.length(0); pool.destroy(true); + done(); }); }, 500); }); From d0e72d55f372f2cddc977da87f661d7a61f04815 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Sun, 25 Mar 2018 08:16:13 -0400 Subject: [PATCH 35/39] test(cursor): skip the flakiest test in our suite for now --- test/tests/functional/cursor_tests.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/tests/functional/cursor_tests.js b/test/tests/functional/cursor_tests.js index 28c7f7812..b39388610 100644 --- a/test/tests/functional/cursor_tests.js +++ b/test/tests/functional/cursor_tests.js @@ -583,7 +583,8 @@ describe('Cursor tests', function() { } }); - it('should not hang if autoReconnect=false and pools sockets all timed out', { + // NOTE: a notoriously flakey test, needs rewriting + it.skip('should not hang if autoReconnect=false and pools sockets all timed out', { metadata: { requires: { topology: ['single'] } }, test: function(done) { var configuration = this.configuration, @@ -596,15 +597,15 @@ describe('Cursor tests', function() { port: configuration.port, bson: new bson(), // Nasty edge case: small timeout, small pool, no auto reconnect - socketTimeout: 100, + socketTimeout: 250, size: 1, reconnect: false }); var ns = f('%s.cursor7', configuration.db); - server.on('connect', function(_server) { + server.on('connect', function() { // Execute the write - _server.insert( + server.insert( ns, [{ a: 1 }], { @@ -616,7 +617,7 @@ describe('Cursor tests', function() { expect(results.result.n).to.equal(1); // Execute slow find - var cursor = _server.cursor(ns, { + var cursor = server.cursor(ns, { find: ns, query: { $where: 'sleep(250) || true' }, batchSize: 1 @@ -626,7 +627,7 @@ describe('Cursor tests', function() { cursor.next(function(err) { expect(err).to.exist; - cursor = _server.cursor(ns, { + cursor = server.cursor(ns, { find: ns, query: {}, batchSize: 1 From 873aebae7801395c67fae0f3ec4400e7d8981762 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Sun, 25 Mar 2018 09:50:27 -0400 Subject: [PATCH 36/39] test(server): don't time how long it takes to eval --- test/tests/functional/server_tests.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/tests/functional/server_tests.js b/test/tests/functional/server_tests.js index 2ffa3a565..e14d4ee13 100644 --- a/test/tests/functional/server_tests.js +++ b/test/tests/functional/server_tests.js @@ -759,19 +759,12 @@ describe('Server tests', function() { // Add event listeners server.on('connect', function() { var left = 5; - var start = new Date().getTime(); - var leftDecrement = function(err, r) { expect(err).to.not.exist; expect(r).to.exist; left = left - 1; - if (left === 0) { - var total = new Date().getTime() - start; - expect(total).to.be.at.least(5 * 100); - expect(total).to.be.at.most(1000); - server.destroy(); done(); } From a3803de54a5816c6bc65e6200721a40f20c52c7d Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 26 Mar 2018 12:12:21 -0400 Subject: [PATCH 37/39] test(evergreen): remove unused bash variables --- .evergreen/run-tests.sh | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index bc3f7e0cf..713f54b81 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -27,19 +27,6 @@ get_mongodb_download_url_for "$DISTRO" download_and_extract "$MONGODB_DOWNLOAD_URL" "$EXTRACT" # run tests -OS=$(uname -s | tr '[:upper:]' '[:lower:]') -[ -z "$MARCH" ] && MARCH=$(uname -m | tr '[:upper:]' '[:lower:]') - -if [ "$AUTH" != "noauth" ]; then - export MONGOC_TEST_USER="bob" - export MONGOC_TEST_PASSWORD="pwd123" -fi - -if [ "$SSL" != "nossl" ]; then - export MONGOC_TEST_SSL_PEM_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem" - export MONGOC_TEST_SSL_CA_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem" -fi - echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI" export PATH="/opt/mongodbtoolchain/v2/bin:$PATH" From 129986ba3a3626e1daf4778d1ffe4583c10f1628 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 26 Mar 2018 12:13:40 -0400 Subject: [PATCH 38/39] chore(cruft): remove deprecated `.evg.yml` --- .evg.yml | 266 ------------------------------------------------------- 1 file changed, 266 deletions(-) delete mode 100644 .evg.yml diff --git a/.evg.yml b/.evg.yml deleted file mode 100644 index 393cb5a5c..000000000 --- a/.evg.yml +++ /dev/null @@ -1,266 +0,0 @@ -stepback: true -command_type: system - -functions: - "fetch source": - - command: git.get_project - params: - directory: "src" - - "fetch nodejs": - - command: shell.exec - type: system - params: - script: | - export NVM_DIR="$HOME/src/.nvm" - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - nvm install --lts=${NODE_LTS_NAME} - - "run tests": - - command: shell.exec - type: test - params: - working_dir: "src" - script: | - export PATH="/opt/mongodbtoolchain/v2/bin:$PATH" - export NVM_DIR="$HOME/src/.nvm" - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - - npm install - MONGODB_VERSION=${VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test -- --evergreen - -pre: - - func: "fetch source" - - func: "fetch nodejs" - -tasks: - - name: "test-2.6-standalone" - tags: ["2.6", "standalone"] - commands: - - func: "run tests" - vars: - VERSION: "2.6" - TOPOLOGY: "single" - - - name: "test-2.6-replica_set" - tags: ["2.6", "replica_set"] - commands: - - func: "run tests" - vars: - VERSION: "2.6" - TOPOLOGY: "replicaset" - - - name: "test-2.6-sharded_cluster" - tags: ["2.6", "sharded_cluster"] - commands: - - func: "run tests" - vars: - VERSION: "2.6" - TOPOLOGY: "sharded" - - - name: "test-3.0-standalone" - tags: ["3.0", "standalone"] - commands: - - func: "run tests" - vars: - VERSION: "3.0" - TOPOLOGY: "single" - - - name: "test-3.0-replica_set" - tags: ["3.0", "replica_set"] - commands: - - func: "run tests" - vars: - VERSION: "3.0" - TOPOLOGY: "replicaset" - - - name: "test-3.0-sharded_cluster" - tags: ["3.0", "sharded_cluster"] - commands: - - func: "run tests" - vars: - VERSION: "3.0" - TOPOLOGY: "sharded" - - - name: "test-3.2-standalone" - tags: ["3.2", "standalone"] - commands: - - func: "run tests" - vars: - VERSION: "3.2" - TOPOLOGY: "single" - - - name: "test-3.2-replica_set" - tags: ["3.2", "replica_set"] - commands: - - func: "run tests" - vars: - VERSION: "3.2" - TOPOLOGY: "replicaset" - - - name: "test-3.2-sharded_cluster" - tags: ["3.2", "sharded_cluster"] - commands: - - func: "run tests" - vars: - VERSION: "3.2" - TOPOLOGY: "sharded" - - - name: "test-3.4-standalone" - tags: ["3.4", "standalone"] - commands: - - func: "run tests" - vars: - VERSION: "3.4" - TOPOLOGY: "single" - - - name: "test-3.4-replica_set" - tags: ["3.4", "replica_set"] - commands: - - func: "run tests" - vars: - VERSION: "3.4" - TOPOLOGY: "replicaset" - - - name: "test-3.4-sharded_cluster" - tags: ["3.4", "sharded_cluster"] - commands: - - func: "run tests" - vars: - VERSION: "3.4" - TOPOLOGY: "sharded" - - - name: "test-3.6-standalone" - tags: ["3.6", "standalone"] - commands: - - func: "run tests" - vars: - VERSION: "3.6" - TOPOLOGY: "single" - - - name: "test-3.6-replica_set" - tags: ["3.6", "replica_set"] - commands: - - func: "run tests" - vars: - VERSION: "3.6" - TOPOLOGY: "replicaset" - - - name: "test-3.6-sharded_cluster" - tags: ["3.6", "sharded_cluster"] - commands: - - func: "run tests" - vars: - VERSION: "3.6" - TOPOLOGY: "sharded" - - - name: "test-latest-standalone" - tags: ["latest", "standalone"] - commands: - - func: "run tests" - vars: - VERSION: "latest" - TOPOLOGY: "single" - - - name: "test-latest-replica_set" - tags: ["latest", "replica_set"] - commands: - - func: "run tests" - vars: - VERSION: "latest" - TOPOLOGY: "replicaset" - - - name: "test-latest-sharded_cluster" - tags: ["latest", "sharded_cluster"] - commands: - - func: "run tests" - vars: - VERSION: "latest" - TOPOLOGY: "sharded" - -axes: - - id: versions - display_name: MongoDB Version - values: - - id: "latest" - display_name: "latest" - variables: - VERSION: "latest" - - id: "3.6" - display_name: "3.6" - variables: - VERSION: "3.6" - - id: "3.4" - display_name: "3.4" - variables: - VERSION: "3.4" - - id: "3.2" - display_name: "3.2" - variables: - VERSION: "3.2" - - id: "3.0" - display_name: "3.0" - variables: - VERSION: "3.0" - - id: "2.6" - display_name: "2.6" - variables: - VERSION: "2.6" - - id: os - display_name: OS - values: - - id: os_rhel62 - display_name: RHEL 6.2 - run_on: - - rhel62-test - - rhel62-build - - rhel62-large - - rhel62-small - - id: os_suse12_zseries - display_name: SUSE 12 Z Series - run_on: - - suse12-zseries-build - - suse12-zseries-test - - id: os_ubuntu1604_arm64 - display_name: Ubuntu 16.04 ARM64 - run_on: - - ubuntu1604-arm64-large - - ubuntu1604-arm64-small - - id: os_ubuntu1604_power8 - display_name: Ubuntu 16.04 Power8 - run_on: - - ubuntu1604-power8-build - - ubuntu1604-power8-test - - id: os_windows64 - display_name: Win64 - run_on: - - windows-64-vs2013-compile - - windows-64-vs2013-test - - windows-64-vs2015-compile - - windows-64-vs2015-test - - windows-64-vs2015-small - - windows-64-vs2015-large - - id: node-version - display_name: "Node.js" - values: - - id: "Argon" - display_name: "Node.js Argon LTS" - variables: - NODE_LTS_NAME: "argon" - - id: "Boron" - display_name: "Node.js Boron LTS" - variables: - NODE_LTS_NAME: "boron" - -buildvariants: -- matrix_name: "tests-all" - matrix_spec: { os: "*", node-version: '*' } - display_name: "${os} ${node-version}" - tasks: - - ".latest" - - ".3.6" - - ".3.4" - - ".3.2" - - ".3.0" - - ".2.6" From 89dfdbd81a4e6b629b099bbbb23fadbe523a86a8 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 26 Mar 2018 12:26:40 -0400 Subject: [PATCH 39/39] test(auth): skip whole suite rather than individual tests --- .../basic_single_server_auth_tests.js | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/test/tests/functional/basic_single_server_auth_tests.js b/test/tests/functional/basic_single_server_auth_tests.js index ebc665602..14d5b12a2 100644 --- a/test/tests/functional/basic_single_server_auth_tests.js +++ b/test/tests/functional/basic_single_server_auth_tests.js @@ -7,9 +7,9 @@ var expect = require('chai').expect, Connection = require('../../../lib/connection/connection'), Bson = require('bson'); -describe('Basic single server auth tests', function() { - // Skipped due to use of topology manager - it.skip('should fail to authenticate server using scram-sha-1 using connect auth', { +// Skipped due to use of topology manager +describe.skip('Basic single server auth tests', function() { + it('should fail to authenticate server using scram-sha-1 using connect auth', { metadata: { requires: { topology: 'auth' } }, test: function(done) { @@ -58,7 +58,7 @@ describe('Basic single server auth tests', function() { }); // Skipped due to use of topology manager - it.skip('should correctly authenticate server using scram-sha-1 using connect auth', { + it('should correctly authenticate server using scram-sha-1 using connect auth', { metadata: { requires: { topology: 'auth' } }, test: function(done) { @@ -120,8 +120,7 @@ describe('Basic single server auth tests', function() { } }); - // Skipped due to use of topology manager - it.skip( + it( 'should correctly authenticate server using scram-sha-1 using connect auth and maintain auth on new connections', { metadata: { requires: { topology: 'auth' } }, @@ -220,8 +219,7 @@ describe('Basic single server auth tests', function() { } ); - // Skipped due to use of topology manager - it.skip('should correctly authenticate server using scram-sha-1 using auth method', { + it('should correctly authenticate server using scram-sha-1 using auth method', { metadata: { requires: { topology: 'auth' } }, test: function(done) { @@ -331,8 +329,7 @@ describe('Basic single server auth tests', function() { } }); - // Skipped due to use of topology manager - it.skip('should correctly authenticate server using scram-sha-1 using connect auth then logout', { + it('should correctly authenticate server using scram-sha-1 using connect auth then logout', { metadata: { requires: { topology: 'auth' } }, test: function(done) { @@ -419,8 +416,7 @@ describe('Basic single server auth tests', function() { } }); - // Skipped due to use of topology manager - it.skip('should correctly have server auth wait for logout to finish', { + it('should correctly have server auth wait for logout to finish', { metadata: { requires: { topology: 'auth' } }, test: function(done) {