-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f175b6
commit fe5d93a
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("./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"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pytest | ||
requests | ||
docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |