Skip to content

Commit 666d807

Browse files
committed
IDEV-2133: Integrate e2e tests in CI pipeline.
1 parent 54e562a commit 666d807

File tree

4 files changed

+84
-40
lines changed

4 files changed

+84
-40
lines changed

.github/workflows/test-build-publish.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,38 @@ jobs:
2929
export TOX_SKIP_MISSING_INTERPRETERS="False";
3030
tox -e py
3131
32+
e2e-tests:
33+
runs-on: ubuntu-latest
34+
env:
35+
MITM_BASIC_AUTH_CONTAINER_NAME: e2e_test_mitm_basic_auth
36+
MITM_CUSTOM_CERT_CONTAINER_NAME: e2e_test_mitm_custom_cert
37+
DOCKER_NETWORK_NAME: e2e_test_docker_network
38+
TEST_USER: integrations_testing
39+
TEST_KEY: ${{ secrets.TEST_KEY }}
40+
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v3
44+
45+
- name: Install dependencies
46+
run: |
47+
python -m pip install --upgrade pip
48+
pip install -e .
49+
pip install -r ./requirements/development.txt
50+
51+
- name: Setup E2E environment
52+
run: |
53+
sh ./tests/e2e/scripts/setup_e2e.sh
54+
55+
- name: Run E2E tests
56+
run: |
57+
python -m pytest -s --capture=sys -v --cov=domaintools tests/e2e
58+
59+
- name: Cleanup E2E environment
60+
if: '!cancelled()'
61+
run: |
62+
sh ./tests/e2e/scripts/cleanup_e2e.sh
63+
3264
# run only in main and in pull request to `main` and in publish release
3365
release-build:
3466
if: |

tests/e2e/scripts/cleanup_e2e.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# Script Requirements
4+
# docker
5+
6+
# Clean up containers
7+
echo "Bringing down containers..."
8+
docker stop ${MITM_BASIC_AUTH_CONTAINER_NAME} || true
9+
docker stop ${MITM_CUSTOM_CERT_CONTAINER_NAME} || true
10+
docker network rm ${DOCKER_NETWORK_NAME} || true
11+
12+
# Clean up custom certs
13+
echo "Removing custom certs..."
14+
sudo rm -rf tests/e2e/mitmproxy-ca.pem
15+
sudo rm -rf ~/.test_mitmproxy

tests/e2e/scripts/setup_e2e.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# Script Requirements
4+
# docker
5+
6+
echo "Create a bridge network for the containers to communicate"
7+
docker network create ${DOCKER_NETWORK_NAME}
8+
9+
echo "Spinning ${MITM_BASIC_AUTH_CONTAINER_NAME}"
10+
docker run --rm -d \
11+
--name ${MITM_BASIC_AUTH_CONTAINER_NAME} \
12+
--network ${DOCKER_NETWORK_NAME} \
13+
-p 8080:8080 mitmproxy/mitmproxy mitmdump \
14+
--set proxyauth="username:pass"
15+
16+
echo "Spinning ${MITM_CUSTOM_CERT_CONTAINER_NAME}"
17+
docker run --rm -d -v ~/.test_mitmproxy:/home/mitmproxy/.mitmproxy \
18+
--name ${MITM_CUSTOM_CERT_CONTAINER_NAME} \
19+
--network ${DOCKER_NETWORK_NAME} \
20+
-p 8090:8090 mitmproxy/mitmproxy mitmdump \
21+
--set listen_port=8090
22+
23+
# Check until custom cert from mitmproxy container is copied locally
24+
echo "Checking for valid custom cert..."
25+
while [ ! -f ~/.test_mitmproxy/mitmproxy-ca.pem ] ;
26+
do
27+
sleep 2
28+
done
29+
echo "Valid custom cert found!"
30+
31+
# Copy valid custom cert to target dir
32+
docker cp ${MITM_CUSTOM_CERT_CONTAINER_NAME}:/home/mitmproxy/.mitmproxy/mitmproxy-ca.pem ./tests/e2e/mitmproxy-ca.pem

tests/e2e/scripts/test_e2e_runner.sh

100755100644
Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,15 @@
33
# Script Requirements
44
# docker
55

6-
MITM_BASIC_AUTH_CONTAINER_NAME="e2e_test_mitm_basic_auth"
7-
MITM_CUSTOM_CERT_CONTAINER_NAME="e2e_test_mitm_custom_cert"
8-
DOCKER_NETWORK_NAME="e2e_test_docker_network"
6+
export MITM_BASIC_AUTH_CONTAINER_NAME="e2e_test_mitm_basic_auth"
7+
export MITM_CUSTOM_CERT_CONTAINER_NAME="e2e_test_mitm_custom_cert"
8+
export DOCKER_NETWORK_NAME="e2e_test_docker_network"
99

1010
echo "Starting e2e tests..."
1111

12-
echo "Create a bridge network for the containers to communicate"
13-
docker network create ${DOCKER_NETWORK_NAME}
14-
15-
echo "Spinning ${MITM_BASIC_AUTH_CONTAINER_NAME}"
16-
docker run --rm -d \
17-
--name ${MITM_BASIC_AUTH_CONTAINER_NAME} \
18-
--network ${DOCKER_NETWORK_NAME} \
19-
-p 8080:8080 mitmproxy/mitmproxy mitmdump \
20-
--set proxyauth="username:pass"
21-
22-
echo "Spinning ${MITM_CUSTOM_CERT_CONTAINER_NAME}"
23-
docker run --rm -d -v ~/.test_mitmproxy:/home/mitmproxy/.mitmproxy \
24-
--name ${MITM_CUSTOM_CERT_CONTAINER_NAME} \
25-
--network ${DOCKER_NETWORK_NAME} \
26-
-p 8090:8090 mitmproxy/mitmproxy mitmdump \
27-
--set listen_port=8090
28-
29-
# Check until custom cert from mitmproxy container is copied locally
30-
echo "Checking for valid custom cert..."
31-
while [ ! -f ~/.test_mitmproxy/mitmproxy-ca.pem ] ;
32-
do
33-
sleep 2
34-
done
35-
echo "Valid custom cert found!"
36-
37-
# Copy valid custom cert to target dir
38-
cp ~/.test_mitmproxy/mitmproxy-ca.pem tests/e2e/mitmproxy-ca.pem
12+
sh ./tests/e2e/scripts/setup_e2e.sh
3913

4014
echo "E2E processing..."
4115
python -m pytest -s --capture=sys -v --cov=domaintools tests/e2e
4216

43-
# Clean up containers
44-
echo "Bringing down containers..."
45-
docker stop ${MITM_BASIC_AUTH_CONTAINER_NAME} || true
46-
docker stop ${MITM_CUSTOM_CERT_CONTAINER_NAME} || true
47-
docker network rm ${DOCKER_NETWORK_NAME} || true
48-
49-
# Clean up custom certs
50-
echo "Removing custom certs..."
51-
rm -rf tests/e2e/mitmproxy-ca.pem
52-
rm -rf ~/.test_mitmproxy
17+
sh ./tests/e2e/scripts/cleanup_e2e.sh

0 commit comments

Comments
 (0)