-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: job queue test failures (#8843)
* hotfix for test * ensure task completion * remove comment * update test helpers * default timeout (cherry picked from commit 08dfa43)
- Loading branch information
1 parent
a74685f
commit 1fc1496
Showing
3 changed files
with
35 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
import time | ||
|
||
import pytest | ||
|
||
from determined.common import api | ||
|
||
|
||
def wait_for_task_state( | ||
test_session: api.Session, | ||
task_id: str, | ||
expected_state: api.bindings.v1GenericTaskState, | ||
timeout: int, | ||
) -> bool: | ||
timeout: int = 30, | ||
) -> None: | ||
deadline = time.time() + timeout | ||
while time.time() < deadline: | ||
resp = api.bindings.get_GetTask(test_session, taskId=task_id) | ||
if expected_state == resp.task.taskState: | ||
return True | ||
return | ||
time.sleep(0.1) | ||
return False | ||
pytest.fail(f"task failed to complete after {timeout} seconds") | ||
|
||
|
||
def wait_for_task_start( | ||
test_session: api.Session, | ||
task_id: str, | ||
timeout: int, | ||
) -> bool: | ||
timeout: int = 30, | ||
) -> None: | ||
deadline = time.time() + timeout | ||
while time.time() < deadline: | ||
resp = api.bindings.get_GetTask(test_session, taskId=task_id) | ||
if resp.task.allocations[0].state == api.bindings.taskv1State.RUNNING: | ||
return True | ||
return | ||
time.sleep(0.1) | ||
return False | ||
pytest.fail(f"task failed to start after {timeout} seconds") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters