Skip to content

Commit

Permalink
chore(ci): add tls support test to evergreen
Browse files Browse the repository at this point in the history
  • Loading branch information
emadum committed Aug 6, 2020
1 parent edf429c commit 61a1d32
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 23 deletions.
47 changes: 38 additions & 9 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ functions:
bootstrap mongo-orchestration:
- command: shell.exec
params:
script: >
script: |
${PREPARE_SHELL}
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} ORCHESTRATION_FILE=${ORCHESTRATION_FILE} bash
${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} \
AUTH=${AUTH} SSL=${SSL} \
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
- command: expansions.update
params:
file: mo-expansion.yml
Expand All @@ -100,20 +101,18 @@ functions:
type: test
params:
working_dir: src
script: >
script: |
${PREPARE_SHELL}
if [ -n "${CLIENT_ENCRYPTION}" ]; then
# Disable xtrace (just in case it was accidentally set).
set +x
. ./prepare_client_encryption.sh
rm -f ./prepare_client_encryption.sh
fi
AUTH=${AUTH} SSL=${SSL} UNIFIED=${UNIFIED} MONGODB_URI="${MONGODB_URI}" bash
${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
AUTH=${AUTH} SSL=${SSL} UNIFIED=${UNIFIED} MONGODB_URI="${MONGODB_URI}" \
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
run checks:
- command: shell.exec
type: test
Expand Down Expand Up @@ -173,6 +172,23 @@ functions:
rm -f ./prepare_atlas_connectivity.sh
NODE_LTS_NAME='${NODE_LTS_NAME}' bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh
run ldap tests:
- command: shell.exec
type: test
params:
working_dir: src
script: |
MONGODB_URI='${plain_auth_mongodb_uri}' NODE_LTS_NAME='${NODE_LTS_NAME}' \
bash ${PROJECT_DIRECTORY}/.evergreen/run-ldap-tests.sh
run tls tests:
- command: shell.exec
type: test
params:
working_dir: src
script: |
NODE_LTS_NAME=${NODE_LTS_NAME} DRIVERS_TOOLS="${DRIVERS_TOOLS}" \
SSL_CA_FILE="${SSL_CA_FILE}" SSL_KEY_FILE="${SSL_KEY_FILE}" \
MONGODB_URI="${MONGODB_URI}" bash ${PROJECT_DIRECTORY}/.evergreen/run-tls-tests.sh
add aws auth variables to file:
- command: shell.exec
type: test
Expand Down Expand Up @@ -1049,6 +1065,17 @@ tasks:
commands:
- func: install dependencies
- func: run atlas tests
- name: test-tls-support
tags:
- tls-support
commands:
- func: install dependencies
- func: bootstrap mongo-orchestration
vars:
SSL: ssl
VERSION: latest
TOPOLOGY: server
- func: run tls tests
- name: test-latest-ocsp-valid-cert-server-staples
tags:
- ocsp
Expand Down Expand Up @@ -1343,6 +1370,7 @@ buildvariants:
- test-2.6-replica_set-unified
- test-2.6-sharded_cluster-unified
- test-atlas-connectivity
- test-tls-support
- test-latest-ocsp-valid-cert-server-staples
- test-latest-ocsp-invalid-cert-server-staples
- test-latest-ocsp-valid-cert-server-does-not-staple
Expand Down Expand Up @@ -1528,6 +1556,7 @@ buildvariants:
- test-3.2-replica_set-unified
- test-3.2-sharded_cluster-unified
- test-atlas-connectivity
- test-tls-support
- test-latest-ocsp-valid-cert-server-staples
- test-latest-ocsp-invalid-cert-server-staples
- test-latest-ocsp-valid-cert-server-does-not-staple
Expand Down
27 changes: 25 additions & 2 deletions .evergreen/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ functions:
params:
script: |
${PREPARE_SHELL}
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} ORCHESTRATION_FILE=${ORCHESTRATION_FILE} bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} \
AUTH=${AUTH} SSL=${SSL} \
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
- command: expansions.update
params:
Expand Down Expand Up @@ -128,7 +131,8 @@ functions:
rm -f ./prepare_client_encryption.sh
fi

AUTH=${AUTH} SSL=${SSL} UNIFIED=${UNIFIED} MONGODB_URI="${MONGODB_URI}" bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
AUTH=${AUTH} SSL=${SSL} UNIFIED=${UNIFIED} MONGODB_URI="${MONGODB_URI}" \
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh

"run checks":
- command: shell.exec
Expand Down Expand Up @@ -207,6 +211,25 @@ functions:

NODE_LTS_NAME='${NODE_LTS_NAME}' bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh

"run ldap tests":
- command: shell.exec
type: test
params:
working_dir: "src"
script: |
MONGODB_URI='${plain_auth_mongodb_uri}' NODE_LTS_NAME='${NODE_LTS_NAME}' \
bash ${PROJECT_DIRECTORY}/.evergreen/run-ldap-tests.sh

"run tls tests":
- command: shell.exec
type: test
params:
working_dir: "src"
script: |
NODE_LTS_NAME=${NODE_LTS_NAME} DRIVERS_TOOLS="${DRIVERS_TOOLS}" \
SSL_CA_FILE="${SSL_CA_FILE}" SSL_KEY_FILE="${SSL_KEY_FILE}" \
MONGODB_URI="${MONGODB_URI}" bash ${PROJECT_DIRECTORY}/.evergreen/run-tls-tests.sh

"add aws auth variables to file":
- command: shell.exec
type: test
Expand Down
40 changes: 29 additions & 11 deletions .evergreen/generate_evergreen_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,37 @@ function makeTask({ mongoVersion, topology }) {
}

MONGODB_VERSIONS.forEach(mongoVersion => {
TOPOLOGIES.forEach(topology => {
TASKS.push(makeTask({ mongoVersion, topology }));
});
TOPOLOGIES.forEach(topology =>
TASKS.push(makeTask({ mongoVersion, topology }))
);
});

TASKS.push({
name: 'test-atlas-connectivity',
tags: ['atlas-connect'],
commands: [
{ func: 'install dependencies' },
{ func: 'run atlas tests' }
]
});
TASKS.push(
{
name: 'test-atlas-connectivity',
tags: ['atlas-connect'],
commands: [
{ func: 'install dependencies' },
{ func: 'run atlas tests' }
]
},
{
name: 'test-tls-support',
tags: ['tls-support'],
commands: [
{ func: 'install dependencies' },
{
func: 'bootstrap mongo-orchestration',
vars: {
SSL: 'ssl',
VERSION: 'latest',
TOPOLOGY: 'server'
}
},
{ func: 'run tls tests' }
]
}
);

OCSP_VERSIONS.forEach(VERSION => {
// manually added tasks
Expand Down
8 changes: 7 additions & 1 deletion .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ set -o errexit # Exit the script with error if any of the commands fail
# MARCH Machine Architecture. Defaults to lowercase uname -m

AUTH=${AUTH:-noauth}
SSL=${SSL:-nossl}
UNIFIED=${UNIFIED:-}
MONGODB_URI=${MONGODB_URI:-}

# ssl setup
SSL=${SSL:-nossl}
if [ "$SSL" != "nossl" ]; then
export SSL_KEY_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem"
export SSL_CA_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem"
fi

# run tests
echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI"

Expand Down
12 changes: 12 additions & 0 deletions .evergreen/run-tls-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -o errexit # Exit the script with error if any of the commands fail

export PROJECT_DIRECTORY="$(pwd)"
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
export SSL_KEY_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem"
export SSL_CA_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem"

npm run check:tls
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
},
"scripts": {
"atlas": "mocha --opts '{}' ./test/manual/atlas_connectivity.test.js",
"check:tls": "mocha --opts '{}' test/manual/tls_support.test.js",
"test": "npm run lint && mocha --recursive test/functional test/unit test/core",
"test-nolint": "mocha --recursive test/functional test/unit test/core",
"coverage": "istanbul cover mongodb-test-runner -- -t 60000 test/core test/unit test/functional",
Expand Down
38 changes: 38 additions & 0 deletions test/manual/tls_support.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';
const MongoClient = require('../..').MongoClient;

const REQUIRED_ENV = ['MONGODB_URI', 'SSL_KEY_FILE', 'SSL_CA_FILE'];

describe('TLS Support', function() {
for (let key of REQUIRED_ENV) {
if (process.env[key] == null) {
throw new Error(`skipping SSL tests, ${key} environment variable is not defined`);
}
}

const connectionString = process.env.MONGODB_URI;
const tlsCertificateKeyFile = process.env.SSL_KEY_FILE;
const tlsCAFile = process.env.SSL_CA_FILE;

it(
'should connect with tls',
makeConnectionTest(connectionString, { tls: true, tlsCertificateKeyFile, tlsCAFile })
);
});

function makeConnectionTest(connectionString, clientOptions) {
return function() {
const client = new MongoClient(connectionString, clientOptions);

return client
.connect()
.then(() => client.db('admin').command({ ismaster: 1 }))
.then(() =>
client
.db('test')
.collection('test')
.findOne({})
)
.then(() => client.close());
};
}
1 change: 1 addition & 0 deletions test/spec/apm/updateOne.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
},
{
"description": "A successful update one command with write errors",
"ignore_if_server_version_greater_than": "4.5",
"operation": {
"name": "updateOne",
"arguments": {
Expand Down

0 comments on commit 61a1d32

Please sign in to comment.