Skip to content

Commit

Permalink
Introduce app tests to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
roekatz committed Aug 14, 2024
1 parent 6c58702 commit 462a263
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 37 deletions.
28 changes: 12 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,17 @@ jobs:
tags: |
permitio/opal-server:test
# TEST PHASE
- name: Create modified docker compose file
run: sed 's/:latest/:test/g' docker/docker-compose-with-callbacks.yml > docker/docker-compose-test.yml

- name: Bring up stack
run: docker-compose -f docker/docker-compose-test.yml up -d

- name: Check if OPA is healthy
run: ./scripts/wait-for.sh -t 2 http://localhost:8181/v1/data/users -- sleep 10 && curl -s "http://localhost:8181/v1/data/users" | jq '.result.bob.location.country == "US"'

- name: Output container logs
run: docker-compose -f docker/docker-compose-test.yml logs
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: check if opal-client was brought up successfully
- name: Install opal packages
run: |
docker-compose -f docker/docker-compose-test.yml logs opal_client | grep "Connected to PubSub server"
docker-compose -f docker/docker-compose-test.yml logs opal_client | grep "Got policy bundle"
docker-compose -f docker/docker-compose-test.yml logs opal_client | grep 'PUT /v1/data/static -> 204'
python -m pip install -e ./packages/opal-common
python -m pip install -e ./packages/opal-client
python -m pip install -e ./packages/opal-server
- name: App Tests
working-directory: ./app-tests
run: POLICY_REPO_SSH_KEY=$OPAL_TESTS_POLICY_REPO_DEPLOY_KEY ./run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ services:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres

opal_server:
image: permitio/opal-server:latest
image: permitio/opal-server:test
deploy:
mode: replicated
replicas: 2
Expand All @@ -31,8 +32,9 @@ services:
- "7002-7003:7002"
depends_on:
- broadcast_channel

opal_client:
image: permitio/opal-client:latest
image: permitio/opal-client:test
deploy:
mode: replicated
replicas: 2
Expand Down
21 changes: 2 additions & 19 deletions docker/app_tests.sh → app-tests/run.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/bin/bash
set -ex

if [ ! -f "docker-compose-with-everything.yml" ]; then
echo "did not find compose file - run this script from the 'docker/' directory under opal root!"
exit
fi
set -e

# TODO: Pretiffy exports
ssh-keygen -q -t rsa -b 4096 -m pem -f opal_crypto_key -N ""
Expand All @@ -16,18 +11,6 @@ rm opal_crypto_key.pub opal_crypto_key
echo "generating master token..."
export OPAL_AUTH_MASTER_TOKEN=`openssl rand -hex 16`

if ! command -v opal-server &> /dev/null
then
echo "opal-server cli was not found, run: 'pip install opal-server'"
exit
fi

if ! command -v opal-client &> /dev/null
then
echo "opal-client cli was not found, run: 'pip install opal-client'"
exit
fi

OPAL_AUTH_JWT_AUDIENCE=https://api.opal.ac/v1/ OPAL_AUTH_JWT_ISSUER=https://opal.ac/ OPAL_REPO_WATCHER_ENABLED=0 opal-server run &

sleep 2;
Expand Down Expand Up @@ -61,7 +44,7 @@ export POLICY_REPO_SSH_KEY
POLICY_REPO_SSH_KEY=${POLICY_REPO_SSH_KEY:=$(cat ~/.ssh/id_rsa)}

function compose {
docker compose -f docker-compose-with-everything.yml --env-file .env "$@"
docker compose -f ./docker-compose-app-tests.yml --env-file .env "$@"
}

function check_clients_logged {
Expand Down

0 comments on commit 462a263

Please sign in to comment.