diff --git a/.evergreen/config.yml b/.evergreen/config.yml index e22ced00e47..0ab8d874681 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -11,7 +11,6 @@ functions: - command: git.get_project params: directory: src - - command: git.apply_patch - command: shell.exec params: working_dir: src @@ -29,6 +28,14 @@ functions: export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" export UPLOAD_BUCKET="${project}" + # fix paths on windows + if [ "Windows_NT" = "$OS" ]; then + export DRIVERS_TOOLS=$(cygpath -m -a $DRIVERS_TOOLS) + export MONGO_ORCHESTRATION_HOME=$(cygpath -m -a $MONGO_ORCHESTRATION_HOME) + export MONGODB_BINARIES=$(cygpath -m -a $MONGODB_BINARIES) + export PROJECT_DIRECTORY=$(cygpath -m -a $PROJECT_DIRECTORY) + fi + cat < expansion.yml CURRENT_VERSION: "$CURRENT_VERSION" DRIVERS_TOOLS: "$DRIVERS_TOOLS" @@ -60,14 +67,7 @@ functions: script: > ${PREPARE_SHELL} - rm -rf $DRIVERS_TOOLS - - if [ "${project}" = "drivers-tools" ]; then - # If this was a patch build, doing a fresh clone would not actually test the patch - cp -R ${PROJECT_DIRECTORY}/ $DRIVERS_TOOLS - else - git clone git://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS - fi + git clone git://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config @@ -101,6 +101,7 @@ functions: type: test params: working_dir: src + timeout_secs: 60 script: | ${PREPARE_SHELL} @@ -112,7 +113,7 @@ functions: fi AUTH=${AUTH} SSL=${SSL} UNIFIED=${UNIFIED} MONGODB_URI="${MONGODB_URI}" \ - bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh + NODE_VERSION=${NODE_VERSION} bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh run checks: - command: shell.exec type: test @@ -124,20 +125,35 @@ functions: cleanup: - command: shell.exec params: + silent: true script: | ${PREPARE_SHELL} rm -rf $DRIVERS_TOOLS || true fix absolute paths: - command: shell.exec params: + silent: true 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: + silent: true + 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: + silent: true script: | ${PREPARE_SHELL} for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do @@ -150,7 +166,11 @@ functions: working_dir: src script: | ${PREPARE_SHELL} - NODE_LTS_NAME=${NODE_LTS_NAME} bash ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh + NODE_LTS_NAME=${NODE_LTS_NAME} MSVS_VERSION=${MSVS_VERSION} \ + bash ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh + - command: expansions.update + params: + file: src/deps-expansion.yml run atlas tests: - command: shell.exec type: test @@ -419,11 +439,14 @@ functions: pre: - func: fetch source - func: prepare resources + - func: windows fix - func: fix absolute paths - func: make files executable post: - func: upload test results - func: cleanup +ignore: + - '*.md' tasks: - name: test-latest-server tags: @@ -1649,6 +1672,153 @@ buildvariants: NODE_LTS_NAME: argon CLIENT_ENCRYPTION: true tasks: *ref_2 + - name: windows-64-vs2013-erbium + display_name: Windows (VS2013) Node Erbium + run_on: windows-64-vs2013-large + expansions: + NODE_LTS_NAME: erbium + MSVS_VERSION: 2013 + tasks: &ref_3 + - test-4.2-server + - test-4.2-replica_set + - test-4.2-sharded_cluster + - test-4.2-server-unified + - test-4.2-replica_set-unified + - test-4.2-sharded_cluster-unified + - test-4.0-server + - test-4.0-replica_set + - test-4.0-sharded_cluster + - test-4.0-server-unified + - test-4.0-replica_set-unified + - test-4.0-sharded_cluster-unified + - test-3.6-server + - test-3.6-replica_set + - test-3.6-sharded_cluster + - test-3.6-server-unified + - test-3.6-replica_set-unified + - test-3.6-sharded_cluster-unified + - test-3.4-server + - test-3.4-replica_set + - test-3.4-sharded_cluster + - test-3.4-server-unified + - test-3.4-replica_set-unified + - test-3.4-sharded_cluster-unified + - test-3.2-server + - test-3.2-replica_set + - test-3.2-sharded_cluster + - test-3.2-server-unified + - test-3.2-replica_set-unified + - test-3.2-sharded_cluster-unified + - test-3.0-server + - test-3.0-replica_set + - test-3.0-sharded_cluster + - test-3.0-server-unified + - test-3.0-replica_set-unified + - test-3.0-sharded_cluster-unified + - test-2.6-server + - test-2.6-replica_set + - test-2.6-sharded_cluster + - test-2.6-server-unified + - test-2.6-replica_set-unified + - test-2.6-sharded_cluster-unified + - name: windows-64-vs2013-dubnium + display_name: Windows (VS2013) Node Dubnium + run_on: windows-64-vs2013-large + expansions: + NODE_LTS_NAME: dubnium + MSVS_VERSION: 2013 + tasks: *ref_3 + - name: windows-64-vs2013-carbon + display_name: Windows (VS2013) Node Carbon + run_on: windows-64-vs2013-large + expansions: + NODE_LTS_NAME: carbon + MSVS_VERSION: 2013 + tasks: *ref_3 + - name: windows-64-vs2013-boron + display_name: Windows (VS2013) Node Boron + run_on: windows-64-vs2013-large + expansions: + NODE_LTS_NAME: boron + MSVS_VERSION: 2013 + tasks: *ref_3 + - name: windows-64-vs2013-argon + display_name: Windows (VS2013) Node Argon + run_on: windows-64-vs2013-large + expansions: + NODE_LTS_NAME: argon + MSVS_VERSION: 2013 + tasks: *ref_3 + - name: windows-64-vs2015-erbium + display_name: Windows (VS2015) Node Erbium + run_on: windows-64-vs2015-large + expansions: + NODE_LTS_NAME: erbium + MSVS_VERSION: 2015 + tasks: *ref_3 + - name: windows-64-vs2015-dubnium + display_name: Windows (VS2015) Node Dubnium + run_on: windows-64-vs2015-large + expansions: + NODE_LTS_NAME: dubnium + MSVS_VERSION: 2015 + tasks: *ref_3 + - name: windows-64-vs2015-carbon + display_name: Windows (VS2015) Node Carbon + run_on: windows-64-vs2015-large + expansions: + NODE_LTS_NAME: carbon + MSVS_VERSION: 2015 + tasks: *ref_3 + - name: windows-64-vs2015-boron + display_name: Windows (VS2015) Node Boron + run_on: windows-64-vs2015-large + expansions: + NODE_LTS_NAME: boron + MSVS_VERSION: 2015 + tasks: *ref_3 + - name: windows-64-vs2015-argon + display_name: Windows (VS2015) Node Argon + run_on: windows-64-vs2015-large + expansions: + NODE_LTS_NAME: argon + MSVS_VERSION: 2015 + tasks: *ref_3 + - name: windows-64-vs2017-erbium + display_name: Windows (VS2017) Node Erbium + run_on: windows-64-vs2017-large + expansions: + NODE_LTS_NAME: erbium + MSVS_VERSION: 2017 + tasks: *ref_3 + - name: windows-64-vs2017-dubnium + display_name: Windows (VS2017) Node Dubnium + run_on: windows-64-vs2017-large + expansions: + NODE_LTS_NAME: dubnium + MSVS_VERSION: 2017 + tasks: *ref_3 + - name: windows-64-vs2017-carbon + display_name: Windows (VS2017) Node Carbon + run_on: windows-64-vs2017-large + expansions: + NODE_LTS_NAME: carbon + MSVS_VERSION: 2017 + tasks: *ref_3 + - name: windows-64-vs2017-boron + display_name: Windows (VS2017) Node Boron + run_on: windows-64-vs2017-large + expansions: + NODE_LTS_NAME: boron + MSVS_VERSION: 2017 + tasks: *ref_3 + - name: windows-64-vs2017-argon + display_name: Windows (VS2017) Node Argon + run_on: windows-64-vs2017-large + expansions: + NODE_LTS_NAME: argon + MSVS_VERSION: 2017 + tasks: *ref_3 - name: lint display_name: lint run_on: rhel70 diff --git a/.evergreen/config.yml.in b/.evergreen/config.yml.in index e450f48340f..82d06c7432f 100644 --- a/.evergreen/config.yml.in +++ b/.evergreen/config.yml.in @@ -26,10 +26,7 @@ functions: - 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 + # Make an evergreen expansion file with dynamic values - command: shell.exec params: working_dir: "src" @@ -47,6 +44,14 @@ functions: export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" export UPLOAD_BUCKET="${project}" + # fix paths on windows + if [ "Windows_NT" = "$OS" ]; then + export DRIVERS_TOOLS=$(cygpath -m -a $DRIVERS_TOOLS) + export MONGO_ORCHESTRATION_HOME=$(cygpath -m -a $MONGO_ORCHESTRATION_HOME) + export MONGODB_BINARIES=$(cygpath -m -a $MONGODB_BINARIES) + export PROJECT_DIRECTORY=$(cygpath -m -a $PROJECT_DIRECTORY) + fi + cat < expansion.yml CURRENT_VERSION: "$CURRENT_VERSION" DRIVERS_TOOLS: "$DRIVERS_TOOLS" @@ -80,13 +85,7 @@ functions: params: script: | ${PREPARE_SHELL} - rm -rf $DRIVERS_TOOLS - if [ "${project}" = "drivers-tools" ]; then - # If this was a patch build, doing a fresh clone would not actually test the patch - cp -R ${PROJECT_DIRECTORY}/ $DRIVERS_TOOLS - else - git clone git://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS - fi + git clone git://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config "bootstrap mongo-orchestration": @@ -121,6 +120,7 @@ functions: type: test params: working_dir: "src" + timeout_secs: 60 script: | ${PREPARE_SHELL} @@ -132,7 +132,7 @@ functions: fi AUTH=${AUTH} SSL=${SSL} UNIFIED=${UNIFIED} MONGODB_URI="${MONGODB_URI}" \ - bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh + NODE_VERSION=${NODE_VERSION} bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh "run checks": - command: shell.exec @@ -146,6 +146,7 @@ functions: "cleanup": - command: shell.exec params: + silent: true script: | ${PREPARE_SHELL} rm -rf $DRIVERS_TOOLS || true @@ -153,27 +154,30 @@ functions: "fix absolute paths": - command: shell.exec params: + silent: true 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 + "windows fix": + - command: shell.exec + params: + silent: true + 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: + silent: true script: | ${PREPARE_SHELL} for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do @@ -187,7 +191,11 @@ functions: working_dir: "src" script: | ${PREPARE_SHELL} - NODE_LTS_NAME=${NODE_LTS_NAME} bash ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh + NODE_LTS_NAME=${NODE_LTS_NAME} MSVS_VERSION=${MSVS_VERSION} \ + bash ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh + - command: expansions.update + params: + file: src/deps-expansion.yml "run atlas tests": - command: shell.exec @@ -266,7 +274,7 @@ functions: } EOF - run aws auth test with regular aws credentials: + "run aws auth test with regular aws credentials": - command: shell.exec type: test params: @@ -295,7 +303,7 @@ functions: ${PREPARE_SHELL} ${PROJECT_DIRECTORY}/.evergreen/run-mongodb-aws-test.sh - run aws auth test with assume role credentials: + "run aws auth test with assume role credentials": - command: shell.exec type: test params: @@ -328,7 +336,7 @@ functions: ${PREPARE_SHELL} ${PROJECT_DIRECTORY}/.evergreen/run-mongodb-aws-test.sh - run aws auth test with aws EC2 credentials: + "run aws auth test with aws EC2 credentials": - command: shell.exec type: test params: @@ -345,7 +353,7 @@ functions: ${PREPARE_SHELL} ${PROJECT_DIRECTORY}/.evergreen/run-mongodb-aws-test.sh - run aws auth test with aws credentials as environment variables: + "run aws auth test with aws credentials as environment variables": - command: shell.exec type: test params: @@ -365,7 +373,7 @@ functions: ${PREPARE_SHELL} ${PROJECT_DIRECTORY}/.evergreen/run-mongodb-aws-test.sh - run aws auth test with aws credentials and session token as environment variables: + "run aws auth test with aws credentials and session token as environment variables": - command: shell.exec type: test params: @@ -386,7 +394,7 @@ functions: ${PREPARE_SHELL} ${PROJECT_DIRECTORY}/.evergreen/run-mongodb-aws-test.sh - run aws ECS auth test: + "run aws ECS auth test": - command: shell.exec type: test params: @@ -413,7 +421,7 @@ functions: cat setup.js mongo --nodb setup.js aws_e2e_ecs.js - run-ocsp-test: + "run-ocsp-test": - command: shell.exec type: test params: @@ -426,7 +434,7 @@ functions: OCSP_TLS_SHOULD_SUCCEED="${OCSP_TLS_SHOULD_SUCCEED}" \ bash ${PROJECT_DIRECTORY}/.evergreen/run-ocsp-tests.sh - run-valid-ocsp-server: + "run-valid-ocsp-server": - command: shell.exec params: script: | @@ -444,7 +452,7 @@ functions: --ocsp_responder_key rsa/ca.key \ -p 8100 -v - run-revoked-ocsp-server: + "run-revoked-ocsp-server": - command: shell.exec params: script: | @@ -464,17 +472,20 @@ functions: -v \ --fault revoked - upload test results: + "upload test results": - command: attach.xunit_results params: file: src/xunit.xml pre: - func: "fetch source" - func: "prepare resources" - # - func: "windows fix" + - func: "windows fix" - func: "fix absolute paths" - func: "make files executable" post: - func: "upload test results" - func: "cleanup" + +ignore: + - '*.md' diff --git a/.evergreen/generate_evergreen_tasks.js b/.evergreen/generate_evergreen_tasks.js index 763086e1236..5086866bda3 100644 --- a/.evergreen/generate_evergreen_tasks.js +++ b/.evergreen/generate_evergreen_tasks.js @@ -39,24 +39,28 @@ const OPERATING_SYSTEMS = [ run_on: 'ubuntu1804-test', mongoVersion: '>=3.2', clientEncryption: true + }, + { + name: 'windows-64-vs2013', + display_name: 'Windows (VS2013)', + run_on: 'windows-64-vs2013-large', + msvsVersion: 2013, + mongoVersion: '<4.4' + }, + { + name: 'windows-64-vs2015', + display_name: 'Windows (VS2015)', + run_on: 'windows-64-vs2015-large', + msvsVersion: 2015, + mongoVersion: '<4.4' + }, + { + name: 'windows-64-vs2017', + display_name: 'Windows (VS2017)', + run_on: 'windows-64-vs2017-large', + msvsVersion: 2017, + mongoVersion: '<4.4' } - - // Windows. reenable this when nvm supports windows, or we settle on an alternative tool - // { - // name: 'windows-64-vs2010-test', - // display_name: 'Windows (VS2010)', - // run_on: 'windows-64-vs2010-test' - // }, - // { - // name: 'windows-64-vs2013-test', - // display_name: 'Windows (VS2013)', - // run_on: 'windows-64-vs2013-test' - // }, - // { - // name: 'windows-64-vs2015-test', - // display_name: 'Windows (VS2015)', - // run_on: 'windows-64-vs2015-test' - // } ].map(osConfig => Object.assign( { @@ -68,6 +72,7 @@ const OPERATING_SYSTEMS = [ ) ); +const BASE_TASKS = []; const TASKS = []; const SINGLETON_TASKS = []; @@ -98,7 +103,7 @@ function makeTask({ mongoVersion, topology }) { MONGODB_VERSIONS.forEach(mongoVersion => { TOPOLOGIES.forEach(topology => - TASKS.push(makeTask({ mongoVersion, topology })) + BASE_TASKS.push(makeTask({ mongoVersion, topology })) ); }); @@ -312,14 +317,14 @@ const BUILD_VARIANTS = []; const getTaskList = (() => { const memo = {}; - return function(mongoVersion) { - const key = mongoVersion; + return function(mongoVersion, onlyBaseTasks = false) { + const key = mongoVersion + (onlyBaseTasks ? 'b' : ''); if (memo[key]) { return memo[key]; } - - const ret = TASKS.filter(task => { + const taskList = onlyBaseTasks ? BASE_TASKS : BASE_TASKS.concat(TASKS); + const ret = taskList.filter(task => { const tasksWithVars = task.commands.filter(task => !!task.vars); if (task.name.match(/^aws/)) return false; @@ -352,10 +357,11 @@ OPERATING_SYSTEMS.forEach( run_on, mongoVersion = '>=2.6', nodeVersions = NODE_VERSIONS, - clientEncryption + clientEncryption, + msvsVersion }) => { const testedNodeVersions = NODE_VERSIONS.filter(version => nodeVersions.includes(version)); - const tasks = getTaskList(mongoVersion); + const tasks = getTaskList(mongoVersion, !!msvsVersion); testedNodeVersions.forEach(NODE_LTS_NAME => { const nodeLtsDisplayName = `Node ${NODE_LTS_NAME[0].toUpperCase()}${NODE_LTS_NAME.substr(1)}`; @@ -366,6 +372,9 @@ OPERATING_SYSTEMS.forEach( if (clientEncryption) { expansions.CLIENT_ENCRYPTION = true; } + if (msvsVersion) { + expansions.MSVS_VERSION = msvsVersion; + } BUILD_VARIANTS.push({ name, display_name, run_on, expansions, tasks }); }); @@ -407,7 +416,7 @@ BUILD_VARIANTS.push({ }); const fileData = yaml.safeLoad(fs.readFileSync(`${__dirname}/config.yml.in`, 'utf8')); -fileData.tasks = (fileData.tasks || []).concat(TASKS).concat(SINGLETON_TASKS); +fileData.tasks = (fileData.tasks || []).concat(BASE_TASKS).concat(TASKS).concat(SINGLETON_TASKS); fileData.buildvariants = (fileData.buildvariants || []).concat(BUILD_VARIANTS); fs.writeFileSync(`${__dirname}/config.yml`, yaml.safeDump(fileData, { lineWidth: 120 }), 'utf8'); diff --git a/.evergreen/install-dependencies.sh b/.evergreen/install-dependencies.sh index e856ee76f48..2c4d52e74cd 100644 --- a/.evergreen/install-dependencies.sh +++ b/.evergreen/install-dependencies.sh @@ -2,7 +2,11 @@ # set -o xtrace # Write all commands first to stderr set -o errexit # Exit the script with error if any of the commands fail +NVM_WINDOWS_URL="https://github.com/coreybutler/nvm-windows/releases/download/1.1.7/nvm-noinstall.zip" +NVM_URL="https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh" + NODE_LTS_NAME=${NODE_LTS_NAME:-carbon} +MSVS_VERSION=${MSVS_VERSION:-2017} NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts" NPM_CACHE_DIR="${NODE_ARTIFACTS_PATH}/npm" NPM_TMP_DIR="${NODE_ARTIFACTS_PATH}/tmp" @@ -16,22 +20,91 @@ 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.35.3/install.sh | bash -[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" -nvm install --no-progress --lts=${NODE_LTS_NAME} +case $NODE_LTS_NAME in + "argon") + VERSION=4 + ;; + "boron") + VERSION=6 + ;; + "carbon") + VERSION=8 + ;; + "dubnium") + VERSION=10 + ;; + "erbium") + VERSION=12 + ;; + "fermium") + VERSION=14 + ;; + *) + echo "Unsupported Node LTS version $1" + exit 1 + ;; +esac +NODE_VERSION=$(curl --retry 8 --retry-delay 5 --max-time 50 -s -o- \ + https://nodejs.org/download/release/latest-v${VERSION}.x/SHASUMS256.txt \ +| head -n 1 | awk '{print $2};' | cut -d- -f2) +export NODE_VERSION=${NODE_VERSION:1} + +# output node version to expansions file for use in subsequent scripts +cat < deps-expansion.yml + NODE_VERSION: "$NODE_VERSION" +EOT + +# install Node.js on Windows +if [[ "$OS" == "Windows_NT" ]]; then + # Delete pre-existing node to avoid version conflicts + rm -rf "/cygdrive/c/Program Files/nodejs" + + export NVM_HOME=`cygpath -w "$NVM_DIR"` + export NVM_SYMLINK=`cygpath -w "$NODE_ARTIFACTS_PATH/bin"` + export NVM_ARTIFACTS_PATH=`cygpath -w "$NODE_ARTIFACTS_PATH/bin"` + export PATH=`cygpath $NVM_SYMLINK`:`cygpath $NVM_HOME`:$PATH + + curl -L $NVM_WINDOWS_URL -o nvm.zip + unzip -d $NVM_DIR nvm.zip + rm nvm.zip + + chmod 777 $NVM_DIR + chmod -R a+rx $NVM_DIR + + cat < $NVM_DIR/settings.txt +root: $NVM_HOME +path: $NVM_SYMLINK +EOT + nvm install $NODE_VERSION + nvm use $NODE_VERSION + which node || echo "node not found, PATH=$PATH" + which npm || echo "npm not found, PATH=$PATH" + npm config set msvs_version ${MSVS_VERSION} + npm config set scripts-prepend-node-path true + +# install Node.js on Linux/MacOS +else + curl -o- $NVM_URL | bash + [ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" + nvm install --no-progress --lts=${NODE_LTS_NAME} -# setup npm cache in a local directory -cat < .npmrc + # setup npm cache in a local directory + cat < .npmrc devdir=${NPM_CACHE_DIR}/.node-gyp init-module=${NPM_CACHE_DIR}/.npm-init.js cache=${NPM_CACHE_DIR} tmp=${NPM_TMP_DIR} registry=https://registry.npmjs.org EOT +fi # NOTE: registry was overridden to not use artifactory, remove the `registry` line when # BUILD-6774 is resolved. # install node dependencies -npm install +if [[ "$SKIP_INSTALL" == "1" ]]; then + echo "Skipping npm install" +else + echo "Running npm install" + npm install --unsafe-perm +fi diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index d8c4eccc57e..492a415939d 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -12,6 +12,7 @@ set -o errexit # Exit the script with error if any of the commands fail AUTH=${AUTH:-noauth} UNIFIED=${UNIFIED:-} MONGODB_URI=${MONGODB_URI:-} +TEST_NPM_SCRIPT="test-nolint" # ssl setup SSL=${SSL:-nossl} @@ -26,7 +27,16 @@ echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI" export PATH="/opt/mongodbtoolchain/v2/bin:$PATH" NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts" export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +if [[ "$OS" == "Windows_NT" ]]; then + export NVM_HOME=`cygpath -m -a "$NVM_DIR"` + export NVM_SYMLINK=`cygpath -m -a "$NODE_ARTIFACTS_PATH/bin"` + export NVM_ARTIFACTS_PATH=`cygpath -m -a "$NODE_ARTIFACTS_PATH/bin"` + export PATH=`cygpath $NVM_SYMLINK`:`cygpath $NVM_HOME`:$PATH + echo "updated path on windows PATH=$PATH" +else + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +fi +echo "initializing NVM, NVM_DIR=$NVM_DIR" # only run FLE tets on hosts we explicitly choose to test on if [[ -z "${CLIENT_ENCRYPTION}" ]]; then @@ -36,4 +46,4 @@ else npm install mongodb-client-encryption fi -MONGODB_UNIFIED_TOPOLOGY=${UNIFIED} MONGODB_URI=${MONGODB_URI} npm run test-nolint +MONGODB_UNIFIED_TOPOLOGY=${UNIFIED} MONGODB_URI=${MONGODB_URI} npm run ${TEST_NPM_SCRIPT} diff --git a/test/functional/change_stream.test.js b/test/functional/change_stream.test.js index 5ce79962563..a5f83366c8d 100644 --- a/test/functional/change_stream.test.js +++ b/test/functional/change_stream.test.js @@ -1,5 +1,4 @@ 'use strict'; -const path = require('path'); const assert = require('assert'); const Transform = require('stream').Transform; const MongoNetworkError = require('../../lib/core').MongoNetworkError; @@ -13,6 +12,8 @@ const chai = require('chai'); const expect = chai.expect; const sinon = require('sinon'); const fs = require('fs'); +const os = require('os'); +const path = require('path'); const crypto = require('crypto'); const BSON = require('bson'); const Long = BSON.Long; @@ -1478,13 +1479,14 @@ describe('Change Streams', function() { it('should resume piping of Change Streams when a resumable error is encountered', { metadata: { requires: { + os: '!win32', // (fs.watch isn't reliable on win32) generators: true, topology: 'single', mongodb: '>=3.6' } }, test: function(done) { - const filename = path.join(__dirname, '_nodemongodbnative_resumepipe.txt'); + const filename = path.join(os.tmpdir(), '_nodemongodbnative_resumepipe.txt'); this.defer(() => fs.unlinkSync(filename)); const configuration = this.configuration; const ObjectId = configuration.require.ObjectId; @@ -1600,6 +1602,7 @@ describe('Change Streams', function() { const changeStream = collection.watch(pipeline); const outStream = fs.createWriteStream(filename); + this.defer(() => outStream.close()); changeStream.stream({ transform: JSON.stringify }).pipe(outStream); this.defer(() => changeStream.close()); diff --git a/test/functional/cmap/connection.test.js b/test/functional/cmap/connection.test.js index 121fa94ec5a..98a0834777f 100644 --- a/test/functional/cmap/connection.test.js +++ b/test/functional/cmap/connection.test.js @@ -61,19 +61,26 @@ describe('Connection', function() { }); }); - it('should support socket timeouts', function(done) { - const connectOptions = Object.assign({ - host: '240.0.0.1', - connectionType: Connection, - bson: new BSON(), - connectionTimeout: 500 - }); + it('should support socket timeouts', { + metadata: { + requires: { + os: '!win32' // NODE-2941: 240.0.0.1 doesnt work for windows + } + }, + test: function(done) { + const connectOptions = Object.assign({ + host: '240.0.0.1', + connectionType: Connection, + bson: new BSON(), + connectionTimeout: 500 + }); - connect(connectOptions, err => { - expect(err).to.exist; - expect(err).to.match(/timed out/); - done(); - }); + connect(connectOptions, err => { + expect(err).to.exist; + expect(err).to.match(/timed out/); + done(); + }); + } }); it('should support calling back multiple times on exhaust commands', { diff --git a/test/functional/connection.test.js b/test/functional/connection.test.js index a75916eeb6f..2f56b47ce66 100644 --- a/test/functional/connection.test.js +++ b/test/functional/connection.test.js @@ -12,7 +12,7 @@ describe('Connection', function() { * @ignore */ it('should correctly start monitoring for single server connection', { - metadata: { requires: { topology: 'single' } }, + metadata: { requires: { topology: 'single', os: '!win32' } }, // The actual test we wish to run test: function(done) { @@ -36,7 +36,7 @@ describe('Connection', function() { * @ignore */ it('should correctly disable monitoring for single server connection', { - metadata: { requires: { topology: 'single' } }, + metadata: { requires: { topology: 'single', os: '!win32' } }, // The actual test we wish to run test: function(done) { @@ -64,7 +64,7 @@ describe('Connection', function() { * @ignore */ it('should correctly connect to server using domain socket', { - metadata: { requires: { topology: 'single' } }, + metadata: { requires: { topology: 'single', os: '!win32' } }, // The actual test we wish to run test: function(done) { @@ -161,7 +161,7 @@ describe('Connection', function() { * @ignore */ it('should connect to server using domain socket with undefined port', { - metadata: { requires: { topology: 'single' } }, + metadata: { requires: { topology: 'single', os: '!win32' } }, // The actual test we wish to run test: function(done) { diff --git a/test/functional/core/rs_mocks/connection.test.js b/test/functional/core/rs_mocks/connection.test.js index 74a3f962be0..1d9281d1fdb 100644 --- a/test/functional/core/rs_mocks/connection.test.js +++ b/test/functional/core/rs_mocks/connection.test.js @@ -265,7 +265,8 @@ describe('ReplSet Connection Tests (mocks)', function() { metadata: { requires: { generators: true, - topology: 'single' + topology: 'single', + os: '!win32' // NODE-2943: timeout on windows } }, @@ -372,7 +373,8 @@ describe('ReplSet Connection Tests (mocks)', function() { metadata: { requires: { generators: true, - topology: 'single' + topology: 'single', + os: '!win32' // NODE-2943: timeout on windows } }, diff --git a/test/functional/core/tailable_cursor.test.js b/test/functional/core/tailable_cursor.test.js index 46fa74cd3d4..c48907f69c9 100644 --- a/test/functional/core/tailable_cursor.test.js +++ b/test/functional/core/tailable_cursor.test.js @@ -11,7 +11,9 @@ describe('Tailable cursor tests', function() { it('should correctly perform awaitdata', { metadata: { - requires: { topology: ['single', 'replicaset', 'sharded'] } + requires: { + os: '!win32' // NODE-2943: timeout on windows + } }, test: function(done) { diff --git a/test/functional/cursor.test.js b/test/functional/cursor.test.js index 64a07f2ab3b..9b3588ff538 100644 --- a/test/functional/cursor.test.js +++ b/test/functional/cursor.test.js @@ -2,6 +2,8 @@ const test = require('./shared').assert; const setupDatabase = require('./shared').setupDatabase; const fs = require('fs'); +const os = require('os'); +const path = require('path'); const expect = require('chai').expect; const Long = require('bson').Long; const sinon = require('sinon'); @@ -2216,7 +2218,9 @@ describe('Cursor', function() { // Add a tag that our runner can trigger on // in this case we are setting that node needs to be higher than 0.10.X to run metadata: { - requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } + requires: { + os: '!win32' // NODE-2943: timeout on windows + } }, // The actual test we wish to run @@ -2239,8 +2243,8 @@ describe('Cursor', function() { collection.insert(docs, configuration.writeConcernMax(), function(err) { test.equal(null, err); - var filename = '/tmp/_nodemongodbnative_stream_out.txt', - out = fs.createWriteStream(filename); + const filename = path.join(os.tmpdir(), '_nodemongodbnative_stream_out.txt'); + const out = fs.createWriteStream(filename); // hack so we don't need to create a stream filter just to // stringify the objects (otherwise the created file would @@ -2282,12 +2286,13 @@ describe('Cursor', function() { /** * @ignore */ - it('shouldCloseDeadTailableCursors', { + it('should close dead tailable cursors', { // Add a tag that our runner can trigger on // in this case we are setting that node needs to be higher than 0.10.X to run metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] }, - sessions: { skipLeakTests: true } + sessions: { skipLeakTests: true }, + os: '!win32' // NODE-2943: timeout on windows }, // The actual test we wish to run diff --git a/test/functional/mongo_client.test.js b/test/functional/mongo_client.test.js index 3943a04bcb8..a2081144d21 100644 --- a/test/functional/mongo_client.test.js +++ b/test/functional/mongo_client.test.js @@ -487,7 +487,7 @@ describe('MongoClient', function() { }); it('should correctly connect to mongodb using domain socket', { - metadata: { requires: { topology: ['single'] } }, + metadata: { requires: { topology: ['single'], os: '!win32' } }, // The actual test we wish to run test: function(done) { diff --git a/test/functional/operation_example.test.js b/test/functional/operation_example.test.js index 599c0f687f4..189e7ee069a 100644 --- a/test/functional/operation_example.test.js +++ b/test/functional/operation_example.test.js @@ -9355,7 +9355,9 @@ describe('Operation Examples', function() { */ it('Should correctly add capped collection options to cursor', { metadata: { - requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } + requires: { + os: '!win32' // NODE-2943: timeout on windows + } }, // The actual test we wish to run @@ -9379,7 +9381,7 @@ describe('Operation Examples', function() { // Create a capped collection with a maximum of 1000 documents db.createCollection( 'a_simple_collection_2', - { capped: true, size: 100000, max: 10000, w: 1 }, + { capped: true, size: 100000, max: 1000, w: 1 }, function(err, collection) { test.equal(null, err); diff --git a/test/functional/operation_generators_example.test.js b/test/functional/operation_generators_example.test.js index 1125da9db98..8054e446723 100644 --- a/test/functional/operation_generators_example.test.js +++ b/test/functional/operation_generators_example.test.js @@ -6464,7 +6464,13 @@ describe('Operation (Generators)', function() { * @ignore */ it('Should correctly add capped collection options to cursor with Generators', { - metadata: { requires: { generators: true, topology: ['single'] } }, + metadata: { + requires: { + generators: true, + topology: ['single'], + os: '!win32' // NODE-2943: timeout on windows + } + }, // The actual test we wish to run test: function() { @@ -6492,7 +6498,7 @@ describe('Operation (Generators)', function() { var collection = yield db.createCollection('a_simple_collection_2_with_generators', { capped: true, size: 100000, - max: 10000, + max: 1000, w: 1 }); var docs = []; diff --git a/test/functional/operation_promises_example.test.js b/test/functional/operation_promises_example.test.js index b73d8c06801..71a0e0424e6 100644 --- a/test/functional/operation_promises_example.test.js +++ b/test/functional/operation_promises_example.test.js @@ -7036,7 +7036,12 @@ describe('Operation (Promises)', function() { * @ignore */ it('Should correctly add capped collection options to cursor With Promises', { - metadata: { requires: { topology: ['single'] } }, + metadata: { + requires: { + topology: ['single'], + os: '!win32' // NODE-2943: timeout on windows + } + }, // The actual test we wish to run test: function(done) { @@ -7062,7 +7067,7 @@ describe('Operation (Promises)', function() { db.createCollection('a_simple_collection_2_with_promise', { capped: true, size: 100000, - max: 10000, + max: 1000, w: 1 }) .then(function(_collection) { diff --git a/test/mocha.opts b/test/mocha.opts index cf335621394..9651c194fea 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -3,3 +3,4 @@ --file test/tools/runner --ui test/tools/runner/metadata_ui.js --reporter spec-xunit-file + --colors diff --git a/test/tools/runner/filters/mongodb_topology_filter.js b/test/tools/runner/filters/mongodb_topology_filter.js index 2725499f92d..76506ae08fd 100755 --- a/test/tools/runner/filters/mongodb_topology_filter.js +++ b/test/tools/runner/filters/mongodb_topology_filter.js @@ -9,7 +9,7 @@ const TopologyType = require('../../../../lib/core/sdam/common').TopologyType; * example: * metadata: { * requires: { - * topology: 'single' | 'replicaset' | 'sharded' | 'auth' | 'ssl' + * topology: 'single' | 'replicaset' | 'sharded' * } * } */ diff --git a/test/unit/core/connect.test.js b/test/unit/core/connect.test.js index 2659c7f2a4d..746b0645af0 100644 --- a/test/unit/core/connect.test.js +++ b/test/unit/core/connect.test.js @@ -100,17 +100,24 @@ describe('Connect Tests', function() { }); }); - it('should allow a cancellaton token', function(done) { - const cancellationToken = new EventEmitter(); - setTimeout(() => cancellationToken.emit('cancel'), 500); - // set no response handler for mock server, effecively blackhole requests - - connect({ host: '240.0.0.1' }, cancellationToken, (err, conn) => { - expect(err).to.exist; - expect(err).to.match(/connection establishment was cancelled/); - expect(conn).to.not.exist; - done(); - }); + it('should allow a cancellaton token', { + metadata: { + requires: { + os: '!win32' // NODE-2941: 240.0.0.1 doesnt work for windows + } + }, + test: function(done) { + const cancellationToken = new EventEmitter(); + setTimeout(() => cancellationToken.emit('cancel'), 500); + // set no response handler for mock server, effecively blackhole requests + + connect({ host: '240.0.0.1' }, cancellationToken, (err, conn) => { + expect(err).to.exist; + expect(err).to.match(/connection establishment was cancelled/); + expect(conn).to.not.exist; + done(); + }); + } }); describe('runCommand', function() {