Skip to content

Commit a0d84f6

Browse files
committedJul 26, 2018
test(evergreen): adding evergreen config to native driver
Adds very basic evergreen support to the native driver. Fixes NODE-885
1 parent b8471f1 commit a0d84f6

7 files changed

+1028
-3
lines changed
 

‎.evergreen/_config.template.yml

+157
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# When a task that used to pass starts to fail
2+
# Go through all versions that may have been skipped to detect
3+
# when the task started failing
4+
stepback: true
5+
6+
# Mark a failure as a system/bootstrap failure (purple box) rather then a task
7+
# failure by default.
8+
# Actual testing tasks are marked with `type: test`
9+
command_type: system
10+
11+
# Protect ourself against rogue test case, or curl gone wild, that runs forever
12+
# Good rule of thumb: the averageish length a task takes, times 5
13+
# That roughly accounts for variable system performance for various buildvariants
14+
exec_timeout_secs: 1800 # 6 minutes is the longest we'll ever run
15+
16+
# What to do when evergreen hits the timeout (`post:` tasks are run automatically)
17+
timeout:
18+
- command: shell.exec
19+
params:
20+
script: |
21+
ls -la
22+
23+
functions:
24+
"fetch source":
25+
# Executes git clone and applies the submitted patch, if any
26+
- command: git.get_project
27+
params:
28+
directory: "src"
29+
# Applies the submitted patch, if any
30+
# Deprecated. Should be removed. But still needed for certain agents (ZAP)
31+
- command: git.apply_patch
32+
# Make an evergreen exapanstion file with dynamic values
33+
- command: shell.exec
34+
params:
35+
working_dir: "src"
36+
script: |
37+
# Get the current unique version of this checkout
38+
if [ "${is_patch}" = "true" ]; then
39+
CURRENT_VERSION=$(git describe)-patch-${version_id}
40+
else
41+
CURRENT_VERSION=latest
42+
fi
43+
44+
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
45+
export PROJECT_DIRECTORY="$(pwd)"
46+
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
47+
export UPLOAD_BUCKET="${project}"
48+
49+
cat <<EOT > expansion.yml
50+
CURRENT_VERSION: "$CURRENT_VERSION"
51+
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
52+
MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
53+
MONGODB_BINARIES: "$MONGODB_BINARIES"
54+
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
55+
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
56+
PREPARE_SHELL: |
57+
set -o errexit
58+
set -o xtrace
59+
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
60+
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
61+
export MONGODB_BINARIES="$MONGODB_BINARIES"
62+
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
63+
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
64+
65+
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
66+
export PATH="$MONGODB_BINARIES:$PATH"
67+
export PROJECT="${project}"
68+
EOT
69+
# See what we've done
70+
cat expansion.yml
71+
72+
# Load the expansion file to make an evergreen variable with the current unique version
73+
- command: expansions.update
74+
params:
75+
file: src/expansion.yml
76+
77+
"prepare resources":
78+
- command: shell.exec
79+
params:
80+
script: |
81+
${PREPARE_SHELL}
82+
rm -rf $DRIVERS_TOOLS
83+
git clone git://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
84+
85+
"run tests":
86+
- command: shell.exec
87+
type: test
88+
params:
89+
working_dir: "src"
90+
script: |
91+
${PREPARE_SHELL}
92+
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} SSL=${SSL} MONGODB_URI="${MONGODB_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
93+
94+
"cleanup":
95+
- command: shell.exec
96+
params:
97+
script: |
98+
${PREPARE_SHELL}
99+
rm -rf $DRIVERS_TOOLS || true
100+
101+
"fix absolute paths":
102+
- command: shell.exec
103+
params:
104+
script: |
105+
${PREPARE_SHELL}
106+
for filename in $(find ${DRIVERS_TOOLS} -name \*.json); do
107+
perl -p -i -e "s|ABSOLUTE_PATH_REPLACEMENT_TOKEN|${DRIVERS_TOOLS}|g" $filename
108+
done
109+
110+
# "windows fix":
111+
# - command: shell.exec
112+
# params:
113+
# script: |
114+
# ${PREPARE_SHELL}
115+
# for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do
116+
# cat $i | tr -d '\r' > $i.new
117+
# mv $i.new $i
118+
# done
119+
# # Copy client certificate because symlinks do not work on Windows.
120+
# cp ${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem ${MONGO_ORCHESTRATION_HOME}/lib/client.pem
121+
122+
"make files executable":
123+
- command: shell.exec
124+
params:
125+
script: |
126+
${PREPARE_SHELL}
127+
for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do
128+
chmod +x $i
129+
done
130+
131+
"install dependencies":
132+
- command: shell.exec
133+
params:
134+
working_dir: "src"
135+
script: |
136+
${PREPARE_SHELL}
137+
NODE_LTS_NAME=${NODE_LTS_NAME} sh ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh
138+
139+
"run atlas tests":
140+
- command: shell.exec
141+
params:
142+
working_dir: "src"
143+
silent: true
144+
script: |
145+
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
146+
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
147+
148+
pre:
149+
- func: "fetch source"
150+
- func: "prepare resources"
151+
# - func: "windows fix"
152+
- func: "fix absolute paths"
153+
- func: "make files executable"
154+
- func: "install dependencies"
155+
156+
post:
157+
- func: "cleanup"

