Commit 1eaddbc6 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Add new constant for pending job status



This constant contains the job status' “queued”, “waiting” and
“cancelled”.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 11f53fdb
......@@ -1498,17 +1498,19 @@ JOB_STATUS_RUNNING = "running"
JOB_STATUS_CANCELED = "canceled"
JOB_STATUS_SUCCESS = "success"
JOB_STATUS_ERROR = "error"
JOBS_PENDING = frozenset([
JOB_STATUS_QUEUED,
JOB_STATUS_WAITING,
JOB_STATUS_CANCELING,
])
JOBS_FINALIZED = frozenset([
JOB_STATUS_CANCELED,
JOB_STATUS_SUCCESS,
JOB_STATUS_ERROR,
])
JOB_STATUS_ALL = frozenset([
JOB_STATUS_QUEUED,
JOB_STATUS_WAITING,
JOB_STATUS_CANCELING,
JOB_STATUS_RUNNING,
]) | JOBS_FINALIZED
]) | JOBS_PENDING | JOBS_FINALIZED
# OpCode status
# not yet finalized
......
......@@ -80,17 +80,19 @@ JOB_STATUS_RUNNING = "running"
JOB_STATUS_CANCELED = "canceled"
JOB_STATUS_SUCCESS = "success"
JOB_STATUS_ERROR = "error"
JOB_STATUS_PENDING = frozenset([
JOB_STATUS_QUEUED,
JOB_STATUS_WAITING,
JOB_STATUS_CANCELING,
])
JOB_STATUS_FINALIZED = frozenset([
JOB_STATUS_CANCELED,
JOB_STATUS_SUCCESS,
JOB_STATUS_ERROR,
])
JOB_STATUS_ALL = frozenset([
JOB_STATUS_QUEUED,
JOB_STATUS_WAITING,
JOB_STATUS_CANCELING,
JOB_STATUS_RUNNING,
]) | JOB_STATUS_FINALIZED
]) | JOB_STATUS_PENDING | JOB_STATUS_FINALIZED
# Legacy name
JOB_STATUS_WAITLOCK = JOB_STATUS_WAITING
......
......@@ -85,6 +85,11 @@ class TestConstants(unittest.TestCase):
self.failUnless(set(constants.DISK_DT_DEFAULTS.keys()) ==
constants.DISK_TEMPLATES)
def testJobStatus(self):
self.assertFalse(constants.JOBS_PENDING & constants.JOBS_FINALIZED)
self.assertFalse(constants.JOBS_PENDING - constants.JOB_STATUS_ALL)
self.assertFalse(constants.JOBS_FINALIZED - constants.JOB_STATUS_ALL)
class TestExportedNames(unittest.TestCase):
_VALID_NAME_RE = re.compile(r"^[A-Z][A-Z0-9_]+$")
......
......@@ -114,6 +114,7 @@ class TestConstants(unittest.TestCase):
self.assertEqual(client.JOB_STATUS_CANCELED, constants.JOB_STATUS_CANCELED)
self.assertEqual(client.JOB_STATUS_SUCCESS, constants.JOB_STATUS_SUCCESS)
self.assertEqual(client.JOB_STATUS_ERROR, constants.JOB_STATUS_ERROR)
self.assertEqual(client.JOB_STATUS_PENDING, constants.JOBS_PENDING)
self.assertEqual(client.JOB_STATUS_FINALIZED, constants.JOBS_FINALIZED)
self.assertEqual(client.JOB_STATUS_ALL, constants.JOB_STATUS_ALL)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment