Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
434374bf
Commit
434374bf
authored
7 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
Task #11020: Hardened checks in test and added assertions on system-provided input
parent
2c41c456
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/ResourceAssignment/ResourceAssigner/lib/schedulers.py
+10
-1
10 additions, 1 deletion
SAS/ResourceAssignment/ResourceAssigner/lib/schedulers.py
SAS/ResourceAssignment/ResourceAssigner/test/t_schedulers.py
+13
-11
13 additions, 11 deletions
SAS/ResourceAssignment/ResourceAssigner/test/t_schedulers.py
with
23 additions
and
12 deletions
SAS/ResourceAssignment/ResourceAssigner/lib/schedulers.py
+
10
−
1
View file @
434374bf
from
datetime
import
datetime
from
datetime
import
datetime
,
timedelta
from
lofar.common.cache
import
cache
from
lofar.common.cache
import
cache
...
@@ -70,6 +70,9 @@ class BasicScheduler(object):
...
@@ -70,6 +70,9 @@ class BasicScheduler(object):
# Any resources that we cannot schedule on for some reason
# Any resources that we cannot schedule on for some reason
self
.
unusable_resources
=
[]
self
.
unusable_resources
=
[]
# Duration must be non-negative or weird stuff will happen
assert
self
.
starttime
<=
self
.
endtime
def
allocate_resources
(
self
,
estimates
):
def
allocate_resources
(
self
,
estimates
):
"""
"""
Tries to allocate resources for the given estimates.
Tries to allocate resources for the given estimates.
...
@@ -471,6 +474,12 @@ class DwellScheduler(PriorityScheduler):
...
@@ -471,6 +474,12 @@ class DwellScheduler(PriorityScheduler):
self
.
max_starttime
=
max_starttime
self
.
max_starttime
=
max_starttime
self
.
duration
=
duration
self
.
duration
=
duration
# Duration must be non-negative or weird stuff will happen
assert
self
.
duration
>=
timedelta
(
0
,
0
,
0
)
# Time span for starttime must be sane
assert
self
.
min_starttime
<=
self
.
max_starttime
def
_new_starttime
(
self
,
starttime
):
def
_new_starttime
(
self
,
starttime
):
"""
"""
Set new start and end time based on the start time
Set new start and end time based on the start time
...
...
This diff is collapsed.
Click to expand it.
SAS/ResourceAssignment/ResourceAssigner/test/t_schedulers.py
+
13
−
11
View file @
434374bf
...
@@ -223,14 +223,6 @@ class BasicSchedulerTest(SchedulerTest):
...
@@ -223,14 +223,6 @@ class BasicSchedulerTest(SchedulerTest):
self
.
scheduler
=
BasicScheduler
(
task_id
,
self
.
fake_resource_availability_checker
,
None
)
self
.
scheduler
=
BasicScheduler
(
task_id
,
self
.
fake_resource_availability_checker
,
None
)
def
verify_claim
(
self
,
claim
):
"""
Verify whether a claim is correct and complete.
"""
self
.
assertIn
(
"
status
"
,
claim
)
self
.
assertIn
(
"
starttime
"
,
claim
)
self
.
assertIn
(
"
endtime
"
,
claim
)
self
.
assertIn
(
"
claim_size
"
,
claim
)
self
.
assertIn
(
"
resource_type_id
"
,
claim
)
def
test_schedule_task
(
self
):
def
test_schedule_task
(
self
):
"""
Whether a task (that fits) can be scheduled.
"""
"""
Whether a task (that fits) can be scheduled.
"""
...
@@ -245,11 +237,21 @@ class BasicSchedulerTest(SchedulerTest):
...
@@ -245,11 +237,21 @@ class BasicSchedulerTest(SchedulerTest):
self
.
assertTrue
(
self
.
fake_ra_database
.
committed
)
self
.
assertTrue
(
self
.
fake_ra_database
.
committed
)
self
.
assertFalse
(
self
.
fake_ra_database
.
rolled_back
)
self
.
assertFalse
(
self
.
fake_ra_database
.
rolled_back
)
# Claim
s
must be present in database
and valid
# Claim must be present in database
claims
=
self
.
fake_ra_database
.
claims
[
0
]
claims
=
self
.
fake_ra_database
.
claims
[
0
]
self
.
assertTrue
(
claims
)
self
.
assertTrue
(
claims
)
for
c
in
claims
:
self
.
assertEqual
(
len
(
claims
),
1
)
self
.
verify_claim
(
c
)
# Claim must be valid
claim
=
claims
[
0
]
task
=
self
.
fake_ra_database
.
tasks
[
0
]
self
.
assertEqual
(
claim
[
"
status
"
],
"
claimed
"
)
self
.
assertEqual
(
claim
[
"
starttime
"
],
task
[
"
starttime
"
])
self
.
assertEqual
(
claim
[
"
endtime
"
],
task
[
"
endtime
"
])
self
.
assertEqual
(
claim
[
"
claim_size
"
],
512
)
self
.
assertEqual
(
claim
[
"
resource_type_id
"
],
FakeResourceAvailabilityChecker
.
resource_types
[
"
bandwidth
"
])
def
test_multiple_resources
(
self
):
def
test_multiple_resources
(
self
):
"""
Whether a task (that fits) can be scheduled.
"""
"""
Whether a task (that fits) can be scheduled.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment