Commit 73d39d4c authored by Paul Rich's avatar Paul Rich
Browse files

Fix for qstat display bug if a job is stuck in a terminal state.

parent 1415adfb
......@@ -2818,6 +2818,7 @@ class Job (StateMachine):
self.trigger_event('Release', {'type' : 'dep'})
def __get_job_state(self):
'''Translate the statemachine state into qstat-friendly states.'''
if self._sm_state in ('Ready', 'Preempted'):
if self.max_running:
return "maxrun_hold"
......@@ -2832,20 +2833,21 @@ class Job (StateMachine):
else:
return "dep_hold"
return "admin_hold"
if self._sm_state in ['Job_Prologue','Job_Prologue_Retry',
if self._sm_state in ['Job_Prologue', 'Job_Prologue_Retry',
'Resource_Prologue', 'Resource_Prologue_Retry', 'Run_Retry']:
return "starting"
if self._sm_state == 'Running':
return "running"
if self._sm_state in ['Kill_Retry', 'Killing']:
return "killing"
if self._sm_state in ['Preempt_Retry', 'Preempting',
if self._sm_state in ['Preempt_Retry', 'Preempting',
'Preempt_Finalize_Retry', 'Preempt_Epilogue']:
return 'preempting'
if self._sm_state == 'Preempted':
return 'preempted'
if self._sm_state in ['Job_Prologue_Retry_Release', 'Resource_Prologue_Retry_Release', 'Finalize_Retry',
'Resource_Epilogue','Resource_Epilogue_Retry', 'Job_Epilogue',
if self._sm_state in ['Job_Prologue_Retry_Release',
'Resource_Prologue_Retry_Release', 'Finalize_Retry',
'Resource_Epilogue', 'Resource_Epilogue_Retry', 'Job_Epilogue',
'Job_Epilogue_Retry']:
return "exiting"
if self._sm_state == 'Terminal':
......@@ -2871,12 +2873,13 @@ class Job (StateMachine):
return "R"
if self._sm_state in ['Kill_Retry', 'Killing']:
return "K"
if self._sm_state in ['Preempt_Retry', 'Preempting',
if self._sm_state in ['Preempt_Retry', 'Preempting',
'Preempt_Finalize_Retry', 'Preempt_Epilogue', 'Preempted']:
return 'P'
if self._sm_state in ['Job_Prologue_Retry_Release', 'Resource_Prologue_Retry_Release', 'Finalize_Retry',
if self._sm_state in ['Job_Prologue_Retry_Release',
'Resource_Prologue_Retry_Release', 'Finalize_Retry',
'Resource_Epilogue', 'Resource_Epilogue_Retry', 'Job_Epilogue',
'Job_Epilogue_Retry' 'Terminal']:
'Job_Epilogue_Retry', 'Terminal']:
return 'E'
raise DataStateError, "unknown state: %s" % (self._sm_state,)
......
......@@ -40,6 +40,8 @@ import types
import unittest
import xmlrpclib
from mock import patch
import Cobalt.Components.cqm
from Cobalt.Components.base import Component, exposed, automatic, query
from Cobalt.Components.cqm import QueueManager, Signal_Map
......@@ -3594,3 +3596,45 @@ class TestCQMIntegration (CQMIntegrationTestBase):
del self.taskman
CQMIntegrationTestBase.teardown(self)
class TestJobStatuses(object):
states = {'Ready': ('queued', 'Q'),
'Preempted': ('preempted', 'P'),
'Job_Prologue': ('starting', 'R'),
'Job_Prologue_Retry': ('starting', 'R'),
'Resource_Prologue':('starting', 'R'),
'Resource_Prologue_Retry': ('starting', 'R'),
'Run_Retry': ('starting', 'R'),
'Running': ('running', 'R'),
'Kill_Retry': ('killing', 'K'),
'Killing': ('killing', 'K'),
'Preempt_Retry': ('preempting', 'P'),
'Preempting': ('preempting', 'P'),
'Preempt_Finalize_Retry': ('preempting', 'P'),
'Preempt_Epilogue': ('preempting', 'P'),
'Job_Prologue_Retry_Release': ('exiting', 'E'),
'Resource_Prologue_Retry_Release': ('exiting', 'E'),
'Finalize_Retry': ('exiting', 'E'),
'Resource_Epilogue': ('exiting', 'E'),
'Resource_Epilogue_Retry': ('exiting', 'E'),
'Job_Epilogue': ('exiting', 'E'),
'Job_Epilogue_Retry': ('exiting', 'E'),
'Terminal': ('done', 'E')
}
def setup(self):
spec = {}
self.job = Cobalt.Components.cqm.Job(spec)
def teardown(self):
del self.job
def test_display_states(self):
for state, printable_status in self.states.items():
with patch.object(Cobalt.Components.cqm.Job, '_sm_state', state):
assert self.job.state == printable_status[0], ("Bad State %s: Expected %s, got %s" %
(state, printable_status[0], self.job.state))
assert self.job.short_state == printable_status[1], ("Bad State %s: Expected %s, got %s" %
(state, printable_status[1], self.job.short_state))
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