diff --git a/e2e_tests/conftest.py b/e2e_tests/conftest.py new file mode 100644 index 00000000..12b975e2 --- /dev/null +++ b/e2e_tests/conftest.py @@ -0,0 +1,19 @@ +import pytest +import subprocess +import time +import os + +@pytest.fixture(scope="session", autouse=True) +def docker_compose_setup(): + """Spin up Docker containers for OPAL services using docker-compose.""" + compose_file = os.path.abspath("./docker-compose.yml") + + subprocess.run(["docker-compose", "-f", compose_file, "up", "-d"]) + + # Wait for services to be up and running + time.sleep(60) + + yield + + # Tear down the Docker services after tests + subprocess.run(["docker-compose", "-f", compose_file, "down"]) diff --git a/e2e_tests/docker-compose.yml b/e2e_tests/docker-compose.yml new file mode 100644 index 00000000..ef3dca27 --- /dev/null +++ b/e2e_tests/docker-compose.yml @@ -0,0 +1,20 @@ +services: + opal_server: + image: permitio/opal-server:${OPAL_IMAGE_TAG:-latest} + ports: + - "7002:7002" + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:7002/health"] + interval: 10s + timeout: 10s + retries: 5 + + opal_client: + image: permitio/opal-client:${OPAL_IMAGE_TAG:-latest} + ports: + - "7776:7000" + healthcheck: + test: ["CMD", "curl", "-f", "http://opal_server:7002/health"] + interval: 10s + timeout: 10s + retries: 5 diff --git a/e2e_tests/requirements.txt b/e2e_tests/requirements.txt new file mode 100644 index 00000000..35b47dca --- /dev/null +++ b/e2e_tests/requirements.txt @@ -0,0 +1,3 @@ +pytest +requests +docker \ No newline at end of file diff --git a/e2e_tests/tests/test_e2e.py b/e2e_tests/tests/test_e2e.py new file mode 100644 index 00000000..50b205ca --- /dev/null +++ b/e2e_tests/tests/test_e2e.py @@ -0,0 +1,12 @@ +import requests + +def test_opal_server_health(): + """Test OPAL Server health endpoint.""" + response = requests.get("http://localhost:7002/policy-data") + assert response.status_code == 200 + +def test_opal_client_health(): + """Test OPAL Client endpoint.""" + response = requests.get("http://localhost:7766/ready") + assert response.status_code == 200 + assert 'connected' in response.json()