Skip to content

Commit

Permalink
Use RUNNER_TEMP
Browse files Browse the repository at this point in the history
  • Loading branch information
otto-ifak committed Nov 12, 2024
1 parent a0aca9e commit c2128b2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions test/acceptance/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from aas_test_engines import api
import os
import shutil
import subprocess
import atexit
import requests
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit c2128b2

Please sign in to comment.