‎.evergreen/config.yml

+590
Large diffs are not rendered by default.
+204
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
'use strict';
2+
3+
const semver = require('semver');
4+
const fs = require('fs');
5+
const yaml = require('js-yaml');
6+
7+
const MONGODB_VERSIONS = ['latest', '4.0', '3.6', '3.4', '3.2', '3.0', '2.6'];
8+
const NODE_VERSIONS = ['carbon', 'boron', 'argon'];
9+
const TOPOLOGIES = ['server', 'replica_set', 'sharded_cluster'];
10+
const OPERATING_SYSTEMS = [
11+
{
12+
name: 'linux-64-amzn-test',
13+
display_name: 'Amazon Linux (Enterprise)',
14+
run_on: 'linux-64-amzn-test'
15+
},
16+
{
17+
name: 'ubuntu-14.04',
18+
display_name: 'Ubuntu 14.04',
19+
run_on: 'ubuntu1404-test'
20+
},
21+
{
22+
name: 'rhel70',
23+
display_name: 'RHEL 7.0',
24+
run_on: 'rhel70-small'
25+
},
26+
{
27+
name: 'debian71-test',
28+
display_name: 'Debian 7.1',
29+
run_on: 'debian71-test'
30+
},
31+
32+
// OSes that support versions of MongoDB without SSL.
33+
{
34+
name: 'archlinux-test',
35+
display_name: 'Archlinux',
36+
run_on: 'archlinux-test',
37+
auth: false
38+
},
39+
{
40+
name: 'macos-1012',
41+
display_name: 'macOS 10.12',
42+
run_on: 'macos-1012',
43+
auth: false
44+
},
45+
46+
// >= 3.2
47+
{
48+
name: 'ubuntu-16.04',
49+
display_name: 'Ubuntu 16.04',
50+
run_on: 'ubuntu1604-test',
51+
mongoVersion: '>=3.2'
52+
},
53+
{
54+
name: 'suse12-x86-64-test',
55+
display_name: 'SUSE 12 (x86_64)',
56+
run_on: 'suse12-test',
57+
mongoVersion: '>=3.2'
58+
},
59+
{
60+
name: 'rhel71-power8-test',
61+
display_name: 'RHEL 7.1 (POWER8)',
62+
run_on: 'rhel71-power8-test',
63+
mongoVersion: '>=3.2'
64+
},
65+
66+
// >= 3.4
67+
{
68+
name: 'debian81-test',
69+
display_name: 'Debian 8.1',
70+
run_on: 'debian81-test',
71+
mongoVersion: '>=3.4',
72+
nodeVersion: 'boron'
73+
},
74+
// reenable when these are actually running 7.2, or we release a 7.4 rpm
75+
// {
76+
// name: 'rhel72-zseries-test',
77+
// display_name: 'RHEL 7.2 (zSeries)',
78+
// run_on: 'rhel72-zseries-test',
79+
// mongoVersion: '>=3.4',
80+
// nodeVersion: 'boron'
81+
// },
82+
{
83+
name: 'suse12-zseries-test',
84+
display_name: 'SUSE 12 (zSeries)',
85+
run_on: 'suse12-zseries-test',
86+
mongoVersion: '>=3.4',
87+
nodeVersion: 'boron'
88+
},
89+
{
90+
name: 'ubuntu1604-arm64-small',
91+
display_name: 'Ubuntu 16.04 (ARM64)',
92+
run_on: 'ubuntu1604-arm64-small',
93+
mongoVersion: '>=3.4',
94+
nodeVersion: 'boron'
95+
},
96+
{
97+
name: 'ubuntu1604-power8-test',
98+
display_name: 'Ubuntu 16.04 (POWER8)',
99+
run_on: 'ubuntu1604-power8-test',
100+
mongoVersion: '>=3.4',
101+
nodeVersion: 'boron'
102+
},
103+
{
104+
name: 'ubuntu1604-zseries-small',
105+
display_name: 'Ubuntu 16.04 (zSeries)',
106+
run_on: 'ubuntu1604-zseries-small',
107+
mongoVersion: '>=3.4',
108+
nodeVersion: 'boron'
109+
},
110+
111+
// Windows. reenable this when nvm supports windows, or we settle on an alternative tool
112+
// {
113+
// name: 'windows-64-vs2010-test',
114+
// display_name: 'Windows (VS2010)',
115+
// run_on: 'windows-64-vs2010-test'
116+
// },
117+
// {
118+
// name: 'windows-64-vs2013-test',
119+
// display_name: 'Windows (VS2013)',
120+
// run_on: 'windows-64-vs2013-test'
121+
// },
122+
// {
123+
// name: 'windows-64-vs2015-test',
124+
// display_name: 'Windows (VS2015)',
125+
// run_on: 'windows-64-vs2015-test'
126+
// }
127+
].map(osConfig => Object.assign({
128+
mongoVersion: '>=2.6',
129+
nodeVersion: 'argon',
130+
auth: false
131+
}, osConfig)
132+
);
133+
134+
const TASKS = [];
135+
136+
function makeTask({ mongoVersion, topology }) {
137+
return {
138+
name: `test-${mongoVersion}-${topology}`,
139+
tags: [mongoVersion, topology],
140+
commands: [
141+
{
142+
func: 'run tests',
143+
vars: {
144+
VERSION: mongoVersion,
145+
TOPOLOGY: topology
146+
}
147+
}
148+
]
149+
};
150+
}
151+
152+
MONGODB_VERSIONS.forEach(mongoVersion => {
153+
TOPOLOGIES.forEach(topology => {
154+
TASKS.push(makeTask({ mongoVersion, topology }));
155+
});
156+
});
157+
158+
const BUILD_VARIANTS = [];
159+
160+
const getTaskList = (() => {
161+
const memo = {};
162+
return function(mongoVersion) {
163+
const key = mongoVersion;
164+
165+
if (memo[key]) {
166+
return memo[key];
167+
}
168+
169+
const ret = TASKS.filter(task => {
170+
const { VERSION } = task.commands[0].vars;
171+
172+
if (VERSION === 'latest') {
173+
return true;
174+
}
175+
176+
return semver.satisfies(semver.coerce(VERSION), mongoVersion);
177+
}).map(x => x.name);
178+
179+
memo[key] = ret;
180+
return ret;
181+
}
182+
})();
183+
184+
OPERATING_SYSTEMS.forEach(
185+
({ name: osName, display_name: osDisplayName, run_on, mongoVersion = '>=2.6', nodeVersion = 'argon' }) => {
186+
const nodeVersions = NODE_VERSIONS.filter(nv => nv >= nodeVersion);
187+
const tasks = getTaskList(mongoVersion);
188+
189+
nodeVersions.forEach(NODE_LTS_NAME => {
190+
const nodeLtsDisplayName = `Node ${NODE_LTS_NAME[0].toUpperCase()}${NODE_LTS_NAME.substr(1)}`;
191+
const name = `${osName}-${NODE_LTS_NAME}`;
192+
const display_name = `${osDisplayName} ${nodeLtsDisplayName}`;
193+
const expansions = { NODE_LTS_NAME };
194+
BUILD_VARIANTS.push({ name, display_name, run_on, expansions, tasks });
195+
});
196+
}
197+
);
198+
199+
const fileData = yaml.safeLoad(fs.readFileSync(`${__dirname}/_config.template.yml`, 'utf8'))
200+
201+
fileData.tasks = (fileData.tasks || []).concat(TASKS);
202+
fileData.buildvariants = (fileData.buildvariants || []).concat(BUILD_VARIANTS);
203+
204+
fs.writeFileSync(`${__dirname}/config.yml`, yaml.safeDump(fileData), 'utf8');

