diff --git a/test/acceptance/server.py b/test/acceptance/server.py index cb7b8cb..23fd082 100755 --- a/test/acceptance/server.py +++ b/test/acceptance/server.py @@ -2,6 +2,7 @@ from aas_test_engines import api import os +import shutil import subprocess import atexit import requests @@ -11,8 +12,16 @@ HOST = 'http://localhost:5001' script_dir = os.path.dirname(os.path.realpath(__file__)) +test_data_dir = os.path.join(script_dir, '..', '..', 'bin', 'check_servers', 'test_data') +runner_temp = os.environ.get('RUNNER_TEMP', None) +if runner_temp: + # In Github actions, only certain directories can be mounted + runner_temp = os.path.join(runner_temp, 'test_data') + print(f"Copy '{test_data_dir}' to '{runner_temp}'") + shutil.copytree(test_data_dir, runner_temp) + test_data_dir = runner_temp -def wait_for_server(url: str, max_tries=30): +def wait_for_server(url: str, max_tries=10): for _ in range(max_tries): try: requests.get(url, verify=False) @@ -24,14 +33,12 @@ def wait_for_server(url: str, max_tries=30): print(f"Cannot reach server at {url}") -def start_server() -> str: - test_data_dir = os.path.join(script_dir, '..', '..', 'bin', 'check_servers', 'test_data') +def start_server(test_data_dir: str) -> str: container_id = subprocess.check_output([ 'docker', 'run', '--publish', '5001:5001', '--detach', - # In Github actions, only shared volumes are allowed (suffix z) - '--volume', f'{test_data_dir}:/AasxServerBlazor/aasxs:z', + '--volume', f'{test_data_dir}:/AasxServerBlazor/aasxs', 'docker.io/adminshellio/aasx-server-blazor-for-demo:main', ]) return container_id.decode().strip() @@ -50,7 +57,7 @@ def show_server_logs(container_id: str): ]) -container_id = start_server() +container_id = start_server(test_data_dir) atexit.register(lambda: stop_server(container_id)) wait_for_server(HOST) show_server_logs(container_id)