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

feat: E2E tests framework using PyTest #681

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
19 changes: 19 additions & 0 deletions e2e_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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("../app-tests/docker-compose-app-tests.yml")

subprocess.run(["docker-compose", "-f", compose_file, "up", "-d"])

# Wait for services to be up and running
time.sleep(10)

yield

# Tear down the Docker services after tests
subprocess.run(["docker-compose", "-f", compose_file, "down"])
3 changes: 3 additions & 0 deletions e2e_tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest
requests
docker
24 changes: 24 additions & 0 deletions e2e_tests/tests/test_e2e.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import requests
import time
import subprocess

def check_logs(container_name):
result = subprocess.run(["docker", "logs", container_name], capture_output=True, text=True)
assert "ERROR" not in result.stdout and "CRITICAL" not in result.stdout, f"Critical errors found in {container_name}"

def test_opal_server_health():
"""Test OPAL Server health endpoint."""
response = requests.get("http://opal_server:7002/healthcheck")
assert response.status_code == 200

def test_opal_client_health():
"""Test OPAL Client endpoint."""
response = requests.get("http://opal_client:7000/healthcheck")
assert response.status_code == 200
print(response.json())

def test_opal_server_logs():
check_logs("app-tests-opal_server-1")

def test_opal_client_logs():
check_logs("app-tests-opal_client-1")