Skip to content

Commit 61a1d32

Browse files
authored
chore(ci): add tls support test to evergreen
NODE-877
1 parent edf429c commit 61a1d32

8 files changed

+151
-23
lines changed

.evergreen/config.yml

+38-9
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@ functions:
7474
bootstrap mongo-orchestration:
7575
- command: shell.exec
7676
params:
77-
script: >
77+
script: |
7878
${PREPARE_SHELL}
79-
80-
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} ORCHESTRATION_FILE=${ORCHESTRATION_FILE} bash
81-
${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
79+
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} \
80+
AUTH=${AUTH} SSL=${SSL} \
81+
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
82+
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
8283
- command: expansions.update
8384
params:
8485
file: mo-expansion.yml
@@ -100,20 +101,18 @@ functions:
100101
type: test
101102
params:
102103
working_dir: src
103-
script: >
104+
script: |
104105
${PREPARE_SHELL}
105106
106-
107107
if [ -n "${CLIENT_ENCRYPTION}" ]; then
108108
# Disable xtrace (just in case it was accidentally set).
109109
set +x
110110
. ./prepare_client_encryption.sh
111111
rm -f ./prepare_client_encryption.sh
112112
fi
113113
114-
115-
AUTH=${AUTH} SSL=${SSL} UNIFIED=${UNIFIED} MONGODB_URI="${MONGODB_URI}" bash
116-
${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
114+
AUTH=${AUTH} SSL=${SSL} UNIFIED=${UNIFIED} MONGODB_URI="${MONGODB_URI}" \
115+
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
117116
run checks:
118117
- command: shell.exec
119118
type: test
@@ -173,6 +172,23 @@ functions:
173172
rm -f ./prepare_atlas_connectivity.sh
174173
175174
NODE_LTS_NAME='${NODE_LTS_NAME}' bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh
175+
run ldap tests:
176+
- command: shell.exec
177+
type: test
178+
params:
179+
working_dir: src
180+
script: |
181+
MONGODB_URI='${plain_auth_mongodb_uri}' NODE_LTS_NAME='${NODE_LTS_NAME}' \
182+
bash ${PROJECT_DIRECTORY}/.evergreen/run-ldap-tests.sh
183+
run tls tests:
184+
- command: shell.exec
185+
type: test
186+
params:
187+
working_dir: src
188+
script: |
189+
NODE_LTS_NAME=${NODE_LTS_NAME} DRIVERS_TOOLS="${DRIVERS_TOOLS}" \
190+
SSL_CA_FILE="${SSL_CA_FILE}" SSL_KEY_FILE="${SSL_KEY_FILE}" \
191+
MONGODB_URI="${MONGODB_URI}" bash ${PROJECT_DIRECTORY}/.evergreen/run-tls-tests.sh
176192
add aws auth variables to file:
177193
- command: shell.exec
178194
type: test
@@ -1049,6 +1065,17 @@ tasks:
10491065
commands:
10501066
- func: install dependencies
10511067
- func: run atlas tests
1068+
- name: test-tls-support
1069+
tags:
1070+
- tls-support
1071+
commands:
1072+
- func: install dependencies
1073+
- func: bootstrap mongo-orchestration
1074+
vars:
1075+
SSL: ssl
1076+
VERSION: latest
1077+
TOPOLOGY: server
1078+
- func: run tls tests
10521079
- name: test-latest-ocsp-valid-cert-server-staples
10531080
tags:
10541081
- ocsp
@@ -1343,6 +1370,7 @@ buildvariants:
13431370
- test-2.6-replica_set-unified
13441371
- test-2.6-sharded_cluster-unified
13451372
- test-atlas-connectivity
1373+
- test-tls-support
13461374
- test-latest-ocsp-valid-cert-server-staples
13471375
- test-latest-ocsp-invalid-cert-server-staples
13481376
- test-latest-ocsp-valid-cert-server-does-not-staple
@@ -1528,6 +1556,7 @@ buildvariants:
15281556
- test-3.2-replica_set-unified
15291557
- test-3.2-sharded_cluster-unified
15301558
- test-atlas-connectivity
1559+
- test-tls-support
15311560
- test-latest-ocsp-valid-cert-server-staples
15321561
- test-latest-ocsp-invalid-cert-server-staples
15331562
- test-latest-ocsp-valid-cert-server-does-not-staple

.evergreen/config.yml.in

+25-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ functions:
9494
params:
9595
script: |
9696
${PREPARE_SHELL}
97-
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} ORCHESTRATION_FILE=${ORCHESTRATION_FILE} bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
97+
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} \
98+
AUTH=${AUTH} SSL=${SSL} \
99+
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
100+
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
98101
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
99102
- command: expansions.update
100103
params:
@@ -128,7 +131,8 @@ functions:
128131
rm -f ./prepare_client_encryption.sh
129132
fi
130133

131-
AUTH=${AUTH} SSL=${SSL} UNIFIED=${UNIFIED} MONGODB_URI="${MONGODB_URI}" bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
134+
AUTH=${AUTH} SSL=${SSL} UNIFIED=${UNIFIED} MONGODB_URI="${MONGODB_URI}" \
135+
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
132136

133137
"run checks":
134138
- command: shell.exec
@@ -207,6 +211,25 @@ functions:
207211

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

