Skip to content

Commit

Permalink
test: enhancements for e2e tests (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
abalias committed Dec 6, 2022
1 parent 403eb38 commit 15abef6
Show file tree
Hide file tree
Showing 20 changed files with 715 additions and 271 deletions.
33 changes: 28 additions & 5 deletions .github/workflows/e2e-tests.yml
Expand Up @@ -30,6 +30,11 @@ jobs:
with:
java-version: openjdk@1.11

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand All @@ -43,27 +48,45 @@ jobs:
version: v2.12.2 # defaults to 'latest'
legacy: true # will also install in PATH as `docker-compose`

- name: Start services
- name: Start services for issuer
env:
PORT: 8080
uses: isbang/compose-action@v1.4.1
with:
compose-file: "./infrastructure/shared/docker-compose.yml"
compose-flags: "--env-file ./infrastructure/local/.env -p issuer"
up-flags: "--wait"
down-flags: "--volumes"

- name: Start services for holder
env:
PORT: 8090
uses: isbang/compose-action@v1.4.1
with:
compose-file: "./infrastructure/ci/docker-compose-multiple-actors.yml"
compose-file: "./infrastructure/shared/docker-compose.yml"
compose-flags: "--env-file ./infrastructure/local/.env -p holder"
up-flags: "--wait"
down-flags: "--volumes"

- name: Run e2e tests
env:
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
run: |
./gradlew test --info
../../infrastructure/local/update_env.sh
cat ../../infrastructure/local/.env
./gradlew test --tests "E2eTestsRunner"
- uses: actions/upload-artifact@v2
if: always()
with:
name: e2e-tests-result
path: tests/e2e-tests/target/site/reports
path: tests/e2e-tests/target/site/serenity

- name: Publish e2e test Results
if: always()
id: publish-unit-tests
uses: EnricoMi/publish-unit-test-result-action@v2
with:
junit_files: "tests/e2e-tests/target/site/reports/SERENITY-JUNIT-*.xml"
junit_files: "tests/e2e-tests/target/site/serenity/SERENITY-JUNIT-*.xml"
comment_title: "E2E Test Results"
check_name: "E2E Test Results"
2 changes: 1 addition & 1 deletion infrastructure/local/.env
@@ -1,4 +1,4 @@
MERCURY_MEDIATOR_VERSION=0.2.0
IRIS_SERVICE_VERSION=0.1.0
PRISM_AGENT_VERSION=0.6.0
PRISM_AGENT_VERSION=0.10.0
PORT=80
30 changes: 11 additions & 19 deletions infrastructure/local/run.sh
Expand Up @@ -4,9 +4,6 @@ set -e

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# Set working directory
cd ${SCRIPT_DIR}

Help()
{
# Display Help
Expand All @@ -17,6 +14,7 @@ Help()
echo "-n/--name Name of this instance - defaults to dev."
echo "-p/--port Port to run this instance on - defaults to 80."
echo "-b/--background Run in docker-compose daemon mode in the background."
echo "-w/--wait Wait until all containers are healthy (only in the background)."
echo "-h/--help Print this help text."
echo
}
Expand All @@ -39,6 +37,10 @@ while [[ $# -gt 0 ]]; do
BACKGROUND="-d"
shift # past argument
;;
-w|--wait)
WAIT="--wait"
shift # past argument
;;
-h|--help)
Help
exit
Expand All @@ -57,26 +59,13 @@ done

set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters


if [[ -n $1 ]]; then
echo "Last line of file specified as non-opt/last argument:"
tail -1 "$1"
fi

if [ -z ${NAME+x} ];
then
NAME="local"
fi

if [ -z ${PORT+x} ];
then
PORT="80"
fi

if [ -z ${BACKGROUND+x} ];
then
BACKGROUND=""
fi
NAME="${NAME:=local}"
PORT="${PORT:=80}"

echo "NAME = ${NAME}"
echo "PORT = ${PORT}"
Expand All @@ -85,4 +74,7 @@ echo "--------------------------------------"
echo "Bringing up stack using docker-compose"
echo "--------------------------------------"

PORT=${PORT} docker-compose -p ${NAME} -f ../shared/docker-compose.yml --env-file ${SCRIPT_DIR}/.env up ${BACKGROUND}
PORT=${PORT} docker-compose \
-p ${NAME} \
-f ${SCRIPT_DIR}/../shared/docker-compose.yml \
--env-file ${SCRIPT_DIR}/.env up ${BACKGROUND} ${WAIT}
22 changes: 6 additions & 16 deletions infrastructure/local/stop.sh
Expand Up @@ -4,9 +4,6 @@ set -e

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# Set working directory
cd ${SCRIPT_DIR}

Help()
{
# Display Help
Expand Down Expand Up @@ -57,23 +54,16 @@ if [[ -n $1 ]]; then
tail -1 "$1"
fi

if [ -z ${NAME+x} ];
then
NAME="local"
fi

if [ -z ${VOLUMES+x} ];
then
VOLUMES=""
fi

# set a default port as required to ensure docker-compose is valid if not set in env
PORT="80"
NAME="${NAME:=local}"
PORT="${PORT:=80}"

echo "NAME = ${NAME}"

echo "--------------------------------------"
echo "Stopping stack using docker-compose"
echo "--------------------------------------"

PORT=${PORT} docker-compose -p ${NAME} -f ../shared/docker-compose.yml --env-file ${SCRIPT_DIR}/.env down ${VOLUMES}
PORT=${PORT} docker-compose \
-p ${NAME} \
-f ${SCRIPT_DIR}/../shared/docker-compose.yml \
--env-file ${SCRIPT_DIR}/.env down ${VOLUMES}
14 changes: 14 additions & 0 deletions infrastructure/local/update_env.sh
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
ENV_FILE="${SCRIPT_DIR}/.env"

pip install ${SCRIPT_DIR}/../utils/python/github-helpers > /dev/null 2>&1

MERCURY_MEDIATOR_VERSION=$(github get-latest-package-version --package mercury-mediator --package-type container)
IRIS_SERVICE_VERSION=$(github get-latest-package-version --package iris-service --package-type container)
PRISM_AGENT_VERSION=$(github get-latest-package-version --package prism-agent --package-type container)

sed -i.bak "s/MERCURY_MEDIATOR_VERSION=.*/MERCURY_MEDIATOR_VERSION=${MERCURY_MEDIATOR_VERSION}/" ${ENV_FILE} && rm -f ${ENV_FILE}.bak
sed -i.bak "s/IRIS_SERVICE_VERSION=.*/IRIS_SERVICE_VERSION=${IRIS_SERVICE_VERSION}/" ${ENV_FILE} && rm -f ${ENV_FILE}.bak
sed -i.bak "s/PRISM_AGENT_VERSION=.*/PRISM_AGENT_VERSION=${PRISM_AGENT_VERSION}/" ${ENV_FILE} && rm -f ${ENV_FILE}.bak
63 changes: 30 additions & 33 deletions infrastructure/shared/docker-compose.yml
Expand Up @@ -14,14 +14,11 @@ services:
POSTGRES_PASSWORD: postgres
volumes:
- pg_data_castor_db:/var/lib/postgresql/data

# delay to ensure DB is up before applying migrations
db_castor_init_delay:
image: alpine:3
command: sleep 5
depends_on:
db_castor:
condition: service_started
healthcheck:
test: [ "CMD", "pg_isready", "-U", "postgres", "-d", "castor" ]
interval: 10s
timeout: 5s
retries: 5

##########################
# Pollux Database
Expand All @@ -36,14 +33,11 @@ services:
POSTGRES_PASSWORD: postgres
volumes:
- pg_data_pollux_db:/var/lib/postgresql/data

# delay to ensure DB is up before applying migrations
db_pollux_init_delay:
image: alpine:3
command: sleep 5
depends_on:
db_pollux:
condition: service_started
healthcheck:
test: [ "CMD", "pg_isready", "-U", "postgres", "-d", "pollux" ]
interval: 10s
timeout: 5s
retries: 5

##########################
# Connect Database
Expand All @@ -58,14 +52,11 @@ services:
POSTGRES_PASSWORD: postgres
volumes:
- pg_data_connect_db:/var/lib/postgresql/data

# delay to ensure DB is up before applying migrations
db_connect_init_delay:
image: alpine:3
command: sleep 5
depends_on:
db_connect:
condition: service_started
healthcheck:
test: [ "CMD", "pg_isready", "-U", "postgres", "-d", "connect" ]
interval: 10s
timeout: 5s
retries: 5

##########################
# Iris Database
Expand All @@ -80,15 +71,11 @@ services:
POSTGRES_PASSWORD: postgres
volumes:
- pg_data_iris_db:/var/lib/postgresql/data

# delay to ensure DB is up before applying migrations
db_iris_init_delay:
image: alpine:3
command: sleep 5
depends_on:
db_iris:
condition: service_started

healthcheck:
test: [ "CMD", "pg_isready", "-U", "postgres", "-d", "iris" ]
interval: 10s
timeout: 5s
retries: 5

##########################
# Services
Expand Down Expand Up @@ -125,6 +112,16 @@ services:
CONNECT_DB_USER: postgres
CONNECT_DB_PASSWORD: postgres
DIDCOMM_SERVICE_URL: http://host.docker.internal:${PORT}/didcomm/
depends_on:
- db_castor
- db_pollux
healthcheck:
test: [ "CMD", "curl", "-f", "http://prism-agent:8080/connections" ]
interval: 30s
timeout: 10s
retries: 5
extra_hosts:
- "host.docker.internal:host-gateway"

swagger-ui:
image: swaggerapi/swagger-ui:v4.14.0
Expand Down
3 changes: 3 additions & 0 deletions infrastructure/utils/python/github-helpers/.gitignore
@@ -0,0 +1,3 @@
build/
*.egg-info/
.env-e
Empty file.

0 comments on commit 15abef6

Please sign in to comment.