Skip to content

Commit a000ba3

Browse files
Shore up timing-dependent tests
1 parent 3a0cebe commit a000ba3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tests/lib/test_openai_priority_loadbalancer.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ def backends_tiered_priority(backends_factory) -> List[Backend]:
102102

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

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

111111
@pytest.fixture
112112
def priority_backend_0_throttling(backends_factory) -> List[Backend]:
@@ -233,7 +233,7 @@ def test_loadbalancer_instantiation_with_all_throttling(self, all_backends_throt
233233

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

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

254254
time.sleep(6)
255255

@@ -455,7 +455,8 @@ def test_async_loadbalancer_instantiation_with_all_throttling(self, all_backends
455455

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

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

476477
time.sleep(6)
477478

0 commit comments

Comments
 (0)