From a0d84f6ba423a3af4d311fb9d1843005379670ae Mon Sep 17 00:00:00 2001 From: Dan Aprahamian Date: Thu, 26 Jul 2018 11:44:08 -0400 Subject: [PATCH] test(evergreen): adding evergreen config to native driver Adds very basic evergreen support to the native driver. Fixes NODE-885 --- .evergreen/_config.template.yml | 157 +++++++ .evergreen/config.yml | 590 +++++++++++++++++++++++++ .evergreen/generate_evergreen_tasks.js | 204 +++++++++ .evergreen/install-dependencies.sh | 32 ++ .evergreen/run-tests.sh | 36 ++ package.json | 5 +- test/environments.js | 7 +- 7 files changed, 1028 insertions(+), 3 deletions(-) create mode 100644 .evergreen/_config.template.yml create mode 100644 .evergreen/config.yml create mode 100644 .evergreen/generate_evergreen_tasks.js create mode 100644 .evergreen/install-dependencies.sh create mode 100755 .evergreen/run-tests.sh diff --git a/.evergreen/_config.template.yml b/.evergreen/_config.template.yml new file mode 100644 index 0000000000..93b8ff96ba --- /dev/null +++ b/.evergreen/_config.template.yml @@ -0,0 +1,157 @@ +# 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)" + 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 + + "run tests": + - command: shell.exec + type: test + params: + working_dir: "src" + script: | + ${PREPARE_SHELL} + MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} 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} + NODE_LTS_NAME=${NODE_LTS_NAME} sh ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh + + "run atlas tests": + - command: shell.exec + params: + working_dir: "src" + silent: true + script: | + # DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does) + NODE_LTS_NAME='${NODE_LTS_NAME}' ATLAS_REPL='${atlas_repl}' ATLAS_SHRD='${atlas_shrd}' ATLAS_FREE='${atlas_free}' ATLAS_TLS11='${atlas_tls11}' ATLAS_TLS12='${atlas_tls12}' sh ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh + +pre: + - func: "fetch source" + - func: "prepare resources" + # - func: "windows fix" + - func: "fix absolute paths" + - func: "make files executable" + - func: "install dependencies" + +post: + - func: "cleanup" diff --git a/.evergreen/config.yml b/.evergreen/config.yml new file mode 100644 index 0000000000..6a32dfcd7d --- /dev/null +++ b/.evergreen/config.yml @@ -0,0 +1,590 @@ +stepback: true +command_type: system +exec_timeout_secs: 1800 +timeout: + - command: shell.exec + params: + script: | + ls -la +functions: + fetch source: + - command: git.get_project + params: + directory: src + - command: git.apply_patch + - 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)" + 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 + - 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 + run tests: + - command: shell.exec + type: test + params: + working_dir: src + script: > + ${PREPARE_SHELL} + + MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} 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 + 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} + + NODE_LTS_NAME=${NODE_LTS_NAME} sh + ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh + run atlas tests: + - command: shell.exec + params: + working_dir: src + silent: true + script: > + # DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does) + + NODE_LTS_NAME='${NODE_LTS_NAME}' ATLAS_REPL='${atlas_repl}' + ATLAS_SHRD='${atlas_shrd}' ATLAS_FREE='${atlas_free}' + ATLAS_TLS11='${atlas_tls11}' ATLAS_TLS12='${atlas_tls12}' sh + ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh +pre: + - func: fetch source + - func: prepare resources + - func: fix absolute paths + - func: make files executable + - func: install dependencies +post: + - func: cleanup +tasks: + - name: test-latest-server + tags: + - latest + - server + commands: + - func: run tests + vars: + VERSION: latest + TOPOLOGY: server + - name: test-latest-replica_set + tags: + - latest + - replica_set + commands: + - func: run tests + vars: + VERSION: latest + TOPOLOGY: replica_set + - name: test-latest-sharded_cluster + tags: + - latest + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: latest + TOPOLOGY: sharded_cluster + - name: test-4.0-server + tags: + - '4.0' + - server + commands: + - func: run tests + vars: + VERSION: '4.0' + TOPOLOGY: server + - name: test-4.0-replica_set + tags: + - '4.0' + - replica_set + commands: + - func: run tests + vars: + VERSION: '4.0' + TOPOLOGY: replica_set + - name: test-4.0-sharded_cluster + tags: + - '4.0' + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: '4.0' + TOPOLOGY: sharded_cluster + - name: test-3.6-server + tags: + - '3.6' + - server + commands: + - func: run tests + vars: + VERSION: '3.6' + TOPOLOGY: server + - name: test-3.6-replica_set + tags: + - '3.6' + - replica_set + commands: + - func: run tests + vars: + VERSION: '3.6' + TOPOLOGY: replica_set + - name: test-3.6-sharded_cluster + tags: + - '3.6' + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: '3.6' + TOPOLOGY: sharded_cluster + - name: test-3.4-server + tags: + - '3.4' + - server + commands: + - func: run tests + vars: + VERSION: '3.4' + TOPOLOGY: server + - name: test-3.4-replica_set + tags: + - '3.4' + - replica_set + commands: + - func: run tests + vars: + VERSION: '3.4' + TOPOLOGY: replica_set + - name: test-3.4-sharded_cluster + tags: + - '3.4' + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: '3.4' + TOPOLOGY: sharded_cluster + - name: test-3.2-server + tags: + - '3.2' + - server + commands: + - func: run tests + vars: + VERSION: '3.2' + TOPOLOGY: server + - name: test-3.2-replica_set + tags: + - '3.2' + - replica_set + commands: + - func: run tests + vars: + VERSION: '3.2' + TOPOLOGY: replica_set + - name: test-3.2-sharded_cluster + tags: + - '3.2' + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: '3.2' + TOPOLOGY: sharded_cluster + - name: test-3.0-server + tags: + - '3.0' + - server + commands: + - func: run tests + vars: + VERSION: '3.0' + TOPOLOGY: server + - name: test-3.0-replica_set + tags: + - '3.0' + - replica_set + commands: + - func: run tests + vars: + VERSION: '3.0' + TOPOLOGY: replica_set + - name: test-3.0-sharded_cluster + tags: + - '3.0' + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: '3.0' + TOPOLOGY: sharded_cluster + - name: test-2.6-server + tags: + - '2.6' + - server + commands: + - func: run tests + vars: + VERSION: '2.6' + TOPOLOGY: server + - name: test-2.6-replica_set + tags: + - '2.6' + - replica_set + commands: + - func: run tests + vars: + VERSION: '2.6' + TOPOLOGY: replica_set + - name: test-2.6-sharded_cluster + tags: + - '2.6' + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: '2.6' + TOPOLOGY: sharded_cluster +buildvariants: + - name: linux-64-amzn-test-carbon + display_name: Amazon Linux (Enterprise) Node Carbon + run_on: linux-64-amzn-test + expansions: + NODE_LTS_NAME: carbon + tasks: &ref_0 + - test-latest-server + - test-latest-replica_set + - test-latest-sharded_cluster + - test-4.0-server + - test-4.0-replica_set + - test-4.0-sharded_cluster + - test-3.6-server + - test-3.6-replica_set + - test-3.6-sharded_cluster + - test-3.4-server + - test-3.4-replica_set + - test-3.4-sharded_cluster + - test-3.2-server + - test-3.2-replica_set + - test-3.2-sharded_cluster + - test-3.0-server + - test-3.0-replica_set + - test-3.0-sharded_cluster + - test-2.6-server + - test-2.6-replica_set + - test-2.6-sharded_cluster + - name: linux-64-amzn-test-boron + display_name: Amazon Linux (Enterprise) Node Boron + run_on: linux-64-amzn-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_0 + - name: linux-64-amzn-test-argon + display_name: Amazon Linux (Enterprise) Node Argon + run_on: linux-64-amzn-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_0 + - name: ubuntu-14.04-carbon + display_name: Ubuntu 14.04 Node Carbon + run_on: ubuntu1404-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_0 + - name: ubuntu-14.04-boron + display_name: Ubuntu 14.04 Node Boron + run_on: ubuntu1404-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_0 + - name: ubuntu-14.04-argon + display_name: Ubuntu 14.04 Node Argon + run_on: ubuntu1404-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_0 + - name: rhel70-carbon + display_name: RHEL 7.0 Node Carbon + run_on: rhel70-small + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_0 + - name: rhel70-boron + display_name: RHEL 7.0 Node Boron + run_on: rhel70-small + expansions: + NODE_LTS_NAME: boron + tasks: *ref_0 + - name: rhel70-argon + display_name: RHEL 7.0 Node Argon + run_on: rhel70-small + expansions: + NODE_LTS_NAME: argon + tasks: *ref_0 + - name: debian71-test-carbon + display_name: Debian 7.1 Node Carbon + run_on: debian71-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_0 + - name: debian71-test-boron + display_name: Debian 7.1 Node Boron + run_on: debian71-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_0 + - name: debian71-test-argon + display_name: Debian 7.1 Node Argon + run_on: debian71-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_0 + - name: archlinux-test-carbon + display_name: Archlinux Node Carbon + run_on: archlinux-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_0 + - name: archlinux-test-boron + display_name: Archlinux Node Boron + run_on: archlinux-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_0 + - name: archlinux-test-argon + display_name: Archlinux Node Argon + run_on: archlinux-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_0 + - name: macos-1012-carbon + display_name: macOS 10.12 Node Carbon + run_on: macos-1012 + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_0 + - name: macos-1012-boron + display_name: macOS 10.12 Node Boron + run_on: macos-1012 + expansions: + NODE_LTS_NAME: boron + tasks: *ref_0 + - name: macos-1012-argon + display_name: macOS 10.12 Node Argon + run_on: macos-1012 + expansions: + NODE_LTS_NAME: argon + tasks: *ref_0 + - name: ubuntu-16.04-carbon + display_name: Ubuntu 16.04 Node Carbon + run_on: ubuntu1604-test + expansions: + NODE_LTS_NAME: carbon + tasks: &ref_1 + - test-latest-server + - test-latest-replica_set + - test-latest-sharded_cluster + - test-4.0-server + - test-4.0-replica_set + - test-4.0-sharded_cluster + - test-3.6-server + - test-3.6-replica_set + - test-3.6-sharded_cluster + - test-3.4-server + - test-3.4-replica_set + - test-3.4-sharded_cluster + - test-3.2-server + - test-3.2-replica_set + - test-3.2-sharded_cluster + - name: ubuntu-16.04-boron + display_name: Ubuntu 16.04 Node Boron + run_on: ubuntu1604-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_1 + - name: ubuntu-16.04-argon + display_name: Ubuntu 16.04 Node Argon + run_on: ubuntu1604-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_1 + - name: suse12-x86-64-test-carbon + display_name: SUSE 12 (x86_64) Node Carbon + run_on: suse12-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_1 + - name: suse12-x86-64-test-boron + display_name: SUSE 12 (x86_64) Node Boron + run_on: suse12-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_1 + - name: suse12-x86-64-test-argon + display_name: SUSE 12 (x86_64) Node Argon + run_on: suse12-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_1 + - name: rhel71-power8-test-carbon + display_name: RHEL 7.1 (POWER8) Node Carbon + run_on: rhel71-power8-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_1 + - name: rhel71-power8-test-boron + display_name: RHEL 7.1 (POWER8) Node Boron + run_on: rhel71-power8-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_1 + - name: rhel71-power8-test-argon + display_name: RHEL 7.1 (POWER8) Node Argon + run_on: rhel71-power8-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_1 + - name: debian81-test-carbon + display_name: Debian 8.1 Node Carbon + run_on: debian81-test + expansions: + NODE_LTS_NAME: carbon + tasks: &ref_2 + - test-latest-server + - test-latest-replica_set + - test-latest-sharded_cluster + - test-4.0-server + - test-4.0-replica_set + - test-4.0-sharded_cluster + - test-3.6-server + - test-3.6-replica_set + - test-3.6-sharded_cluster + - test-3.4-server + - test-3.4-replica_set + - test-3.4-sharded_cluster + - name: debian81-test-boron + display_name: Debian 8.1 Node Boron + run_on: debian81-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_2 + - name: suse12-zseries-test-carbon + display_name: SUSE 12 (zSeries) Node Carbon + run_on: suse12-zseries-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_2 + - name: suse12-zseries-test-boron + display_name: SUSE 12 (zSeries) Node Boron + run_on: suse12-zseries-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_2 + - name: ubuntu1604-arm64-small-carbon + display_name: Ubuntu 16.04 (ARM64) Node Carbon + run_on: ubuntu1604-arm64-small + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_2 + - name: ubuntu1604-arm64-small-boron + display_name: Ubuntu 16.04 (ARM64) Node Boron + run_on: ubuntu1604-arm64-small + expansions: + NODE_LTS_NAME: boron + tasks: *ref_2 + - name: ubuntu1604-power8-test-carbon + display_name: Ubuntu 16.04 (POWER8) Node Carbon + run_on: ubuntu1604-power8-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_2 + - name: ubuntu1604-power8-test-boron + display_name: Ubuntu 16.04 (POWER8) Node Boron + run_on: ubuntu1604-power8-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_2 + - name: ubuntu1604-zseries-small-carbon + display_name: Ubuntu 16.04 (zSeries) Node Carbon + run_on: ubuntu1604-zseries-small + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_2 + - name: ubuntu1604-zseries-small-boron + display_name: Ubuntu 16.04 (zSeries) Node Boron + run_on: ubuntu1604-zseries-small + expansions: + NODE_LTS_NAME: boron + tasks: *ref_2 diff --git a/.evergreen/generate_evergreen_tasks.js b/.evergreen/generate_evergreen_tasks.js new file mode 100644 index 0000000000..3b43e4f9b2 --- /dev/null +++ b/.evergreen/generate_evergreen_tasks.js @@ -0,0 +1,204 @@ +'use strict'; + +const semver = require('semver'); +const fs = require('fs'); +const yaml = require('js-yaml'); + +const MONGODB_VERSIONS = ['latest', '4.0', '3.6', '3.4', '3.2', '3.0', '2.6']; +const NODE_VERSIONS = ['carbon', 'boron', 'argon']; +const TOPOLOGIES = ['server', 'replica_set', 'sharded_cluster']; +const OPERATING_SYSTEMS = [ + { + name: 'linux-64-amzn-test', + display_name: 'Amazon Linux (Enterprise)', + run_on: 'linux-64-amzn-test' + }, + { + name: 'ubuntu-14.04', + display_name: 'Ubuntu 14.04', + run_on: 'ubuntu1404-test' + }, + { + name: 'rhel70', + display_name: 'RHEL 7.0', + run_on: 'rhel70-small' + }, + { + name: 'debian71-test', + display_name: 'Debian 7.1', + run_on: 'debian71-test' + }, + + // OSes that support versions of MongoDB without SSL. + { + name: 'archlinux-test', + display_name: 'Archlinux', + run_on: 'archlinux-test', + auth: false + }, + { + name: 'macos-1012', + display_name: 'macOS 10.12', + run_on: 'macos-1012', + auth: false + }, + + // >= 3.2 + { + name: 'ubuntu-16.04', + display_name: 'Ubuntu 16.04', + run_on: 'ubuntu1604-test', + mongoVersion: '>=3.2' + }, + { + name: 'suse12-x86-64-test', + display_name: 'SUSE 12 (x86_64)', + run_on: 'suse12-test', + mongoVersion: '>=3.2' + }, + { + name: 'rhel71-power8-test', + display_name: 'RHEL 7.1 (POWER8)', + run_on: 'rhel71-power8-test', + mongoVersion: '>=3.2' + }, + + // >= 3.4 + { + name: 'debian81-test', + display_name: 'Debian 8.1', + run_on: 'debian81-test', + mongoVersion: '>=3.4', + nodeVersion: 'boron' + }, + // reenable when these are actually running 7.2, or we release a 7.4 rpm + // { + // name: 'rhel72-zseries-test', + // display_name: 'RHEL 7.2 (zSeries)', + // run_on: 'rhel72-zseries-test', + // mongoVersion: '>=3.4', + // nodeVersion: 'boron' + // }, + { + name: 'suse12-zseries-test', + display_name: 'SUSE 12 (zSeries)', + run_on: 'suse12-zseries-test', + mongoVersion: '>=3.4', + nodeVersion: 'boron' + }, + { + name: 'ubuntu1604-arm64-small', + display_name: 'Ubuntu 16.04 (ARM64)', + run_on: 'ubuntu1604-arm64-small', + mongoVersion: '>=3.4', + nodeVersion: 'boron' + }, + { + name: 'ubuntu1604-power8-test', + display_name: 'Ubuntu 16.04 (POWER8)', + run_on: 'ubuntu1604-power8-test', + mongoVersion: '>=3.4', + nodeVersion: 'boron' + }, + { + name: 'ubuntu1604-zseries-small', + display_name: 'Ubuntu 16.04 (zSeries)', + run_on: 'ubuntu1604-zseries-small', + mongoVersion: '>=3.4', + nodeVersion: 'boron' + }, + + // 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({ + mongoVersion: '>=2.6', + nodeVersion: 'argon', + auth: false + }, osConfig) +); + +const TASKS = []; + +function makeTask({ mongoVersion, topology }) { + return { + name: `test-${mongoVersion}-${topology}`, + tags: [mongoVersion, topology], + commands: [ + { + func: 'run tests', + vars: { + VERSION: mongoVersion, + TOPOLOGY: topology + } + } + ] + }; +} + +MONGODB_VERSIONS.forEach(mongoVersion => { + TOPOLOGIES.forEach(topology => { + TASKS.push(makeTask({ mongoVersion, topology })); + }); +}); + +const BUILD_VARIANTS = []; + +const getTaskList = (() => { + const memo = {}; + return function(mongoVersion) { + const key = mongoVersion; + + if (memo[key]) { + return memo[key]; + } + + const ret = TASKS.filter(task => { + const { VERSION } = task.commands[0].vars; + + if (VERSION === 'latest') { + return true; + } + + return semver.satisfies(semver.coerce(VERSION), mongoVersion); + }).map(x => x.name); + + memo[key] = ret; + return ret; + } +})(); + +OPERATING_SYSTEMS.forEach( + ({ name: osName, display_name: osDisplayName, run_on, mongoVersion = '>=2.6', nodeVersion = 'argon' }) => { + const nodeVersions = NODE_VERSIONS.filter(nv => nv >= nodeVersion); + const tasks = getTaskList(mongoVersion); + + nodeVersions.forEach(NODE_LTS_NAME => { + const nodeLtsDisplayName = `Node ${NODE_LTS_NAME[0].toUpperCase()}${NODE_LTS_NAME.substr(1)}`; + const name = `${osName}-${NODE_LTS_NAME}`; + const display_name = `${osDisplayName} ${nodeLtsDisplayName}`; + const expansions = { NODE_LTS_NAME }; + BUILD_VARIANTS.push({ name, display_name, run_on, expansions, tasks }); + }); + } +); + +const fileData = yaml.safeLoad(fs.readFileSync(`${__dirname}/_config.template.yml`, 'utf8')) + +fileData.tasks = (fileData.tasks || []).concat(TASKS); +fileData.buildvariants = (fileData.buildvariants || []).concat(BUILD_VARIANTS); + +fs.writeFileSync(`${__dirname}/config.yml`, yaml.safeDump(fileData), 'utf8'); diff --git a/.evergreen/install-dependencies.sh b/.evergreen/install-dependencies.sh new file mode 100644 index 0000000000..5ea5f7226d --- /dev/null +++ b/.evergreen/install-dependencies.sh @@ -0,0 +1,32 @@ +#!/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 + +NODE_LTS_NAME=${NODE_LTS_NAME:-carbon} +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" + +# 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 +[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" +nvm install --lts=${NODE_LTS_NAME} + +# 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} +EOT + +# install node dependencies +npm install diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh new file mode 100755 index 0000000000..713f54b815 --- /dev/null +++ b/.evergreen/run-tests.sh @@ -0,0 +1,36 @@ +#!/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:-} +DRIVERS_TOOLS=${DRIVERS_TOOLS:-} +MONGODB_VERSION=${MONGODB_VERSION:-} + +# 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" + +# run tests +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" +MONGODB_VERSION=${MONGODB_VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test -- --local diff --git a/package.json b/package.json index 3487655558..41a6f0cc92 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "mongodb-mock-server": "^1.0.0", "mongodb-test-runner": "^1.1.18", "prettier": "~1.12.0", - "semver": "5.4.1", + "semver": "^5.5.0", "sinon": "^4.3.0", "sinon-chai": "^3.2.0", "worker-farm": "^1.5.0" @@ -51,7 +51,8 @@ "lint": "eslint lib test", "format": "prettier --print-width 100 --tab-width 2 --single-quote --write 'test/**/*.js' 'lib/**/*.js'", "changelog": "conventional-changelog -p angular -i HISTORY.md -s", - "bench": "node test/driverBench/" + "bench": "node test/driverBench/", + "generate-evergreen": "node .evergreen/generate_evergreen_tasks.js" }, "homepage": "https://github.com/mongodb/node-mongodb-native" } diff --git a/test/environments.js b/test/environments.js index 34985aae84..f68648f8ef 100644 --- a/test/environments.js +++ b/test/environments.js @@ -269,5 +269,10 @@ module.exports = { // informational aliases kerberos: SingleEnvironment, ldap: SingleEnvironment, - sni: SingleEnvironment + sni: SingleEnvironment, + + // for compatability with evergreen template + server: SingleEnvironment, + replica_set: ReplicaSetEnvironment, + sharded_cluster: ShardedEnvironment };