Separated IOC startup from running tests
This commit is contained in:
@@ -1,24 +1,21 @@
|
||||
import time
|
||||
|
||||
from caproto.sync.client import read, write
|
||||
from ioc.pystartioc import startioc
|
||||
import pytest
|
||||
|
||||
from common import read_config
|
||||
|
||||
TIMEOUT_IOC_STARTUP = 10
|
||||
TIMEOUT_READ = 2
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def prepare_ioc():
|
||||
def check_ioc_running():
|
||||
|
||||
config = read_config()
|
||||
pvprefix = config['pvprefix']
|
||||
|
||||
"""
|
||||
This function checks if the test IOC is already running and attempts to
|
||||
start it, if that is not the case.
|
||||
This function checks if the test IOC is already running.
|
||||
"""
|
||||
try:
|
||||
read(f'{pvprefix}:IOCREADY', timeout=TIMEOUT_READ)
|
||||
@@ -27,18 +24,5 @@ def prepare_ioc():
|
||||
# is running
|
||||
return
|
||||
except TimeoutError:
|
||||
# Received a timeout error -> Start the IOC
|
||||
startioc()
|
||||
|
||||
# Check periodically if the IOC started successfully
|
||||
now = time.time()
|
||||
while now + TIMEOUT_IOC_STARTUP > time.time():
|
||||
try:
|
||||
read(f'{pvprefix}:IOCREADY', timeout=TIMEOUT_READ)
|
||||
return
|
||||
except TimeoutError:
|
||||
time.sleep(0.5)
|
||||
|
||||
# IOC startup failed in the given time -> Raise an error
|
||||
raise TimeoutError(
|
||||
f'Starting the IOC within {TIMEOUT_IOC_STARTUP} seconds failed.')
|
||||
raise Exception('Start the test IOC first ()')
|
||||
|
||||
Reference in New Issue
Block a user