Skip to content

Commit

Permalink
Test all possible PBS job states (#7307)
Browse files Browse the repository at this point in the history
  • Loading branch information
berland authored Feb 29, 2024
1 parent 983719d commit d6da218
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
22 changes: 20 additions & 2 deletions src/ert/scheduler/openpbs_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@
logger = logging.getLogger(__name__)

_POLL_PERIOD = 2.0 # seconds
JobState = Literal["B", "E", "F", "H", "M", "Q", "R", "S", "T", "U", "W", "X"]
JobState = Literal[
"B", # Begun
"E", # Exiting with or without errors
"F", # Finished (completed, failed or deleted)
"H", # Held,
"M", # Moved to another server
"Q", # Queued
"R", # Running
"S", # Suspended
"T", # Transiting
"U", # User suspended
"W", # Waiting
"X", # Expired (subjobs only)
]
JOBSTATE_INITIAL: JobState = "Q"

QSUB_INVALID_CREDENTIAL: int = 171
Expand Down Expand Up @@ -45,8 +58,13 @@ class RunningJob(BaseModel):
job_state: Literal["R"]


class IgnoredJobstates(BaseModel):
job_state: Literal["B", "E", "M", "S", "T", "U", "W", "X"]


AnyJob = Annotated[
Union[FinishedJob, QueuedJob, RunningJob], Field(discriminator="job_state")
Union[FinishedJob, QueuedJob, RunningJob, IgnoredJobstates],
Field(discriminator="job_state"),
]


Expand Down
3 changes: 2 additions & 1 deletion tests/unit_tests/scheduler/test_openpbs_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
QSUB_INVALID_CREDENTIAL,
QSUB_PREMATURE_END_OF_MESSAGE,
FinishedEvent,
JobState,
StartedEvent,
_Stat,
)


@given(st.lists(st.sampled_from(["H", "Q", "R", "F"])))
@given(st.lists(st.sampled_from(JobState.__args__)))
async def test_events_produced_from_jobstate_updates(jobstate_sequence: List[str]):
# Determine what to expect from the sequence:
started = False
Expand Down

0 comments on commit d6da218

Please sign in to comment.