Skip to content

Commit

Permalink
Merge pull request #1371 from dagardner-nv/david-fea-sherlock-http-te…
Browse files Browse the repository at this point in the history
…st-ci-1370

Draft: fix for test_simple_request
  • Loading branch information
dagardner-nv authored Nov 18, 2023
2 parents 8f7f4a0 + 1b3f4ec commit a940471
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tests/common/test_http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import time
import typing
from http import HTTPStatus
from unittest import mock
Expand Down Expand Up @@ -83,6 +84,18 @@ def check_server():

parse_fn.assert_called_once_with(payload)

if use_callback:
# Since the callback is executed asynchronously, we don't know when it will be called.
expected_call = mock.call(False, "")

max_retries = 300
attempt = 0
while expected_call not in callback_fn.mock_calls and attempt < max_retries:
attempt += 1
time.sleep(0.1)

callback_fn.assert_called_once_with(False, "")

if use_context_mgr:
with HttpServer(parse_fn=parse_fn, port=port, endpoint=endpoint, method=method,
num_threads=num_threads) as server:
Expand All @@ -100,11 +113,6 @@ def check_server():

assert not server.is_running()

# Since the callback is executed asynchronously, we don't know when it will be called.
# However server.stop() will wait for the callback to be executed.
if use_callback:
callback_fn.assert_called_once_with(False, "")


def test_constructor_errors():
with pytest.raises(RuntimeError):
Expand Down

0 comments on commit a940471

Please sign in to comment.