Skip to content

Commit

Permalink
chore: run connectivity tests in a docker container (#3087)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mcasimir authored May 16, 2022
1 parent b5cd3b0 commit 3992792
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 140 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
**/node_modules
26 changes: 26 additions & 0 deletions .evergreen/connectivity-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# "bullseye" is the debian distribution that
# ubuntu:20.04 is based on
FROM node:14-bullseye

COPY .evergreen/connectivity-tests/krb5.conf /etc/krb5.conf

RUN apt-get update -y && \
apt-get install -y \
krb5-user \
libsasl2-modules-gssapi-mit \
ldap-utils \
libkrb5-dev \
libsecret-1-dev \
net-tools \
libstdc++6 \
gnome-keyring

ENV COMPASS_RUN_DOCKER_TESTS="true"

COPY . /compass-monorepo-root
WORKDIR /compass-monorepo-root

RUN npm i -g npm@8
RUN npm run bootstrap-ci

CMD ["bash", ".evergreen/connectivity-tests/entrypoint.sh"]
16 changes: 16 additions & 0 deletions .evergreen/connectivity-tests/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -e
echo "---- HOSTS: ----"
cat /etc/hosts
echo "----------------"

echo "running kinit"
echo 'password' | kinit [email protected]
echo
echo "klist:"
klist
echo

echo "Running 'npm run test-connectivity --workspace mongodb-data-service' in ${PWD}"
npm run test-connectivity --workspace mongodb-data-service
17 changes: 17 additions & 0 deletions .evergreen/connectivity-tests/krb5.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[libdefaults]
default_realm = EXAMPLE.COM
dns_canonicalize_hostname = false

[realms]
EXAMPLE.COM = {
kdc = localhost
admin_server = localhost
}

EXAMPLE2.COM = {
kdc = localhost:89
admin_server = localhost:849
}

[domain_realm]
.examplecrossrealm.com = EXAMPLE2.COM
31 changes: 31 additions & 0 deletions .evergreen/connectivity-tests/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

# NOTE: do not -x here there are "env" vars in the commands
set -e

MONOREPO_ROOT_DIR="$(cd $(dirname "$0")/../..; pwd)"
cd $MONOREPO_ROOT_DIR

echo "building connectivity tests image from ${PWD}"
docker build -t devtools-connectivity-tests -f "./.evergreen/connectivity-tests/Dockerfile" .
echo "connectivity tests image built"

echo running connectivity tests image

docker run \
--rm \
-e E2E_TESTS_ATLAS_HOST="${E2E_TESTS_ATLAS_HOST}" \
-e E2E_TESTS_DATA_LAKE_HOST="${E2E_TESTS_DATA_LAKE_HOST}" \
-e E2E_TESTS_ANALYTICS_NODE_HOST="${E2E_TESTS_ANALYTICS_NODE_HOST}" \
-e E2E_TESTS_SERVERLESS_HOST="${E2E_TESTS_SERVERLESS_HOST}" \
-e E2E_TESTS_FREE_TIER_HOST="${E2E_TESTS_FREE_TIER_HOST}" \
-e E2E_TESTS_ATLAS_USERNAME="${E2E_TESTS_ATLAS_USERNAME}" \
-e E2E_TESTS_ATLAS_PASSWORD="${E2E_TESTS_ATLAS_PASSWORD}" \
-e E2E_TESTS_ATLAS_X509_PEM="${E2E_TESTS_ATLAS_X509_PEM}" \
-e MONGODB_VERSION="${MONGODB_VERSION}" \
--add-host mongodb-kerberos-1.example.com:0.0.0.0 \
--add-host mongodb-kerberos-2.example.com:0.0.0.0 \
--add-host mongodb-kerberos-3.examplecrossrealm.com:0.0.0.0 \
--network host \
devtools-connectivity-tests

7 changes: 6 additions & 1 deletion .evergreen/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ post:
file_location: src/packages/compass-e2e-tests/.log/report.json

functions:
clone:
- command: git.get_project
params:
directory: src

prepare:
- command: git.get_project
params:
Expand Down Expand Up @@ -383,7 +388,7 @@ functions:
# Load environment variables
eval $(.evergreen/print-compass-env.sh)
source .evergreen/start-docker-envs.sh
npm run test-connectivity --workspace mongodb-data-service
bash .evergreen/connectivity-tests/run.sh
test-csfle:
- command: shell.exec
Expand Down
6 changes: 2 additions & 4 deletions .evergreen/tasks.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,9 @@ tasks:
variants: [ubuntu]

- name: test-connectivity
tags: ['required-for-publish']
tags: ['required-for-publish', 'run-on-pr']
commands:
- func: prepare
- func: install
- func: bootstrap
- func: clone
- func: test-connectivity
vars:
debug: 'compass*,electron*,hadron*,mongo*'
Expand Down
40 changes: 19 additions & 21 deletions .evergreen/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,9 @@ tasks:
variants: [ubuntu]

- name: test-connectivity
tags: ['required-for-publish']
tags: ['required-for-publish', 'run-on-pr']
commands:
- func: prepare
- func: install
- func: bootstrap
- func: clone
- func: test-connectivity
vars:
debug: 'compass*,electron*,hadron*,mongo*'
Expand Down Expand Up @@ -277,7 +275,7 @@ tasks:
target_platform: '--platform=darwin'

# copied as test-packaged-app-macos due to depends_on variation


- name: test-packaged-app-40x-community
tags: ['required-for-publish', 'run-on-pr']
Expand All @@ -296,11 +294,11 @@ tasks:
vars:
compass_distribution: compass
- func: test-packaged-app
vars:
vars:
mongodb_version: 4.0.x
compass_distribution: compass
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'


- name: test-packaged-app-40x-enterprise
tags: ['required-for-publish', 'run-on-pr']
Expand All @@ -319,12 +317,12 @@ tasks:
vars:
compass_distribution: compass
- func: test-packaged-app
vars:
vars:
mongodb_version: 4.0.x
mongodb_use_enterprise: yes
compass_distribution: compass
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'


- name: test-packaged-app-42x-community
tags: ['required-for-publish', 'run-on-pr']
Expand All @@ -343,11 +341,11 @@ tasks:
vars:
compass_distribution: compass
- func: test-packaged-app
vars:
vars:
mongodb_version: 4.2.x
compass_distribution: compass
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'


- name: test-packaged-app-42x-enterprise
tags: ['required-for-publish', 'run-on-pr']
Expand All @@ -366,12 +364,12 @@ tasks:
vars:
compass_distribution: compass
- func: test-packaged-app
vars:
vars:
mongodb_version: 4.2.x
mongodb_use_enterprise: yes
compass_distribution: compass
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'


- name: test-packaged-app-44x-community
tags: ['required-for-publish', 'run-on-pr']
Expand All @@ -390,11 +388,11 @@ tasks:
vars:
compass_distribution: compass
- func: test-packaged-app
vars:
vars:
mongodb_version: 4.4.x
compass_distribution: compass
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'


- name: test-packaged-app-44x-enterprise
tags: ['required-for-publish', 'run-on-pr']
Expand All @@ -413,12 +411,12 @@ tasks:
vars:
compass_distribution: compass
- func: test-packaged-app
vars:
vars:
mongodb_version: 4.4.x
mongodb_use_enterprise: yes
compass_distribution: compass
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'


- name: test-packaged-app-5x-community
tags: ['required-for-publish', 'run-on-pr']
Expand All @@ -437,11 +435,11 @@ tasks:
vars:
compass_distribution: compass
- func: test-packaged-app
vars:
vars:
mongodb_version: 5.x.x
compass_distribution: compass
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'


- name: test-packaged-app-5x-enterprise
tags: ['required-for-publish', 'run-on-pr']
Expand All @@ -460,9 +458,9 @@ tasks:
vars:
compass_distribution: compass
- func: test-packaged-app
vars:
vars:
mongodb_version: 5.x.x
mongodb_use_enterprise: yes
compass_distribution: compass
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'

114 changes: 0 additions & 114 deletions .github/workflows/connectivity-tests.yaml

This file was deleted.

0 comments on commit 3992792

Please sign in to comment.