Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lisa Casino
slapos
Commits
0cfa2cab
Commit
0cfa2cab
authored
Aug 31, 2021
by
Lisa Casino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/monitor: add prediction test
parent
3f2ff90c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
0 deletions
+93
-0
software/monitor/test/test.py
software/monitor/test/test.py
+93
-0
No files found.
software/monitor/test/test.py
View file @
0cfa2cab
...
...
@@ -33,6 +33,7 @@ import re
import
requests
import
subprocess
import
unittest
import
datetime
import
xml.etree.ElementTree
as
ET
from
slapos.recipe.librecipe
import
generateHashFromFiles
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
...
...
@@ -1408,3 +1409,95 @@ URL =
'status-code': '200',
'url': 'https://www.all.org/'}"""
%
(
self
.
surykatka_dict
[
'edge4'
][
2
][
'json-file'
],))
class
TestPrediction
(
ServicesTestCase
):
def
test_new_modules
(
self
):
# check that the new modules are in the develop-eggs folder
develop_eggs_path
=
os
.
path
.
join
(
self
.
computer_partition_root_path
,
'software_release'
,
'develop-eggs'
)
pandas_path
=
os
.
path
.
join
(
develop_eggs_path
,
'pandas-0.19.2-py3.6-linux-x86_64.egg'
)
self
.
assertEqual
(
os
.
path
.
exists
(
pandas_path
),
True
)
scipy_path
=
os
.
path
.
join
(
develop_eggs_path
,
'scipy-1.0.1-py3.6-linux-x86_64.egg'
)
self
.
assertEqual
(
os
.
path
.
exists
(
scipy_path
),
True
)
statsmodels_path
=
os
.
path
.
join
(
develop_eggs_path
,
'statsmodels-0.8.0-py3.6-linux-x86_64.egg'
)
self
.
assertEqual
(
os
.
path
.
exists
(
statsmodels_path
),
True
)
def
test_arima_run
(
self
):
now
=
datetime
.
datetime
.
now
()
parameter_dict
=
{
'display-prediction'
:
'1'
,
}
self
.
slap
.
request
(
software_release
=
self
.
getSoftwareURL
(),
partition_reference
=
self
.
default_partition_reference
,
partition_parameter_kw
=
parameter_dict
)
# Force promises to recompute regardless of periodicity
self
.
slap
.
_force_slapos_node_instance_all
=
True
self
.
slap
.
waitForInstance
(
error_lines
=
0
)
promise_result_path
=
os
.
path
.
join
(
self
.
computer_partition_root_path
,
'.slapgrid'
,
'promise'
,
'result'
)
# check file exist
path_check_free_disk_space
=
os
.
path
.
join
(
promise_result_path
,
'check-free-disk-space.status.json'
)
self
.
assertEqual
(
os
.
path
.
exists
(
path_check_free_disk_space
),
True
)
# check monitor_partition_space promise has not been run
path_monitor_partition_space
=
os
.
path
.
join
(
promise_result_path
,
'monitor-partition-space.status.json'
)
self
.
assertEqual
(
os
.
path
.
exists
(
path_monitor_partition_space
),
False
)
# check ARIMA option is True
f
=
open
(
path_check_free_disk_space
)
result
=
json
.
load
(
f
)
self
.
assertIn
(
"Enable to display disk space predictions: True"
,
result
[
'result'
][
'message'
])
self
.
assertFalse
(
result
[
'result'
][
'failed'
])
# check that promise timestamp is later than now
promise_time
=
datetime
.
datetime
.
strptime
(
result
[
'result'
][
'date'
],
"%Y-%m-%dT%H:%M:%S+%f"
)
self
.
assertTrue
(
promise_time
<
now
)
def
test_monitor_partition_space_run
(
self
):
now
=
datetime
.
datetime
.
now
()
parameter_dict
=
{
'display-anomaly'
:
'1'
,
}
self
.
slap
.
request
(
software_release
=
self
.
getSoftwareURL
(),
partition_reference
=
self
.
default_partition_reference
,
partition_parameter_kw
=
parameter_dict
)
# Force promises to recompute regardless of periodicity
self
.
slap
.
_force_slapos_node_instance_all
=
True
self
.
slap
.
waitForInstance
(
error_lines
=
0
)
promise_result_path
=
os
.
path
.
join
(
self
.
computer_partition_root_path
,
'.slapgrid'
,
'promise'
,
'result'
)
# check file exist
path_check_free_disk_space
=
os
.
path
.
join
(
promise_result_path
,
'check-free-disk-space.status.json'
)
self
.
assertEqual
(
os
.
path
.
exists
(
path_check_free_disk_space
),
True
)
path_monitor_partition_space
=
os
.
path
.
join
(
promise_result_path
,
'monitor-partition-space.status.json'
)
self
.
assertEqual
(
os
.
path
.
exists
(
path_monitor_partition_space
),
True
)
# check ARIMA option is False
f
=
open
(
path_check_free_disk_space
)
result
=
json
.
load
(
f
)
self
.
assertIn
(
"Enable to display disk space predictions: False"
,
result
[
'result'
][
'message'
])
# check monitor_partition_space ran
f
=
open
(
path_monitor_partition_space
)
result
=
json
.
load
(
f
)
self
.
assertTrue
(
result
[
'result'
][
'message'
]
is
not
None
)
self
.
assertFalse
(
result
[
'result'
][
'failed'
])
# check that promise timestamp is later than now
promise_time
=
datetime
.
datetime
.
strptime
(
result
[
'result'
][
'date'
],
"%Y-%m-%dT%H:%M:%S+%f"
)
self
.
assertTrue
(
promise_time
<
now
)
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