‎.evergreen/install-dependencies.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
# set -o xtrace # Write all commands first to stderr
3+
set -o errexit # Exit the script with error if any of the commands fail
4+
5+
NODE_LTS_NAME=${NODE_LTS_NAME:-carbon}
6+
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
7+
NPM_CACHE_DIR="${NODE_ARTIFACTS_PATH}/npm"
8+
NPM_TMP_DIR="${NODE_ARTIFATS_PATH}/tmp"
9+
10+
# this needs to be explicitly exported for the nvm install below
11+
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
12+
13+
# create node artifacts path if needed
14+
mkdir -p ${NODE_ARTIFACTS_PATH}
15+
mkdir -p ${NPM_CACHE_DIR}
16+
mkdir -p "${NPM_TMP_DIR}"
17+
18+
# install Node.js
19+
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
20+
[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh"
21+
nvm install --lts=${NODE_LTS_NAME}
22+
23+
# setup npm cache in a local directory
24+
cat <<EOT > .npmrc
25+
devdir=${NPM_CACHE_DIR}/.node-gyp
26+
init-module=${NPM_CACHE_DIR}/.npm-init.js
27+
cache=${NPM_CACHE_DIR}
28+
tmp=${NPM_TMP_DIR}
29+
EOT
30+
31+
# install node dependencies
32+
npm install

‎.evergreen/run-tests.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
# set -o xtrace # Write all commands first to stderr
3+
set -o errexit # Exit the script with error if any of the commands fail
4+
5+
# Supported/used environment variables:
6+
# AUTH Set to enable authentication. Defaults to "noauth"
7+
# SSL Set to enable SSL. Defaults to "nossl"
8+
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info)
9+
# MARCH Machine Architecture. Defaults to lowercase uname -m
10+
11+
AUTH=${AUTH:-noauth}
12+
SSL=${SSL:-nossl}
13+
MONGODB_URI=${MONGODB_URI:-}
14+
DRIVERS_TOOLS=${DRIVERS_TOOLS:-}
15+
MONGODB_VERSION=${MONGODB_VERSION:-}
16+
17+
# install MongoDB
18+
# Functions to fetch MongoDB binaries
19+
. ${DRIVERS_TOOLS}/.evergreen/download-mongodb.sh
20+
21+
get_distro
22+
if [ -z "$MONGODB_DOWNLOAD_URL" ]; then
23+
get_mongodb_download_url_for "$DISTRO" "$MONGODB_VERSION"
24+
fi
25+
# Even though we have the MONGODB_DOWNLOAD_URL, we still call this to get the proper EXTRACT variable
26+
get_mongodb_download_url_for "$DISTRO"
27+
download_and_extract "$MONGODB_DOWNLOAD_URL" "$EXTRACT"
28+
29+
# run tests
30+
echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI"
31+
32+
export PATH="/opt/mongodbtoolchain/v2/bin:$PATH"
33+
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
34+
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
35+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
36+
MONGODB_VERSION=${MONGODB_VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test -- --local

‎package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"mongodb-mock-server": "^1.0.0",
3333
"mongodb-test-runner": "^1.1.18",
3434
"prettier": "~1.12.0",
35-
"semver": "5.4.1",
35+
"semver": "^5.5.0",
3636
"sinon": "^4.3.0",
3737
"sinon-chai": "^3.2.0",
3838
"worker-farm": "^1.5.0"
@@ -51,7 +51,8 @@
5151
"lint": "eslint lib test",
5252
"format": "prettier --print-width 100 --tab-width 2 --single-quote --write 'test/**/*.js' 'lib/**/*.js'",
5353
"changelog": "conventional-changelog -p angular -i HISTORY.md -s",
54-
"bench": "node test/driverBench/"
54+
"bench": "node test/driverBench/",
55+
"generate-evergreen": "node .evergreen/generate_evergreen_tasks.js"
5556
},
5657
"homepage": "https://github.com/mongodb/node-mongodb-native"
5758
}

‎test/environments.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,10 @@ module.exports = {
269269
// informational aliases
270270
kerberos: SingleEnvironment,
271271
ldap: SingleEnvironment,
272-
sni: SingleEnvironment
272+
sni: SingleEnvironment,
273+
274+
// for compatability with evergreen template
275+
server: SingleEnvironment,
276+
replica_set: ReplicaSetEnvironment,
277+
sharded_cluster: ShardedEnvironment
273278
};

0 commit comments

Comments
 (0)
Please sign in to comment.