Skip to content

Commit

Permalink
Shore up timing-dependent tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simonkurtz-MSFT committed Oct 18, 2024
1 parent 3a0cebe commit a000ba3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tests/lib/test_openai_priority_loadbalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ def backends_tiered_priority(backends_factory) -> List[Backend]:

@pytest.fixture
def backends_0_and_1_throttling(backends_factory) -> List[Backend]:
return backends_factory([1, 1, 1], [True, True, False], [3, 1, None], [None, None, None], [None, None, None])
return backends_factory([1, 1, 1], [True, True, False], [3, 2, None], [None, None, None], [None, None, None])

@pytest.fixture
def all_backends_throttling(backends_factory) -> List[Backend]:
return backends_factory([1, 1, 1], [True, True, True], [3, 1, 5], [None, None, None], [None, None, None])
return backends_factory([1, 1, 1], [True, True, True], [4, 2, 6], [None, None, None], [None, None, None])

@pytest.fixture
def priority_backend_0_throttling(backends_factory) -> List[Backend]:
Expand Down Expand Up @@ -233,7 +233,7 @@ def test_loadbalancer_instantiation_with_all_throttling(self, all_backends_throt

response: httpx.Response = _lb._return_429()
assert response.status_code == 429
assert response.headers["Retry-After"] == "1"
assert response.headers["Retry-After"] in ["1", "2"] # could be either value depending on test runtime

@pytest.mark.skipif(SKIP_LONG_RUNNING_TESTS is True, reason = "Flag is set to skip long tests.")
@pytest.mark.loadbalancer
Expand All @@ -249,7 +249,7 @@ def test_loadbalancer_instantiation_with_all_throttling_then_resetting(self, all
selected_index = _lb._get_backend_index()
assert selected_index == -1
delay = _lb._get_soonest_retry_after()
assert delay == 1
assert delay in [1, 2] # could be either value depending on test runtime

time.sleep(6)

Expand Down Expand Up @@ -455,7 +455,8 @@ def test_async_loadbalancer_instantiation_with_all_throttling(self, all_backends

response: httpx.Response = _lb._return_429()
assert response.status_code == 429
assert response.headers["Retry-After"] == "1"
assert response.headers["Retry-After"] in ["1", "2"] # could be either value depending on test runtime


@pytest.mark.skipif(SKIP_LONG_RUNNING_TESTS is True, reason = "Flag is set to skip long tests.")
@pytest.mark.async_loadbalancer
Expand All @@ -471,7 +472,7 @@ def test_async_loadbalancer_instantiation_with_all_throttling_then_resetting(sel
selected_index = _lb._get_backend_index()
assert selected_index == -1
delay = _lb._get_soonest_retry_after()
assert delay == 1
assert delay in [1, 2] # could be either value depending on test runtime

time.sleep(6)

Expand Down

0 comments on commit a000ba3

Please sign in to comment.