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

E2E Tests version 1.0 #731

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
30809a7
E2E Tests version 1.0 (#2)
iwphonedo Jan 7, 2025
a3f892a
Refactor test scripts and improve documentation comments
iwphonedo Jan 8, 2025
ed3c033
Refactor service configurations and update container dependencies
iwphonedo Jan 8, 2025
59b3404
Add end-to-end tests to GitHub Actions workflow
iwphonedo Jan 8, 2025
58ada4a
Refactor log waiting mechanism to use threading for improved performa…
ariWeinberg Jan 9, 2025
2c978f6
Refactor PostgresBroadcastContainer usage in tests for improved clari…
ariWeinberg Jan 9, 2025
d8a8edf
Fix sleep duration in GitHub Actions and adjust context path in Docke…
ariWeinberg Jan 10, 2025
7da2b5f
Update e2e_tests workflow to change directory command and add listing…
ariWeinberg Jan 10, 2025
a52803d
Refactor e2e_tests workflow to streamline directory navigation and im…
ariWeinberg Jan 10, 2025
c247d85
Update e2e_tests workflow to trigger on master branch for improved te…
ariWeinberg Jan 10, 2025
f7c4b62
Remove redundant e2e tests step in workflow for cleaner execution
ariWeinberg Jan 10, 2025
d3b782f
Add newline at end of run.sh execution in tests workflow for consistency
ariWeinberg Jan 10, 2025
81f6a5d
Remove trailing newline at end of run.sh execution in tests workflow
ariWeinberg Jan 10, 2025
862f857
Remove unused debugpy import from api.py
iwphonedo Jan 10, 2025
8d90371
Rename workflow to 'E2E Tests' and add trigger for completed 'Tests' …
iwphonedo Jan 10, 2025
6694f51
Refactor start.sh to remove sleep and debugpy execution, streamline g…
ariWeinberg Jan 10, 2025
8d3b000
Fix Dockerfile paths to use relative references for consistency
ariWeinberg Jan 10, 2025
71f2b35
Update Dockerfile to use relative path for wait-for.sh and remove unu…
ariWeinberg Jan 10, 2025
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
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
"runArgs": ["--name", "OAPL-DEV"],
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}

},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "/bin/bash .devcontainer/setup.sh",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
20 changes: 20 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

if [ -d ".venv" ]; then
echo "Virtual environment already exists"
else
python3 -m venv .venv
fi
source .venv/bin/activate

apt-get update && apt-get install -y git

pip install --upgrade pip
pip3 install --user -r requirements.txt

cd tests
pip3 install --user -r requirements.txt

pip install pre-commit
pre-commit install
pre-commit run --all-files
44 changes: 44 additions & 0 deletions .github/workflows/e2e_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: E2E Tests

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_run:
workflows: ["Tests"]
types:
- completed

jobs:
test:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3

# Set up Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x' # Adjust the version as needed

# Install opal dependencies
- name: Install opal dependencies
run: pip install -r requirements.txt

# Ensure Docker is installed and running
- name: Set up Docker
uses: docker/setup-buildx-action@v2

# Install test dependencies
- name: Install test dependencies
run: cd ./tests && pip install -r requirements.txt

# Run the tests using the script
- name: Run tests
run: cd ./tests && ./run.sh
75 changes: 37 additions & 38 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
# Byte-compiled / optimized / DLL files
# OPAL specific
.env
*.env
opal-example-policy-repo/*


# Temporary and Python cache files
**/*.pyc
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Virtual environments
.venv/
venv/
env/
ENV/
env.bak/
venv.bak/

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
Expand All @@ -18,7 +32,6 @@ lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
Expand All @@ -27,16 +40,14 @@ share/python-wheels/
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# PyInstaller
*.manifest
*.spec

# Unit test / coverage reports
htmlcov/
.tox/
Expand All @@ -55,17 +66,17 @@ coverage.xml
*.mo
*.pot

# Django stuff:
# Django
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
# Flask
instance/
.webassets-cache

# Scrapy stuff:
# Scrapy
.scrapy

# Sphinx documentation
Expand All @@ -84,53 +95,41 @@ ipython_config.py
# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
# Pipenv
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
# PEP 582
__pypackages__/

# Celery stuff
# Celery
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
# SageMath
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Editors
.vscode/
.idea
*.iml

# Spyder project settings
# Spyder
.spyderproject
.spyproject

# Rope project settings
# Rope
.ropeproject

# mkdocs documentation
/site
# mkdocs
docs/_build/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
# Pyre
.pyre/

# editors
.vscode/
.idea
*.iml

# System files
.DS_Store
40 changes: 40 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Remote to local",
"type": "debugpy",
"request": "attach",
"justMyCode": false,
"subProcess": true,
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "${cwd}"
}
]
},
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Debug with Args",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"args": [
"--deploy",
"--with_broadcast",
],
"console": "integratedTerminal"
}
]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"cmake.ignoreCMakeListsMissing": true,
"makefile.configureOnOpen": false,
"python.analysis.extraPaths": [
"./packages/opal-common",
"./packages/opal-server"
]
}
15 changes: 11 additions & 4 deletions app-tests/docker-compose-app-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

services:

broadcast_channel:
image: postgres:alpine
environment:
Expand All @@ -7,15 +9,19 @@ services:
- POSTGRES_PASSWORD=postgres

opal_server:
image: permitio/opal-server:${OPAL_IMAGE_TAG:-latest}
#image: permitio/opal-server:${OPAL_IMAGE_TAG:-latest}
build:
context: ../ # Point to the directory containing your Dockerfile
dockerfile: ./docker/Dockerfile.server # Specify your Dockerfile if it's not named 'Dockerfile'
deploy:
mode: replicated
replicas: 2
replicas: 1
endpoint_mode: vip
environment:
- OPAL_BROADCAST_URI=postgres://postgres:postgres@broadcast_channel:5432/postgres
- UVICORN_NUM_WORKERS=4
- OPAL_POLICY_REPO_URL=${OPAL_POLICY_REPO_URL:[email protected]:permitio/opal-tests-policy-repo.git}
- UVICORN_NUM_WORKERS=0
#- OPAL_POLICY_REPO_URL=${OPAL_POLICY_REPO_URL:[email protected]:permitio/opal-tests-policy-repo.git}
- OPAL_POLICY_REPO_URL=${OPAL_POLICY_REPO_URL:[email protected]:permitio/opal-example-policy-repo.git}
- OPAL_POLICY_REPO_MAIN_BRANCH=${POLICY_REPO_BRANCH}
- OPAL_POLICY_REPO_SSH_KEY=${OPAL_POLICY_REPO_SSH_KEY}
- OPAL_DATA_CONFIG_SOURCES={"config":{"entries":[{"url":"http://opal_server:7002/policy-data","config":{"headers":{"Authorization":"Bearer ${OPAL_CLIENT_TOKEN}"}},"topics":["policy_data"],"dst_path":"/static"}]}}
Expand All @@ -35,6 +41,7 @@ services:

opal_client:
image: permitio/opal-client:${OPAL_IMAGE_TAG:-latest}
scale: 2
deploy:
mode: replicated
replicas: 2
Expand Down
1 change: 1 addition & 0 deletions app-tests/jwks_dir/jwks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"keys": [{"kty": "RSA", "key_ops": ["verify"], "n": "zQSk0F8jfU3KR9w-7-aq5n7Elh34Vhi1pzQsKG7VVoJgzqHqhXP1JsbSo-4ntAZ77fCWKMd25y4gOmNpur_0sOErRtSGwdlwVRxef-wztDD0ecqksMF7c2ZNwdq3hXxJ9NrDpcg8ORmIt6q-T5ZtbvoYhVy37LKw5dr0ry-SxfTeUuadFin4wTMQAwuiYKNQMGjuW8eEGi_ZEjziXjhQhEWfIIhH1v_jcWnW-_cjx7fvJ_Jau98vs40KKLawnvueiRdi8KWNQpA4b6480b0KfC0U7qbr61-fyL8u0L7aotTxmMzCfRabBRQ53sR5zYvvhV4Y-OZM_82RAFleIFsNfjrkbN5Sq7NEStE3b_yLMYu_uW5IoewOt7X3MgICq0jiXrbvExuJ0pq7DGlax5uhBt316Gt_HY8yqWAnCaa766_0av8IVZstRlCPOjhaM4liEneNdlzGheQlxoi6SxvQFhy4jbcG4tAmbvRIWpAbYaaXyB0H_PMPN7uPzo9lQNv1N6jMHlUq9GOGMy83qy6iQ2aA_NouCwDUKh5WUDePZwpwNFd5Fs6EiBcESG0SJkTwyuFPM6iYl6H2S7Knf8CYJMmixr_Ezm0id0Ltm0_FAwoEUqbltSmaGDZeI5T29732eFr9lK0Fw5R8_2X6uIRaIljCMSkbrRQcsm8gUZ_H9ms", "e": "AQAB"}]}
Loading
Loading