Skip to content

Commit 3992792

Browse files
authored
chore: run connectivity tests in a docker container (#3087)
* chore: run connectivity tests in a docker container * run test-connectivity on prs * fix paths and add logging * fix dockerfile * replace host gateway with hardcoded ip * run from monorepo root * replace localhost everywhere * try net = host * fix run * switch to 0.0.0.0 * revert unnecessary changes to connect.spec.ts
1 parent b5cd3b0 commit 3992792

File tree

9 files changed

+119
-140
lines changed

9 files changed

+119
-140
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
**/node_modules
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# "bullseye" is the debian distribution that
2+
# ubuntu:20.04 is based on
3+
FROM node:14-bullseye
4+
5+
COPY .evergreen/connectivity-tests/krb5.conf /etc/krb5.conf
6+
7+
RUN apt-get update -y && \
8+
apt-get install -y \
9+
krb5-user \
10+
libsasl2-modules-gssapi-mit \
11+
ldap-utils \
12+
libkrb5-dev \
13+
libsecret-1-dev \
14+
net-tools \
15+
libstdc++6 \
16+
gnome-keyring
17+
18+
ENV COMPASS_RUN_DOCKER_TESTS="true"
19+
20+
COPY . /compass-monorepo-root
21+
WORKDIR /compass-monorepo-root
22+
23+
RUN npm i -g npm@8
24+
RUN npm run bootstrap-ci
25+
26+
CMD ["bash", ".evergreen/connectivity-tests/entrypoint.sh"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
echo "---- HOSTS: ----"
5+
cat /etc/hosts
6+
echo "----------------"
7+
8+
echo "running kinit"
9+
echo 'password' | kinit [email protected]
10+
echo
11+
echo "klist:"
12+
klist
13+
echo
14+
15+
echo "Running 'npm run test-connectivity --workspace mongodb-data-service' in ${PWD}"
16+
npm run test-connectivity --workspace mongodb-data-service
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[libdefaults]
2+
default_realm = EXAMPLE.COM
3+
dns_canonicalize_hostname = false
4+
5+
[realms]
6+
EXAMPLE.COM = {
7+
kdc = localhost
8+
admin_server = localhost
9+
}
10+
11+
EXAMPLE2.COM = {
12+
kdc = localhost:89
13+
admin_server = localhost:849
14+
}
15+
16+
[domain_realm]
17+
.examplecrossrealm.com = EXAMPLE2.COM

.evergreen/connectivity-tests/run.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
# NOTE: do not -x here there are "env" vars in the commands
4+
set -e
5+
6+
MONOREPO_ROOT_DIR="$(cd $(dirname "$0")/../..; pwd)"
7+
cd $MONOREPO_ROOT_DIR
8+
9+
echo "building connectivity tests image from ${PWD}"
10+
docker build -t devtools-connectivity-tests -f "./.evergreen/connectivity-tests/Dockerfile" .
11+
echo "connectivity tests image built"
12+
13+
echo running connectivity tests image
14+
15+
docker run \
16+
--rm \
17+
-e E2E_TESTS_ATLAS_HOST="${E2E_TESTS_ATLAS_HOST}" \
18+
-e E2E_TESTS_DATA_LAKE_HOST="${E2E_TESTS_DATA_LAKE_HOST}" \
19+
-e E2E_TESTS_ANALYTICS_NODE_HOST="${E2E_TESTS_ANALYTICS_NODE_HOST}" \
20+
-e E2E_TESTS_SERVERLESS_HOST="${E2E_TESTS_SERVERLESS_HOST}" \
21+
-e E2E_TESTS_FREE_TIER_HOST="${E2E_TESTS_FREE_TIER_HOST}" \
22+
-e E2E_TESTS_ATLAS_USERNAME="${E2E_TESTS_ATLAS_USERNAME}" \
23+
-e E2E_TESTS_ATLAS_PASSWORD="${E2E_TESTS_ATLAS_PASSWORD}" \
24+
-e E2E_TESTS_ATLAS_X509_PEM="${E2E_TESTS_ATLAS_X509_PEM}" \
25+
-e MONGODB_VERSION="${MONGODB_VERSION}" \
26+
--add-host mongodb-kerberos-1.example.com:0.0.0.0 \
27+
--add-host mongodb-kerberos-2.example.com:0.0.0.0 \
28+
--add-host mongodb-kerberos-3.examplecrossrealm.com:0.0.0.0 \
29+
--network host \
30+
devtools-connectivity-tests
31+

.evergreen/functions.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ post:
9494
file_location: src/packages/compass-e2e-tests/.log/report.json
9595

9696
functions:
97+
clone:
98+
- command: git.get_project
99+
params:
100+
directory: src
101+
97102
prepare:
98103
- command: git.get_project
99104
params:
@@ -383,7 +388,7 @@ functions:
383388
# Load environment variables
384389
eval $(.evergreen/print-compass-env.sh)
385390
source .evergreen/start-docker-envs.sh
386-
npm run test-connectivity --workspace mongodb-data-service
391+
bash .evergreen/connectivity-tests/run.sh
387392
388393
test-csfle:
389394
- command: shell.exec

.evergreen/tasks.in.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,9 @@ tasks:
124124
variants: [ubuntu]
125125

126126
- name: test-connectivity
127-
tags: ['required-for-publish']
127+
tags: ['required-for-publish', 'run-on-pr']
128128
commands:
129-
- func: prepare
130-
- func: install
131-
- func: bootstrap
129+
- func: clone
132130
- func: test-connectivity
133131
vars:
134132
debug: 'compass*,electron*,hadron*,mongo*'

.evergreen/tasks.yml

+19-21
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,9 @@ tasks:
124124
variants: [ubuntu]
125125

126126
- name: test-connectivity
127-
tags: ['required-for-publish']
127+
tags: ['required-for-publish', 'run-on-pr']
128128
commands:
129-
- func: prepare
130-
- func: install
131-
- func: bootstrap
129+
- func: clone
132130
- func: test-connectivity
133131
vars:
134132
debug: 'compass*,electron*,hadron*,mongo*'
@@ -277,7 +275,7 @@ tasks:
277275
target_platform: '--platform=darwin'
278276

279277
# copied as test-packaged-app-macos due to depends_on variation
280-
278+
281279

282280
- name: test-packaged-app-40x-community
283281
tags: ['required-for-publish', 'run-on-pr']
@@ -296,11 +294,11 @@ tasks:
296294
vars:
297295
compass_distribution: compass
298296
- func: test-packaged-app
299-
vars:
297+
vars:
300298
mongodb_version: 4.0.x
301299
compass_distribution: compass
302300
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'
303-
301+
304302

305303
- name: test-packaged-app-40x-enterprise
306304
tags: ['required-for-publish', 'run-on-pr']
@@ -319,12 +317,12 @@ tasks:
319317
vars:
320318
compass_distribution: compass
321319
- func: test-packaged-app
322-
vars:
320+
vars:
323321
mongodb_version: 4.0.x
324322
mongodb_use_enterprise: yes
325323
compass_distribution: compass
326324
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'
327-
325+
328326

329327
- name: test-packaged-app-42x-community
330328
tags: ['required-for-publish', 'run-on-pr']
@@ -343,11 +341,11 @@ tasks:
343341
vars:
344342
compass_distribution: compass
345343
- func: test-packaged-app
346-
vars:
344+
vars:
347345
mongodb_version: 4.2.x
348346
compass_distribution: compass
349347
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'
350-
348+
351349

352350
- name: test-packaged-app-42x-enterprise
353351
tags: ['required-for-publish', 'run-on-pr']
@@ -366,12 +364,12 @@ tasks:
366364
vars:
367365
compass_distribution: compass
368366
- func: test-packaged-app
369-
vars:
367+
vars:
370368
mongodb_version: 4.2.x
371369
mongodb_use_enterprise: yes
372370
compass_distribution: compass
373371
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'
374-
372+
375373

376374
- name: test-packaged-app-44x-community
377375
tags: ['required-for-publish', 'run-on-pr']
@@ -390,11 +388,11 @@ tasks:
390388
vars:
391389
compass_distribution: compass
392390
- func: test-packaged-app
393-
vars:
391+
vars:
394392
mongodb_version: 4.4.x
395393
compass_distribution: compass
396394
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'
397-
395+
398396

399397
- name: test-packaged-app-44x-enterprise
400398
tags: ['required-for-publish', 'run-on-pr']
@@ -413,12 +411,12 @@ tasks:
413411
vars:
414412
compass_distribution: compass
415413
- func: test-packaged-app
416-
vars:
414+
vars:
417415
mongodb_version: 4.4.x
418416
mongodb_use_enterprise: yes
419417
compass_distribution: compass
420418
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'
421-
419+
422420

423421
- name: test-packaged-app-5x-community
424422
tags: ['required-for-publish', 'run-on-pr']
@@ -437,11 +435,11 @@ tasks:
437435
vars:
438436
compass_distribution: compass
439437
- func: test-packaged-app
440-
vars:
438+
vars:
441439
mongodb_version: 5.x.x
442440
compass_distribution: compass
443441
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'
444-
442+
445443

446444
- name: test-packaged-app-5x-enterprise
447445
tags: ['required-for-publish', 'run-on-pr']
@@ -460,9 +458,9 @@ tasks:
460458
vars:
461459
compass_distribution: compass
462460
- func: test-packaged-app
463-
vars:
461+
vars:
464462
mongodb_version: 5.x.x
465463
mongodb_use_enterprise: yes
466464
compass_distribution: compass
467465
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'
468-
466+

.github/workflows/connectivity-tests.yaml

-114
This file was deleted.

0 commit comments

Comments
 (0)