Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
Justin
slapos.toolbox
Commits
4fc2b623
Commit
4fc2b623
authored
Dec 15, 2022
by
Justin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated test for check_ram_usage promise
parent
cf44cbba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
slapos/test/promise/plugin/test_check_ram_usage.py
slapos/test/promise/plugin/test_check_ram_usage.py
+6
-7
No files found.
slapos/test/promise/plugin/test_check_ram_usage.py
View file @
4fc2b623
...
...
@@ -41,6 +41,7 @@ class TestCheckRamUsage(TestPromisePluginMixin):
def
setUp
(
self
):
super
(
TestCheckRamUsage
,
self
).
setUp
()
self
.
ram_data
=
namedtuple
(
'ram_data'
,
[
'available'
])
def
writePromise
(
self
,
**
kw
):
super
(
TestCheckRamUsage
,
self
).
writePromise
(
self
.
promise_name
,
...
...
@@ -60,29 +61,26 @@ class TestCheckRamUsage(TestPromisePluginMixin):
def
test_ram_ok
(
self
):
message
=
"RAM usage OK"
ram_data
=
namedtuple
(
'ram_data'
,
[
'available'
])
available_ram
=
{
'available'
:
1e9
}
self
.
writePromise
(
**
{
'last-avg-ram-file'
:
'last_avg_ram_file'
,
'min-threshold-ram'
:
500e6
,
# 500MB
'min-avg-ram'
:
100
,
})
self
.
assertEqual
(
message
,
self
.
runPromise
(
ram_data
(
**
available_ram
)))
self
.
assertEqual
(
message
,
self
.
runPromise
(
self
.
ram_data
(
**
available_ram
)))
def
test_ram_below_threshold_nok
(
self
):
message
=
"RAM usage reached critical threshold: 190.7M (threshold is 476.8M)"
ram_data
=
namedtuple
(
'ram_data'
,
[
'available'
])
available_ram
=
{
'available'
:
200e6
}
self
.
writePromise
(
**
{
'last-avg-ram-file'
:
'last_avg_ram_file'
,
'min-threshold-ram'
:
500e6
,
# ≈500MB
'min-avg-ram'
:
100
,
})
self
.
assertEqual
(
message
,
self
.
runPromise
(
ram_data
(
**
available_ram
)))
self
.
assertEqual
(
message
,
self
.
runPromise
(
self
.
ram_data
(
**
available_ram
)))
def
test_ram_below_average_nok
(
self
):
message
=
"Average RAM usage over the last 1 seconds reached threshold: 100.5B (threshold is 200.0B)"
ram_data
=
namedtuple
(
'ram_data'
,
[
'available'
])
available_ram
=
{
'available'
:
200
}
self
.
writePromise
(
**
{
'last-avg-ram-file'
:
'last_avg_ram_file'
,
...
...
@@ -90,9 +88,10 @@ class TestCheckRamUsage(TestPromisePluginMixin):
'min-avg-ram'
:
200
,
'avg-ram-period-sec'
:
1
,
})
m
=
self
.
runPromise
(
ram_data
(
**
{
'available'
:
1
}))
m
=
self
.
runPromise
(
self
.
ram_data
(
**
{
'available'
:
200
}))
m
=
self
.
runPromise
(
self
.
ram_data
(
**
{
'available'
:
1
}))
time
.
sleep
(
1
)
self
.
assertEqual
(
message
,
self
.
runPromise
(
ram_data
(
**
available_ram
),
failed
=
True
))
self
.
assertEqual
(
message
,
self
.
runPromise
(
self
.
ram_data
(
**
available_ram
)
))
if
__name__
==
'__main__'
:
...
...
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