Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AIG-public
Cobalt
Commits
bef6c753
Commit
bef6c753
authored
Nov 03, 2016
by
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/Components/cqm.py
View file @
bef6c753
...
@@ -3848,13 +3848,20 @@ class QueueManager(Component):
...
@@ -3848,13 +3848,20 @@ class QueueManager(Component):
if
updates
.
has_key
(
"queue"
):
if
updates
.
has_key
(
"queue"
):
new_q_name
=
updates
[
"queue"
]
new_q_name
=
updates
[
"queue"
]
if
new_q_name
not
in
self
.
Queues
:
if
new_q_name
not
in
self
.
Queues
:
logger
.
error
(
"attempted to move a job to non-existent queue '%s'"
%
new_q_name
)
logger
.
error
(
"attempted to move a job to non-existent queue '%s'"
,
raise
QueueError
,
"Error: queue '%s' does not exist"
%
new_q_name
new_q_name
)
raise
QueueError
(
"Error: queue '%s' does not exist"
%
new_q_name
)
for
job
in
joblist
:
for
job
in
joblist
:
if
job
.
is_active
or
job
.
has_completed
:
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
:
for
job
in
joblist
:
...
...
testsuite/TestCobalt/TestComponents/test_cqm.py
View file @
bef6c753
...
@@ -29,6 +29,7 @@ config_fp.close()
...
@@ -29,6 +29,7 @@ config_fp.close()
import
ConfigParser
import
ConfigParser
from
nose.tools
import
timed
,
TimeExpired
from
nose.tools
import
timed
,
TimeExpired
from
nose.tools
import
raises
import
os
import
os
import
os.path
import
os.path
import
pwd
import
pwd
...
@@ -332,7 +333,8 @@ class TestCQMJobManagement (TestCQMComponent):
...
@@ -332,7 +333,8 @@ class TestCQMJobManagement (TestCQMComponent):
group_name
=
grp
.
getgrgid
(
os
.
getegid
()).
gr_name
#group we're running under for verification check.
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'
:
"default"
}])
self
.
cqm
.
add_queues
([{
'name'
:
"restricted-group"
}])
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
}])
self
.
cqm
.
add_jobs
([{
'queue'
:
"default"
,
'jobname'
:
"hello"
,
'user'
:
pwd
.
getpwuid
(
os
.
getuid
()).
pw_name
}])
try
:
try
:
...
@@ -349,6 +351,37 @@ class TestCQMJobManagement (TestCQMComponent):
...
@@ -349,6 +351,37 @@ class TestCQMJobManagement (TestCQMComponent):
#assert len(r) == 1
#assert len(r) == 1
#assert r[0].queue == "restricted-group"
#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
):
class
Task
(
Data
):
required_fields
=
[
'jobid'
,
'location'
,
'user'
,
'cwd'
,
'executable'
,
'args'
,
]
required_fields
=
[
'jobid'
,
'location'
,
'user'
,
'cwd'
,
'executable'
,
'args'
,
]
fields
=
Data
.
fields
+
[
"id"
,
"jobid"
,
"location"
,
"size"
,
"mode"
,
"user"
,
"executable"
,
"args"
,
"env"
,
"cwd"
,
"umask"
,
fields
=
Data
.
fields
+
[
"id"
,
"jobid"
,
"location"
,
"size"
,
"mode"
,
"user"
,
"executable"
,
"args"
,
"env"
,
"cwd"
,
"umask"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment