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
Lu Xu
slapos.toolbox
Commits
52ea1591
Commit
52ea1591
authored
Mar 01, 2023
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check_surykatka_json: Cover missing total_seconds in elapsed_time
parent
04d93134
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
0 deletions
+71
-0
slapos/promise/plugin/check_surykatka_json.py
slapos/promise/plugin/check_surykatka_json.py
+6
-0
slapos/test/promise/plugin/test_check_surykatka_json.py
slapos/test/promise/plugin/test_check_surykatka_json.py
+65
-0
No files found.
slapos/promise/plugin/check_surykatka_json.py
View file @
52ea1591
...
...
@@ -311,8 +311,10 @@ class RunPromise(GenericPromise):
return
self
.
appendMessage
(
'%s:'
%
(
key
,))
if
maximum_elapsed_time
:
found
=
False
for
entry
in
entry_list
:
if
'total_seconds'
in
entry
:
found
=
True
maximum_elapsed_time
=
float
(
maximum_elapsed_time
)
if
entry
[
'total_seconds'
]
==
0.
:
appendError
(
'IP %s failed to reply'
%
(
entry
[
'ip'
]))
...
...
@@ -324,6 +326,10 @@ class RunPromise(GenericPromise):
self
.
appendMessage
(
'OK IP %s replied < %.2fs'
%
(
entry
[
'ip'
],
maximum_elapsed_time
))
if
not
found
:
appendError
(
"No entry with total_seconds found. If the error persist, please "
"update surykatka"
)
else
:
self
.
appendMessage
(
"OK No check configured"
)
...
...
slapos/test/promise/plugin/test_check_surykatka_json.py
View file @
52ea1591
...
...
@@ -480,6 +480,71 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"127.0.0.2 failed to reply"
)
def
test_maximum_elapsed_no_match
(
self
):
self
.
writeSurykatkaPromise
(
{
'report'
:
'http_query'
,
'json-file'
:
self
.
json_file
,
'url'
:
'https://www.erp5.com/'
,
'status-code'
:
'302'
,
'ip-list'
:
'127.0.0.1 127.0.0.2'
,
'maximum-elapsed-time'
:
'5'
,
}
)
self
.
writeSurykatkaJson
({
"http_query"
:
[
{
"date"
:
"Wed, 11 Dec 2019 09:35:28 -0000"
,
"ip"
:
"127.0.0.1"
,
"status_code"
:
302
,
"url"
:
"https://www.erp5.com/"
,
},
{
"date"
:
"Wed, 11 Dec 2019 09:35:28 -0000"
,
"ip"
:
"127.0.0.2"
,
"status_code"
:
302
,
"url"
:
"https://www.erp5.com/"
,
},
{
"date"
:
"Wed, 11 Dec 2019 09:35:28 -0000"
,
"ip"
:
"176.31.129.213"
,
"status_code"
:
200
,
"url"
:
"https://www.erp5.org/"
,
}
],
"ssl_certificate"
:
[
{
"date"
:
"Fri, 27 Dec 2019 14:43:26 -0000"
,
"hostname"
:
"www.erp5.com"
,
"ip"
:
"127.0.0.1"
,
"not_after"
:
self
.
time_future60d
},
{
"date"
:
"Fri, 27 Dec 2019 14:43:26 -0000"
,
"hostname"
:
"www.erp5.com"
,
"ip"
:
"127.0.0.2"
,
"not_after"
:
self
.
time_future60d
}
],
"dns_query"
:
[],
"tcp_server"
:
[],
})
self
.
configureLauncher
(
enable_anomaly
=
True
)
with
self
.
assertRaises
(
PromiseError
):
self
.
launcher
.
run
()
self
.
assertFailedMessage
(
self
.
getPromiseResult
(
self
.
promise_name
),
"https://www.erp5.com/ : "
"dns_query: ERROR No data "
"tcp_server: ERROR No data "
"http_query: OK IP 127.0.0.1 status_code 302 OK IP 127.0.0.2 "
"status_code 302 "
"ssl_certificate: OK IP 127.0.0.1 will expire in > 15 days OK IP "
"127.0.0.2 will expire in > 15 days "
"elapsed_time: ERROR No entry with total_seconds found. If the error "
"persist, please update surykatka"
)
def
test_maximum_elapsed_time_no_total_seconds
(
self
):
self
.
writeSurykatkaPromise
(
{
...
...
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