Skip to content

Commit

Permalink
Merge pull request DIRACGrid#7276 from fstagni/80_fixes68
Browse files Browse the repository at this point in the history
[8.0] JobStatus: allow WAITING -> KILLED
  • Loading branch information
fstagni authored Nov 7, 2023
2 parents 61ba60a + f3380df commit 157cd6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/DIRAC/WorkloadManagementSystem/Client/JobStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self, state):
RUNNING: State(8, [STALLED, DONE, FAILED, RESCHEDULED, COMPLETING, KILLED, RECEIVED], defState=RUNNING),
RESCHEDULED: State(7, [WAITING, RECEIVED, DELETED, FAILED], defState=RESCHEDULED),
MATCHED: State(6, [RUNNING, FAILED, RESCHEDULED, KILLED], defState=MATCHED),
WAITING: State(5, [MATCHED, RESCHEDULED, DELETED], defState=WAITING),
WAITING: State(5, [MATCHED, RESCHEDULED, DELETED, KILLED], defState=WAITING),
STAGING: State(4, [CHECKING, WAITING, FAILED, KILLED], defState=STAGING),
SCOUTING: State(3, [CHECKING, FAILED, STALLED, KILLED], defState=SCOUTING),
CHECKING: State(2, [SCOUTING, STAGING, WAITING, RESCHEDULED, FAILED, DELETED], defState=CHECKING),
Expand Down
17 changes: 11 additions & 6 deletions tests/Integration/WorkloadManagementSystem/Test_JobDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@

from datetime import datetime, timedelta
from unittest.mock import MagicMock, patch
import pytest

import DIRAC
import pytest

DIRAC.initialize() # Initialize configuration

from DIRAC import gLogger, S_OK
from DIRAC.WorkloadManagementSystem.Client import JobStatus
from DIRAC.WorkloadManagementSystem.Client import JobMinorStatus
from DIRAC import S_OK, gLogger
from DIRAC.WorkloadManagementSystem.Client import JobMinorStatus, JobStatus

# sut
from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB
Expand Down Expand Up @@ -317,14 +316,20 @@ def test_setJobsMajorStatus(jobDB):
assert res["OK"] is True, res["Message"]
res = jobDB.getJobsAttributes([jobID_1, jobID_2], ["Status"])
assert res["OK"] is True, res["Message"]
assert res["Value"] == {jobID_1: {"Status": JobStatus.WAITING}, jobID_2: {"Status": JobStatus.CHECKING}}
assert res["Value"] == {jobID_1: {"Status": JobStatus.KILLED}, jobID_2: {"Status": JobStatus.CHECKING}}

res = jobDB.setJobsMajorStatus([jobID_1], JobStatus.KILLED, force=True)
res = jobDB.setJobsMajorStatus([jobID_1], JobStatus.RUNNING)
assert res["OK"] is True, res["Message"]
res = jobDB.getJobsAttributes([jobID_1, jobID_2], ["Status"])
assert res["OK"] is True, res["Message"]
assert res["Value"] == {jobID_1: {"Status": JobStatus.KILLED}, jobID_2: {"Status": JobStatus.CHECKING}}

res = jobDB.setJobsMajorStatus([jobID_1], JobStatus.RUNNING, force=True)
assert res["OK"] is True, res["Message"]
res = jobDB.getJobsAttributes([jobID_1, jobID_2], ["Status"])
assert res["OK"] is True, res["Message"]
assert res["Value"] == {jobID_1: {"Status": JobStatus.RUNNING}, jobID_2: {"Status": JobStatus.CHECKING}}


def test_attributes(jobDB):
res = jobDB.insertNewJobIntoDB(jdl, "owner_1", "/DN/OF/owner", "ownerGroup", "someSetup")
Expand Down

0 comments on commit 157cd6c

Please sign in to comment.