Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add actions for running e2e tests #35

Merged
merged 14 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 164 additions & 0 deletions .github/workflows/shared-run-e2e-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
name: Run operator E2E tests
on:
workflow_call:
inputs:
core_root:
description: 'The root path for uid2-core folder'
type: string
default: '../uid2-core'
optout_root:
description: 'The root path for uid2-optout folder'
type: string
default: '../uid2-optout'
admin_root:
description: 'The root path for uid2-admin folder'
type: string
default: '../uid2-admin'
operator_root:
description: 'The root path for uid2-operator folder'
type: string
default: '../uid2-operator'
operator_image_version:
description: 'The version of UID2 operator image'
type: string
default: 'latest'
core_image_version:
description: 'The version of UID2 core image'
type: string
default: 'latest'
optout_image_version:
description: 'The version of UID2 optout image'
type: string
default: 'latest'
e2e_image_version:
description: 'The version of E2E image'
type: string
default: 'latest'
core_branch:
description: 'The branch of UID2-core to test on'
type: string
default: 'main'
optout_branch:
description: 'The branch of UID2-optout to test on'
type: string
default: 'main'
admin_branch:
description: 'The branch of UID2-admin to test on'
type: string
default: 'main'
operator_branch:
description: 'The branch of UID2-operator to test on'
type: string
default: 'main'
operator_type:
description: 'The type of operator [either public or private]'
type: string
default: 'public'
uid2_e2e_identity_scope:
description: 'Environment variable to run the E2E test'
required: false
type: string
default: 'UID2'
uid2_e2e_pipeline_operator_type:
description: 'Environment variable to run the E2E test'
required: false
type: string
default: 'PUBLIC'
uid2_e2e_pipeline_operator_url:
description: 'Environment variable to run the E2E test'
required: false
type: string
default: 'http://publicoperator:8080'
uid2_e2e_pipeline_operator_cloud_provider:
description: 'Environment variable to run the E2E test'
required: false
type: string
default: 'PUBLIC'
uid2_e2e_phone_support:
description: 'Environment variable to run the E2E test'
required: false
type: string
default: 'true'

env:
REGISTRY: ghcr.io

jobs:
e2e-test:
name: E2E Test
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
id-token: write
steps:
- name: Log in to the Docker container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}
cYKatherine marked this conversation as resolved.
Show resolved Hide resolved

- name: Checkout full history
uses: actions/checkout@v3

- name: Checkout uid2-core repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.core_branch }}
repository: IABTechLab/uid2-core
path: uid2-core

- name: Checkout uid2-optout repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.optout_branch }}
repository: IABTechLab/uid2-optout
path: uid2-optout

- name: Checkout uid2-admin repo

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would we test with branched off test data?

@gmsdelmundo any ideas?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or branched config

uses: actions/checkout@v3
with:
ref: ${{ inputs.admin_branch }}
repository: IABTechLab/uid2-admin
path: uid2-admin

- name: Checkout uid2-operator repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.operator_branch }}
repository: IABTechLab/uid2-operator
path: uid2-operator

- name: Checkout uid2-shared-actions repo
uses: actions/checkout@v3
with:
repository: IABTechLab/uid2-shared-actions
path: uid2-shared-actions

- name: Checkout uid2-e2e repo
uses: actions/checkout@v3
with:
repository: IABTechLab/uid2-e2e
path: uid2-e2e

- name: Bring up docker compose
id: docker-compose
env:
CORE_ROOT: ${{ inputs.core_root }}
OPTOUT_ROOT: ${{ inputs.optout_root }}
ADMIN_ROOT: ${{ inputs.admin_root }}
OPERATOR_ROOT: ${{ inputs.operator_root }}
CORE_VERSION: ${{ inputs.core_image_version }}
OPTOUT_VERSION: ${{ inputs.optout_image_version }}
OPERATOR_VERSION: ${{ inputs.operator_image_version }}
E2E_VERSION: ${{ inputs.e2e_image_version }}
OPERATOR_TYPE: ${{ inputs.operator_type }}
run: |
cd e2e && bash ../uid2-shared-actions/scripts/prepare-resources-for-e2e-docker-compose.sh

- name: Run e2e tests
id: e2e
uses: IABTechLab/uid2-shared-actions/actions/run_e2e_tests@main
with:
e2e_image_version: ${{ inputs.e2e_image_version }}
58 changes: 58 additions & 0 deletions actions/run_e2e_tests/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Shared E2E Test
description: Pull uid2-e2e Docker image and run E2E test suite

inputs:
e2e_image_version:
description: 'The version of E2E image'
required: false
type: string
default: 'latest'
uid2_e2e_identity_scope:
description: 'Environment variable to run the E2E test'
required: false
type: string
default: 'UID2'
uid2_e2e_pipeline_operator_type:
description: 'Environment variable to run the E2E test'
required: false
type: string
default: 'PUBLIC'
uid2_e2e_pipeline_operator_url:
description: 'Environment variable to run the E2E test'
required: false
type: string
default: 'http://publicoperator:8080'
uid2_e2e_pipeline_operator_cloud_provider:
description: 'Environment variable to run the E2E test'
required: false
type: string
default: 'PUBLIC'
uid2_e2e_phone_support:
description: 'Environment variable to run the E2E test'
required: false
type: string
default: 'true'

runs:
using: "composite"
steps:
- name: Run E2E tests
shell: bash
run: |
docker pull ghcr.io/iabtechlab/uid2-e2e:${{ inputs.e2e_image_version }}
docker images
echo $UID2_E2E_PIPELINE_OPERATOR_TYPE
docker run \
--env UID2_E2E_ENV='github-test-pipeline' \
--env UID2_E2E_API_KEY='UID2-C-L-999-fCXrMM.fsR3mDqAXELtWWMS+xG1s7RdgRTMqdOH2qaAo=' \
--env UID2_E2E_API_KEY_OLD='UID2-C-L-1000-qxpBsF.ibeCDBpD2bq4Zm7inDacGioUk1aaLeNJrabow=' \
--env UID2_E2E_API_SECRET='DzBzbjTJcYL0swDtFs2krRNu+g1Eokm2tBU4dEuD0Wk=' \
--env UID2_E2E_API_SECRET_OLD='VT7+t0G/RVueMuVZAL56I2c3JJFSYQfhbu8yo0V/Tds=' \
--env UID2_E2E_IDENTITY_SCOPE='${{ inputs.uid2_e2e_identity_scope }}' \
--env UID2_E2E_PHONE_SUPPORT='${{ inputs.uid2_e2e_phone_support }}' \
--env UID2_E2E_PIPELINE_OPERATOR_CLOUD_PROVIDER='${{ inputs.uid2_e2e_pipeline_operator_cloud_provider }}' \
--env UID2_E2E_PIPELINE_OPERATOR_TYPE='${{ inputs.uid2_e2e_pipeline_operator_type }}' \
--env UID2_E2E_PIPELINE_OPERATOR_URL='${{ inputs.uid2_e2e_pipeline_operator_url }}' \
--env UID2_E2E_SITE_ID='999' \
--network e2e_default \
ghcr.io/iabtechlab/uid2-e2e:${{ inputs.e2e_image_version }}
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,16 @@ cp "$OPTOUT_ROOT/run_tool_local_e2e.sh" "$OPTOUT_CONFIG_FILE_DIR"
cp -r "$OPTOUT_ROOT/src/main/resources/localstack" "$OPTOUT_RESOURCE_FILE_DIR"
mkdir -p "$OPERATOR_CONFIG_FILE_DIR"
cp "$OPERATOR_ROOT/conf/default-config.json" "$OPERATOR_CONFIG_FILE_DIR"
cp "$OPERATOR_ROOT/conf/local-e2e-docker-$OPERATOR_TYPE-config.json" "$OPERATOR_CONFIG_FILE_DIR"
cp "$OPERATOR_ROOT/conf/local-e2e-docker-$OPERATOR_TYPE-config.json" "$OPERATOR_CONFIG_FILE_DIR/local-e2e-docker-config.json"

cp "../uid2-e2e/docker-compose.yml" "$ROOT"

CORE_CONFIG_FILE="$ROOT/docker/uid2-core/conf/local-e2e-docker-config.json"
OPTOUT_CONFIG_FILE="$ROOT/docker/uid2-optout/conf/local-e2e-docker-config.json"
OPERATOR_CONFIG_FILE="$ROOT/docker/uid2-operator/conf/local-e2e-docker-config.json"
COMPOSE_FILE="$ROOT/docker-compose.yml"
DOCKER_COMPOSE_FILE="$ROOT/docker-compose.yml"
OPTOUT_MOUNT="$ROOT/docker/uid2-optout/mount"


source "$ROOT/jq_helper.sh"
source "$ROOT/healthcheck.sh"

if [ -z "$CORE_VERSION" ]; then
echo "CORE_VERSION can not be empty"
exit 1
Expand All @@ -74,19 +72,19 @@ if [ -z "$E2E_VERSION" ]; then
fi

# replace placeholders
sed -i.bak "s#<CORE_VERSION>#$CORE_VERSION#g" $COMPOSE_FILE
sed -i.bak "s#<OPTOUT_VERSION>#$OPTOUT_VERSION#g" $COMPOSE_FILE
sed -i.bak "s#<OPERATOR_VERSION>#$OPERATOR_VERSION#g" $COMPOSE_FILE
sed -i.bak "s#<E2E_VERSION>#$E2E_VERSION#g" $COMPOSE_FILE
sed -i.bak "s#uid2-core:latest#uid2-core:$CORE_VERSION#g" $DOCKER_COMPOSE_FILE
sed -i.bak "s#uid2-optout:latest#uid2-optout:$OPTOUT_VERSION#g" $DOCKER_COMPOSE_FILE
sed -i.bak "s#uid2-operator:latest#uid2-operator:$OPERATOR_VERSION#g" $DOCKER_COMPOSE_FILE

cat $CORE_CONFIG_FILE
cat $OPTOUT_CONFIG_FILE
cat $OPERATOR_CONFIG_FILE
cat $DOCKER_COMPOSE_FILE

mkdir -p "$OPTOUT_MOUNT" && chmod 777 "$OPTOUT_MOUNT"
chmod 777 "$CORE_RESOURCE_FILE_DIR/init-aws.sh"
chmod 777 "$OPTOUT_RESOURCE_FILE_DIR/init-aws.sh"

docker compose -f "$ROOT/e2e/docker-compose.yml" up -d
docker compose --profile "$OPERATOR_TYPE" -f "$DOCKER_COMPOSE_FILE" up -d
docker ps -a
docker network ls