Skip to content

Commit

Permalink
fix: Python server is not correctly starting in integration tests (#2706
Browse files Browse the repository at this point in the history
)

Signed-off-by: Oleksii Moskalenko <moskalenko.alexey@gmail.com>
  • Loading branch information
pyalex authored May 16, 2022
1 parent 095dfd6 commit 7583a0b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sdk/python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,11 @@ def pytest_generate_tests(metafunc: pytest.Metafunc):

@pytest.fixture(scope="session")
def python_server(environment):
assert not _check_port_open("localhost", environment.get_local_server_port())

proc = Process(
target=start_test_local_server,
args=(environment.feature_store.repo_path, environment.get_local_server_port()),
daemon=True,
)
if (
environment.python_feature_server
Expand All @@ -298,6 +299,15 @@ def python_server(environment):
if proc.is_alive():
proc.kill()

# wait server to free the port
wait_retry_backoff(
lambda: (
None,
not _check_port_open("localhost", environment.get_local_server_port()),
),
timeout_secs=30,
)


def _check_port_open(host, port) -> bool:
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
Expand Down

0 comments on commit 7583a0b

Please sign in to comment.