214+
"run ldap tests":
215+
- command: shell.exec
216+
type: test
217+
params:
218+
working_dir: "src"
219+
script: |
220+
MONGODB_URI='${plain_auth_mongodb_uri}' NODE_LTS_NAME='${NODE_LTS_NAME}' \
221+
bash ${PROJECT_DIRECTORY}/.evergreen/run-ldap-tests.sh
222+
223+
"run tls tests":
224+
- command: shell.exec
225+
type: test
226+
params:
227+
working_dir: "src"
228+
script: |
229+
NODE_LTS_NAME=${NODE_LTS_NAME} DRIVERS_TOOLS="${DRIVERS_TOOLS}" \
230+
SSL_CA_FILE="${SSL_CA_FILE}" SSL_KEY_FILE="${SSL_KEY_FILE}" \
231+
MONGODB_URI="${MONGODB_URI}" bash ${PROJECT_DIRECTORY}/.evergreen/run-tls-tests.sh
232+
210233
"add aws auth variables to file":
211234
- command: shell.exec
212235
type: test

.evergreen/generate_evergreen_tasks.js

+29-11
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,37 @@ function makeTask({ mongoVersion, topology }) {
9797
}
9898

9999
MONGODB_VERSIONS.forEach(mongoVersion => {
100-
TOPOLOGIES.forEach(topology => {
101-
TASKS.push(makeTask({ mongoVersion, topology }));
102-
});
100+
TOPOLOGIES.forEach(topology =>
101+
TASKS.push(makeTask({ mongoVersion, topology }))
102+
);
103103
});
104104

105-
TASKS.push({
106-
name: 'test-atlas-connectivity',
107-
tags: ['atlas-connect'],
108-
commands: [
109-
{ func: 'install dependencies' },
110-
{ func: 'run atlas tests' }
111-
]
112-
});
105+
TASKS.push(
106+
{
107+
name: 'test-atlas-connectivity',
108+
tags: ['atlas-connect'],
109+
commands: [
110+
{ func: 'install dependencies' },
111+
{ func: 'run atlas tests' }
112+
]
113+
},
114+
{
115+
name: 'test-tls-support',
116+
tags: ['tls-support'],
117+
commands: [
118+
{ func: 'install dependencies' },
119+
{
120+
func: 'bootstrap mongo-orchestration',
121+
vars: {
122+
SSL: 'ssl',
123+
VERSION: 'latest',
124+
TOPOLOGY: 'server'
125+
}
126+
},
127+
{ func: 'run tls tests' }
128+
]
129+
}
130+
);
113131

114132
OCSP_VERSIONS.forEach(VERSION => {
115133
// manually added tasks

.evergreen/run-tests.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ set -o errexit # Exit the script with error if any of the commands fail
1010
# MARCH Machine Architecture. Defaults to lowercase uname -m
1111

1212
AUTH=${AUTH:-noauth}
13-
SSL=${SSL:-nossl}
1413
UNIFIED=${UNIFIED:-}
1514
MONGODB_URI=${MONGODB_URI:-}
1615

16+
# ssl setup
17+
SSL=${SSL:-nossl}
18+
if [ "$SSL" != "nossl" ]; then
19+
export SSL_KEY_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem"
20+
export SSL_CA_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem"
21+
fi
22+
1723
# run tests
1824
echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI"
1925

.evergreen/run-tls-tests.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -o errexit # Exit the script with error if any of the commands fail
4+
5+
export PROJECT_DIRECTORY="$(pwd)"
6+
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
7+
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
8+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
9+
export SSL_KEY_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem"
10+
export SSL_CA_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem"
11+
12+
npm run check:tls

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
},
6666
"scripts": {
6767
"atlas": "mocha --opts '{}' ./test/manual/atlas_connectivity.test.js",
68+
"check:tls": "mocha --opts '{}' test/manual/tls_support.test.js",
6869
"test": "npm run lint && mocha --recursive test/functional test/unit test/core",
6970
"test-nolint": "mocha --recursive test/functional test/unit test/core",
7071
"coverage": "istanbul cover mongodb-test-runner -- -t 60000 test/core test/unit test/functional",

test/manual/tls_support.test.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict';
2+
const MongoClient = require('../..').MongoClient;
3+
4+
const REQUIRED_ENV = ['MONGODB_URI', 'SSL_KEY_FILE', 'SSL_CA_FILE'];
5+
6+
describe('TLS Support', function() {
7+
for (let key of REQUIRED_ENV) {
8+
if (process.env[key] == null) {
9+
throw new Error(`skipping SSL tests, ${key} environment variable is not defined`);
10+
}
11+
}
12+
13+
const connectionString = process.env.MONGODB_URI;
14+
const tlsCertificateKeyFile = process.env.SSL_KEY_FILE;
15+
const tlsCAFile = process.env.SSL_CA_FILE;
16+
17+
it(
18+
'should connect with tls',
19+
makeConnectionTest(connectionString, { tls: true, tlsCertificateKeyFile, tlsCAFile })
20+
);
21+
});
22+
23+
function makeConnectionTest(connectionString, clientOptions) {
24+
return function() {
25+
const client = new MongoClient(connectionString, clientOptions);
26+
27+
return client
28+
.connect()
29+
.then(() => client.db('admin').command({ ismaster: 1 }))
30+
.then(() =>
31+
client
32+
.db('test')
33+
.collection('test')
34+
.findOne({})
35+
)
36+
.then(() => client.close());
37+
};
38+
}

test/spec/apm/updateOne.json

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
},
132132
{
133133
"description": "A successful update one command with write errors",
134+
"ignore_if_server_version_greater_than": "4.5",
134135
"operation": {
135136
"name": "updateOne",
136137
"arguments": {

0 commit comments

Comments
 (0)