Skip to content
Snippets Groups Projects
Commit 6a6cd5a8 authored by Millian Poquet's avatar Millian Poquet
Browse files

[test] run redis from pytest

parent 5dc8db51
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3 #!/usr/bin/env python3
from collections import namedtuple
import glob import glob
import pytest
import subprocess
from collections import namedtuple
from os.path import abspath, basename from os.path import abspath, basename
Workload = namedtuple('Workload', ['name', 'filename']) Workload = namedtuple('Workload', ['name', 'filename'])
...@@ -60,3 +62,23 @@ def pytest_generate_tests(metafunc): ...@@ -60,3 +62,23 @@ def pytest_generate_tests(metafunc):
if 'upper_llh_threshold' in metafunc.fixturenames: if 'upper_llh_threshold' in metafunc.fixturenames:
metafunc.parametrize('upper_llh_threshold', [60]) metafunc.parametrize('upper_llh_threshold', [60])
@pytest.fixture(scope="session", autouse=True)
def manage_redis_server(request):
print('Trying to run a redis-server...')
proc = subprocess.Popen('redis-server', stdout=subprocess.PIPE)
try:
out, _ = proc.communicate(timeout=1)
if 'Address already in use' in str(out):
print("Could not run redis-server (address already in use).")
print("Assuming that the process using the TCP port is another redis-server instance and going on.")
else:
raise Exception("Could not run redis-server (unhandled reason), aborting.")
except subprocess.TimeoutExpired:
print('redis-server has been running for 1 second.')
print('Assuming redis-server has started successfully and going on.')
def on_finalize():
print('Killing the spawned redis-server (if any)...')
proc.kill()
request.addfinalizer(on_finalize)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment