Commit bef6c753 authored by Paul Rich's avatar Paul Rich
Browse files

Merge branch '40-job-cleanup-error' into 'master'

40 job cleanup error

Closes #40

See merge request !26
parents c5ea709a 3efbdc0c
......@@ -3848,13 +3848,20 @@ class QueueManager(Component):
if updates.has_key("queue"):
new_q_name = updates["queue"]
if new_q_name not in self.Queues:
logger.error("attempted to move a job to non-existent queue '%s'" % new_q_name)
raise QueueError, "Error: queue '%s' does not exist" % new_q_name
logger.error("attempted to move a job to non-existent queue '%s'",
new_q_name)
raise QueueError("Error: queue '%s' does not exist" % new_q_name)
for job in joblist:
if job.is_active or job.has_completed:
raise QueueError, "job %d is running; it cannot be moved" % job.jobid
raise QueueError("job %d is running; it cannot be moved" % job.jobid)
if updates.has_key("score"):
try:
updates['score'] = float(updates['score'])
except ValueError:
logger.error('new score of %s cannot be converted to a floating point value',
updates['score'])
raise QueueError("Bad new score value.")
for job in joblist:
......
......@@ -29,6 +29,7 @@ config_fp.close()
import ConfigParser
from nose.tools import timed, TimeExpired
from nose.tools import raises
import os
import os.path
import pwd
......@@ -332,7 +333,8 @@ class TestCQMJobManagement (TestCQMComponent):
group_name = grp.getgrgid(os.getegid()).gr_name #group we're running under for verification check.
self.cqm.add_queues([{'name':"default"}])
self.cqm.add_queues([{'name':"restricted-group"}])
self.cqm.set_queues([{'name':"restricted-group"}], {'groups':'bar'})
self.cqm.set_queues([{'name':"restricted-group"}],
{'groups':'ThisGroupDefinitelyDoesntExist'})
self.cqm.add_jobs([{'queue':"default", 'jobname':"hello", 'user':pwd.getpwuid(os.getuid()).pw_name}])
try:
......@@ -349,6 +351,37 @@ class TestCQMJobManagement (TestCQMComponent):
#assert len(r) == 1
#assert r[0].queue == "restricted-group"
def test_set_job_score_type_from_float(self):
# Ensure that job scores are set to a float and are appropriately cast
self.cqm.add_queues([{'tag':"queue", 'name':"default"}])
self.cqm.add_jobs([{'tag':"job", 'queue':"default"}])
self.cqm.set_jobs([{'tag':"job", 'queue':"*"}], {'score':0.1})
job = self.cqm.get_jobs([{'tag':"job", 'queue':"default"}])[0]
assert type(job.score) == type(0.0), "Job score not float type when set from float"
def test_set_job_score_type_from_int(self):
# Ensure that job scores are set to a float and are appropriately cast
self.cqm.add_queues([{'tag':"queue", 'name':"default"}])
self.cqm.add_jobs([{'tag':"job", 'queue':"default"}])
self.cqm.set_jobs([{'tag':"job", 'queue':"*"}], {'score':1})
job = self.cqm.get_jobs([{'tag':"job", 'queue':"default"}])[0]
assert type(job.score) == type(0.0), "Job score not float type when set from int"
def test_set_job_score_type_from_string(self):
# Ensure that job scores are set to a float and are appropriately cast
self.cqm.add_queues([{'tag':"queue", 'name':"default"}])
self.cqm.add_jobs([{'tag':"job", 'queue':"default"}])
self.cqm.set_jobs([{'tag':"job", 'queue':"*"}], {'score': "0.1"})
job = self.cqm.get_jobs([{'tag':"job", 'queue':"default"}])[0]
assert type(job.score) == type(0.0), "Job score not float type when set from string"
@raises(Cobalt.Exceptions.QueueError)
def test_set_job_score_bad_string(self):
# Refuse to queue if score cannot be cast to a float.
self.cqm.add_queues([{'tag':"queue", 'name':"default"}])
self.cqm.add_jobs([{'tag':"job", 'queue':"default"}])
self.cqm.set_jobs([{'tag':"job", 'queue':"*"}], {'score': "NotANumber"})
class Task (Data):
required_fields = ['jobid', 'location', 'user', 'cwd', 'executable', 'args', ]
fields = Data.fields + ["id", "jobid", "location", "size", "mode", "user", "executable", "args", "env", "cwd", "umask",
......
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