Skip to content
GitLab
Explore
Sign in
Register
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
6a506a89
Commit
6a506a89
authored
3 years ago
by
Mario Raciti
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-857
: Fix reporting tests for durations
parent
f459341d
No related branches found
No related tags found
3 merge requests
!634
WIP: COBALT commissioning delta
,
!516
Resolve TMSS-857
,
!481
Draft: SW-971 SW-973 SW-975: Various fixes to build LOFAR correctly.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
+3
-4
3 additions, 4 deletions
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
SAS/TMSS/backend/test/t_adapter.py
+21
-21
21 additions, 21 deletions
SAS/TMSS/backend/test/t_adapter.py
with
24 additions
and
25 deletions
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
+
3
−
4
View file @
6a506a89
...
@@ -302,10 +302,9 @@ def create_project_report(request: Request, project: models.Project) -> {}:
...
@@ -302,10 +302,9 @@ def create_project_report(request: Request, project: models.Project) -> {}:
"""
"""
Create a project report as a JSON object.
Create a project report as a JSON object.
"""
"""
result
=
{
'
project
'
:
project
.
pk
,
'
quota
'
:
_get_quotas_from_project
(
request
,
project
.
pk
),
subs
,
durations
=
_get_subs_and_durations_from_project
(
project
.
pk
)
'
SUBs
'
:
(
_get_subs_and_durations_from_project
(
project
.
pk
))[
0
],
result
=
{
'
project
'
:
project
.
pk
,
'
quota
'
:
_get_quotas_from_project
(
request
,
project
.
pk
),
'
SUBs
'
:
subs
,
'
durations
'
:
(
_get_subs_and_durations_from_project
(
project
.
pk
))[
1
],
'
durations
'
:
durations
,
'
LTA dataproducts
'
:
_get_lta_dataproducts
(
project
.
name
),
'
SAPs
'
:
_get_saps
(
project
.
pk
)}
'
LTA dataproducts
'
:
_get_lta_dataproducts
(
project
.
name
),
'
SAPs
'
:
_get_saps
(
project
.
pk
)}
return
result
return
result
...
...
This diff is collapsed.
Click to expand it.
SAS/TMSS/backend/test/t_adapter.py
+
21
−
21
View file @
6a506a89
...
@@ -538,23 +538,20 @@ class CycleReportTest(unittest.TestCase):
...
@@ -538,23 +538,20 @@ class CycleReportTest(unittest.TestCase):
self
.
assertEqual
(
data_per_site_and_cat
[
'
Preprocessing Pipeline
'
][
'
size__sum
'
],
dp_preprocessing_pip
.
size
)
self
.
assertEqual
(
data_per_site_and_cat
[
'
Preprocessing Pipeline
'
][
'
size__sum
'
],
dp_preprocessing_pip
.
size
)
self
.
assertEqual
(
data_per_site_and_cat
[
'
Pulsar Pipeline
'
][
'
size__sum
'
],
dp_pulsar_pip1
.
size
+
dp_pulsar_pip2
.
size
)
self
.
assertEqual
(
data_per_site_and_cat
[
'
Pulsar Pipeline
'
][
'
size__sum
'
],
dp_pulsar_pip1
.
size
+
dp_pulsar_pip2
.
size
)
# TODO: Avoid calculations in the code.
# Assert usage_mode
# Assert usage_mode
total_sa_mode
=
reservation_no_project_sa_mode
.
duration
+
reservation_mixed_sa_mode
.
duration
+
reservation_project_sa_mode
.
duration
total_all_modes
=
reservation_no_project
.
duration
+
reservation_mixed
.
duration
+
reservation_project
.
duration
+
total_sa_mode
usage_mode
=
result
[
'
usage_mode
'
]
usage_mode
=
result
[
'
usage_mode
'
]
self
.
assertAlmostEqual
(
usage_mode
[
'
all modes
'
][
'
total
'
],
total_all_modes
)
self
.
assertAlmostEqual
(
usage_mode
[
'
all modes
'
][
'
total
'
],
3750
,
places
=
4
)
self
.
assertAlmostEqual
(
usage_mode
[
'
all modes
'
][
'
observing
'
],
reservation_project
.
duration
+
reservation_project_sa_mode
.
duration
)
self
.
assertAlmostEqual
(
usage_mode
[
'
all modes
'
][
'
observing
'
],
1400
,
places
=
4
)
self
.
assertAlmostEqual
(
usage_mode
[
'
all modes
'
][
'
idle/test
'
],
reservation_mixed
.
duration
+
reservation_mixed_sa_mode
.
duration
)
self
.
assertAlmostEqual
(
usage_mode
[
'
all modes
'
][
'
idle/test
'
],
850
,
places
=
4
)
self
.
assertAlmostEqual
(
usage_mode
[
'
stand-alone mode
'
][
'
total
'
],
total_sa_mode
)
self
.
assertAlmostEqual
(
usage_mode
[
'
stand-alone mode
'
][
'
total
'
],
2350
,
places
=
4
)
self
.
assertAlmostEqual
(
usage_mode
[
'
stand-alone mode
'
][
'
no project
'
],
reservation_no_project_sa_mode
.
duration
)
self
.
assertAlmostEqual
(
usage_mode
[
'
stand-alone mode
'
][
'
no project
'
],
1200
,
places
=
4
)
self
.
assertAlmostEqual
(
usage_mode
[
'
stand-alone mode
'
][
'
project
'
],
reservation_project_sa_mode
.
duration
)
self
.
assertAlmostEqual
(
usage_mode
[
'
stand-alone mode
'
][
'
project
'
],
800
,
places
=
4
)
self
.
assertAlmostEqual
(
usage_mode
[
'
stand-alone mode
'
][
'
mixed/no project
'
],
reservation_mixed_sa_mode
.
duration
)
self
.
assertAlmostEqual
(
usage_mode
[
'
stand-alone mode
'
][
'
mixed/no project
'
],
350
,
places
=
4
)
self
.
assertAlmostEqual
(
usage_mode
[
'
ILT mode
'
][
'
total
'
],
total_all_modes
-
total_sa_mode
)
self
.
assertAlmostEqual
(
usage_mode
[
'
ILT mode
'
][
'
total
'
],
1400
,
places
=
4
)
self
.
assertAlmostEqual
(
usage_mode
[
'
ILT mode
'
][
'
observing
'
],
reservation_project
.
duration
+
reservation_project_sa_mode
.
duration
-
reservation_project_sa_mode
.
duration
)
self
.
assertAlmostEqual
(
usage_mode
[
'
ILT mode
'
][
'
observing
'
],
600
,
places
=
4
)
self
.
assertAlmostEqual
(
usage_mode
[
'
ILT mode
'
][
'
idle/test
'
],
reservation_mixed
.
duration
+
reservation_mixed_sa_mode
.
duration
-
reservation_mixed_sa_mode
.
duration
)
self
.
assertAlmostEqual
(
usage_mode
[
'
ILT mode
'
][
'
idle/test
'
],
500
,
places
=
4
)
class
ProjectReportTest
(
unittest
.
TestCase
):
class
ProjectReportTest
(
unittest
.
TestCase
):
...
@@ -594,12 +591,15 @@ class ProjectReportTest(unittest.TestCase):
...
@@ -594,12 +591,15 @@ class ProjectReportTest(unittest.TestCase):
"""
"""
Test create project extra action.
Test create project extra action.
"""
"""
# Create and set three SUBs and respectively set the following states: 'finished', 'cancelled', 'defined' (not cancelled)
# Create four SUBs and respectively set their states to: 'finished' (so we can create dataproducts and compare
# their sizes), blank (it may be whatever), 'cancelled' and 'defined' (which means not cancelled).
succeeded_sub
,
_
,
succeeded_subtask
=
self
.
_get_SUB_with_subtask_and_set_status
(
'
finished
'
)
succeeded_sub
,
_
,
succeeded_subtask
=
self
.
_get_SUB_with_subtask_and_set_status
(
'
finished
'
)
failed_sub
,
_
,
failed_subtask
=
self
.
_get_SUB_with_subtask_and_set_status
()
cancelled_sub
,
_
,
cancelled_subtask
=
self
.
_get_SUB_with_subtask_and_set_status
(
'
cancelled
'
)
not_cancelled_sub
,
_
,
not_cancelled_subtask
=
self
.
_get_SUB_with_subtask_and_set_status
(
'
defined
'
)
# Set workflow flags so we have a successful and a failed SUBs
SchedulingUnitProcess
.
objects
.
create
(
su
=
succeeded_sub
,
results_accepted
=
True
)
SchedulingUnitProcess
.
objects
.
create
(
su
=
succeeded_sub
,
results_accepted
=
True
)
failed_sub
,
_
,
failed_subtask
=
self
.
_get_SUB_with_subtask_and_set_status
(
'
cancelled
'
)
SchedulingUnitProcess
.
objects
.
create
(
su
=
failed_sub
,
results_accepted
=
False
)
SchedulingUnitProcess
.
objects
.
create
(
su
=
failed_sub
,
results_accepted
=
False
)
not_cancelled_sub
,
_
,
not_cancelled_subtask
=
self
.
_get_SUB_with_subtask_and_set_status
(
'
defined
'
)
# Create SubtaskOutput and Dataproducts from subtask_output
# Create SubtaskOutput and Dataproducts from subtask_output
subtask_output
=
models
.
SubtaskOutput
.
objects
.
create
(
**
SubtaskOutput_test_data
(
subtask
=
succeeded_subtask
))
subtask_output
=
models
.
SubtaskOutput
.
objects
.
create
(
**
SubtaskOutput_test_data
(
subtask
=
succeeded_subtask
))
...
@@ -616,11 +616,11 @@ class ProjectReportTest(unittest.TestCase):
...
@@ -616,11 +616,11 @@ class ProjectReportTest(unittest.TestCase):
self
.
assertEqual
(
result
[
'
quota
'
][
0
][
'
id
'
],
self
.
project_quota
.
pk
)
self
.
assertEqual
(
result
[
'
quota
'
][
0
][
'
id
'
],
self
.
project_quota
.
pk
)
# Assert durations are well calculated
# Assert durations are well calculated
# N
ote
:
t
he
re are three SUBs: one
successful,
one
failed and
one
not cancelled
. Each
ha
s
a duration
=600
.
# N
OTE
:
T
he
four SUBs (
successful, failed
, cancelled
and not cancelled
)
ha
ve
a duration
of 600s each
.
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total
'
],
1800.
0
,
places
=
4
)
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total
'
],
240
0
,
places
=
4
)
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total_succeeded
'
],
600
.0
,
places
=
4
)
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total_succeeded
'
],
600
,
places
=
4
)
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total_not_cancelled
'
],
1
200.
0
,
places
=
4
)
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total_not_cancelled
'
],
1
80
0
,
places
=
4
)
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total_failed
'
],
600
.0
,
places
=
4
)
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total_failed
'
],
600
,
places
=
4
)
# There is only one finished SUB
# There is only one finished SUB
self
.
assertEqual
(
result
[
'
SUBs
'
][
'
finished
'
][
0
][
'
id
'
],
succeeded_sub
.
pk
)
self
.
assertEqual
(
result
[
'
SUBs
'
][
'
finished
'
][
0
][
'
id
'
],
succeeded_sub
.
pk
)
...
...
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