Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
beat
beat.web
Commits
edf87c0a
Commit
edf87c0a
authored
8 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[backend] Implements successful experiment scheduling and execution testing
parent
caf71f9f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!194
Scheduler
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/backend/tests.py
+63
-21
63 additions, 21 deletions
beat/web/backend/tests.py
with
63 additions
and
21 deletions
beat/web/backend/tests.py
+
63
−
21
View file @
edf87c0a
...
@@ -43,11 +43,12 @@ from guardian.shortcuts import get_perms
...
@@ -43,11 +43,12 @@ from guardian.shortcuts import get_perms
from
..common.testutils
import
BaseTestCase
as
APITestCase
from
..common.testutils
import
BaseTestCase
as
APITestCase
from
..experiments.models
import
Experiment
,
Block
from
..experiments.models
import
Experiment
,
Block
from
..algorithms.models
import
Algorithm
from
..algorithms.models
import
Algorithm
from
..utils.management.commands
import
install
from
..statistics.models
import
HourlyStatistics
from
.models
import
Queue
,
Worker
,
Slot
,
Environment
,
Job
,
JobSplit
,
Result
from
.models
import
Queue
,
Worker
,
Slot
,
Environment
,
Job
,
JobSplit
,
Result
from
.utils
import
cleanup_cache
,
dump_backend
,
setup_backend
from
.utils
import
cleanup_cache
,
dump_backend
,
setup_backend
from
.management.commands
import
qsetup
from
.management.commands
import
qsetup
from
..utils.management.commands
import
install
from
.schedule
import
schedule
from
.schedule
import
schedule
...
@@ -733,8 +734,21 @@ class BackendSetup(BaseBackendTestCase):
...
@@ -733,8 +734,21 @@ class BackendSetup(BaseBackendTestCase):
class
Scheduling
(
BaseBackendTestCase
):
class
Scheduling
(
BaseBackendTestCase
):
def
check_stats_success
(
self
,
split
):
assert
abs
(
split
.
job
.
block
.
speed_up_real
()
-
1.0
)
<
0.1
assert
abs
(
split
.
job
.
block
.
speed_up_maximal
()
-
1.0
)
<
0.1
assert
split
.
job
.
block
.
linear_execution_time
()
>
0.0
assert
split
.
job
.
block
.
queuing_time
()
>
0.0
assert
split
.
job
.
block
.
stdout
()
is
None
assert
split
.
job
.
block
.
stderr
()
is
None
assert
split
.
job
.
block
.
error_report
()
is
None
def
test_success
(
self
):
def
test_success
(
self
):
current_stats
=
HourlyStatistics
.
objects
.
count
()
fullname
=
'
user/user/single/1/single
'
fullname
=
'
user/user/single/1/single
'
xp
=
Experiment
.
objects
.
get
(
name
=
fullname
.
split
(
os
.
sep
)[
-
1
])
xp
=
Experiment
.
objects
.
get
(
name
=
fullname
.
split
(
os
.
sep
)[
-
1
])
...
@@ -743,6 +757,8 @@ class Scheduling(BaseBackendTestCase):
...
@@ -743,6 +757,8 @@ class Scheduling(BaseBackendTestCase):
self
.
check_single
(
xp
)
self
.
check_single
(
xp
)
# schedules the first runnable block
# schedules the first runnable block
assert
xp
.
blocks
.
first
().
job
.
runnable_date
is
not
None
assert
xp
.
blocks
.
last
().
job
.
runnable_date
is
None
schedule
()
schedule
()
assigned_splits
=
JobSplit
.
objects
.
filter
(
worker__isnull
=
False
)
assigned_splits
=
JobSplit
.
objects
.
filter
(
worker__isnull
=
False
)
...
@@ -776,37 +792,63 @@ class Scheduling(BaseBackendTestCase):
...
@@ -776,37 +792,63 @@ class Scheduling(BaseBackendTestCase):
self
.
assertEqual
(
split
.
job
.
block
.
status
,
Block
.
CACHED
)
self
.
assertEqual
(
split
.
job
.
block
.
status
,
Block
.
CACHED
)
self
.
assertEqual
(
split
.
job
.
block
.
experiment
.
status
,
Experiment
.
RUNNING
)
self
.
assertEqual
(
split
.
job
.
block
.
experiment
.
status
,
Experiment
.
RUNNING
)
'''
# checks the number of statistics objects has increased by 1
nose.tools.eq_(block.result.stats.as_dict(), result.stats)
self
.
assertEqual
(
HourlyStatistics
.
objects
.
count
(),
current_stats
+
1
)
self
.
check_stats_success
(
split
)
self.assertEqual(worker.available_cores(), CORES)
# assert we have no database traces after the block is done
self
.
assertEqual
(
Job
.
objects
.
filter
(
block
=
split
.
job
.
block
).
count
(),
0
)
self
.
assertEqual
(
JobSplit
.
objects
.
filter
(
job
=
split
.
job
).
count
(),
0
)
self
.
assertEqual
(
Result
.
objects
.
filter
(
job__isnull
=
True
).
count
(),
0
)
self
.
assertEqual
(
worker
.
available_cores
(),
qsetup
.
CORES
)
# since this job was successful, the next one should be ready to run
# since this job was successful, the next one should be ready to run
# schedules the last block of the experiment
# schedules the last block of the experiment
jobs = s.jobs_to_run()
assert
xp
.
blocks
.
last
().
job
.
runnable_date
is
not
None
self.assertEqual(len(jobs), 1)
schedule
()
job, worker = jobs.popitem(last=False)
assigned_splits
=
JobSplit
.
objects
.
filter
(
worker__isnull
=
False
)
self
.
assertEqual
(
assigned_splits
.
count
(),
1
)
split
=
assigned_splits
.
first
()
self
.
assertEqual
(
split
.
job
.
block
.
experiment
,
xp
)
self
.
assertEqual
(
split
.
job
.
block
.
name
,
'
analysis
'
)
self
.
assertEqual
(
split
.
worker
,
worker
)
self
.
assertEqual
(
worker
.
name
,
qsetup
.
HOSTNAME
)
self
.
assertEqual
(
worker
.
available_cores
(),
qsetup
.
CORES
)
check_block_assignment(job, worker, xp,
'
analysis
'
, HOSTNAME, CORES)
# simulate job start on worker
split
.
start
()
self
.
assertEqual
(
split
.
job
.
status
,
Job
.
PROCESSING
)
self
.
assertEqual
(
split
.
job
.
block
.
status
,
Block
.
PROCESSING
)
self
.
assertEqual
(
split
.
job
.
block
.
experiment
.
status
,
Experiment
.
RUNNING
)
check_start_job(s, job, worker, xp)
self
.
assertEqual
(
worker
.
available_cores
(),
qsetup
.
CORES
-
1
)
self.assertEqual(worker.available_cores(), CORES-1)
# no job can be run right now
# no job can be run right now
jobs = s.jobs_to_run()
schedule
()
self.assertEqual(len(jobs), 0)
assigned_splits
=
JobSplit
.
objects
.
filter
(
worker__isnull
=
False
,
status
=
Job
.
QUEUED
)
self
.
assertEqual
(
assigned_splits
.
count
(),
0
)
# simulate end job signal
# simulate end job signal
check_end_job_successfuly(s, job)
split
.
end
(
Result
(
status
=
0
))
# checks the number of statistics objects has increased by 1
self
.
assertEqual
(
HourlyStatistics
.
objects
.
count
(),
current_stats
+
1
)
# no more jobs scheduled
self
.
assertEqual
(
split
.
job
.
status
,
Job
.
COMPLETED
)
jobs = s.jobs_to_run(
)
self
.
assertEqual
(
split
.
job
.
block
.
status
,
Block
.
CACHED
)
self.assertEqual(
len(jobs), 0
)
self
.
assertEqual
(
split
.
job
.
block
.
experiment
.
status
,
Experiment
.
DONE
)
# experiment is now
'
completed
'
self
.
check_stats_success
(
split
)
self.assertEqual(xp.state,
'
completed
'
)
self.assertEqual(xp.dispatch,
'
pending
'
)
self.assertEqual(worker.available_cores(), CORES)
# assert we have no database traces after the block is done
'''
self
.
assertEqual
(
Job
.
objects
.
filter
(
block
=
split
.
job
.
block
).
count
(),
0
)
self
.
assertEqual
(
JobSplit
.
objects
.
filter
(
job
=
split
.
job
).
count
(),
0
)
self
.
assertEqual
(
Result
.
objects
.
filter
(
job__isnull
=
True
).
count
(),
0
)
self
.
assertEqual
(
Result
.
objects
.
filter
(
split__isnull
=
True
).
count
(),
0
)
self
.
assertEqual
(
worker
.
available_cores
(),
qsetup
.
CORES
)
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