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
8b9454c8
Commit
8b9454c8
authored
Mar 02, 2023
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check_surykatka_json: Reword
parent
c58eff92
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
28 deletions
+25
-28
slapos/promise/plugin/check_surykatka_json.py
slapos/promise/plugin/check_surykatka_json.py
+6
-6
slapos/test/promise/plugin/test_check_surykatka_json.py
slapos/test/promise/plugin/test_check_surykatka_json.py
+19
-22
No files found.
slapos/promise/plugin/check_surykatka_json.py
View file @
8b9454c8
...
...
@@ -126,11 +126,11 @@ class RunPromise(GenericPromise):
if
certificate_expiration_time
-
datetime
.
timedelta
(
days
=
certificate_expiration_days
)
<
self
.
utcnow
:
self
.
appendError
(
'IP %s
will expire
in < %s days'
%
(
'IP %s
expires
in < %s days'
%
(
entry
[
'ip'
],
certificate_expiration_days
))
else
:
self
.
appendOk
(
'IP %s
will expire
in > %s days'
%
(
'IP %s
expires
in > %s days'
%
(
entry
[
'ip'
],
certificate_expiration_days
))
def
senseHttpQuery
(
self
):
...
...
@@ -161,7 +161,7 @@ class RunPromise(GenericPromise):
else
:
status_code_explanation
=
entry_status_code
self
.
appendError
(
'IP %s
expected
status_code %s != %s'
%
(
'IP %s status_code %s != %s'
%
(
entry
[
'ip'
],
status_code_explanation
,
status_code
))
else
:
self
.
appendOk
(
...
...
@@ -169,7 +169,7 @@ class RunPromise(GenericPromise):
if
http_header_dict
:
if
http_header_dict
!=
entry
[
'http_header_dict'
]:
self
.
appendError
(
'IP %s
expected
HTTP Header %s != %s'
%
(
'IP %s HTTP Header %s != %s'
%
(
entry
[
'ip'
],
json
.
dumps
(
http_header_dict
,
sort_keys
=
True
),
json
.
dumps
(
entry
[
'http_header_dict'
],
sort_keys
=
True
)))
...
...
@@ -203,12 +203,12 @@ class RunPromise(GenericPromise):
q
.
strip
()
for
q
in
entry
[
'response'
].
split
(
","
)
if
q
.
strip
()])
if
ip_set
!=
response_ip_set
:
self
.
appendError
(
"resolver
%s expected
%s != %s"
%
(
"resolver
's %s:
%s != %s"
%
(
entry
[
'resolver_ip'
],
' '
.
join
(
sorted
(
ip_set
)),
' '
.
join
(
sorted
(
response_ip_set
))
or
"empty-reply"
))
else
:
self
.
appendOk
(
"resolver
%s returned expected set of IPs
%s"
%
(
"resolver
's %s:
%s"
%
(
entry
[
'resolver_ip'
],
' '
.
join
(
sorted
(
ip_set
)),))
else
:
self
.
appendOk
(
'No check configured'
)
...
...
slapos/test/promise/plugin/test_check_surykatka_json.py
View file @
8b9454c8
...
...
@@ -452,13 +452,12 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
)
self
.
runAndAssertPassedMessage
(
"https://www.allok.com/ : "
"dns_query: OK resolver 1.2.3.4 returned expected set of IPs 127.0.0.1 "
"127.0.0.2 "
"dns_query: OK resolver's 1.2.3.4: 127.0.0.1 127.0.0.2 "
"tcp_server: OK IP 127.0.0.1:443 OK IP 127.0.0.2:443 "
"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 "
"ssl_certificate: OK IP 127.0.0.1
expires
in > 15 days OK IP "
"127.0.0.2
expires
in > 15 days "
"elapsed_time: OK IP 127.0.0.1 replied < 5.00s OK IP 127.0.0.2 replied "
"< 5.00s"
)
...
...
@@ -517,8 +516,7 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
)
self
.
runAndAssertPassedMessage
(
"http://www.httpallok.com/ : "
"dns_query: OK resolver 1.2.3.4 returned expected set of IPs 127.0.0.1 "
"127.0.0.2 "
"dns_query: OK resolver's 1.2.3.4: 127.0.0.1 127.0.0.2 "
"tcp_server: OK IP 127.0.0.1:80 OK IP 127.0.0.2:80 "
"http_query: OK IP 127.0.0.1 status_code 302 OK IP 127.0.0.2 "
"status_code 302 "
...
...
@@ -565,7 +563,7 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'dns_query: OK No check configured '
'tcp_server: OK No check configured '
'http_query: OK IP 127.0.0.1 status_code 200 ERROR IP 127.0.0.1 '
'
expected
HTTP Header {"Cache-Control": "max-age=300", "Vary": '
'HTTP Header {"Cache-Control": "max-age=300", "Vary": '
'"Accept-Encoding"} != {"Cache-Control": "max-age=300, public", "Vary": '
'"Accept-Encoding"} '
'ssl_certificate: OK No check needed '
...
...
@@ -587,8 +585,8 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"tcp_server: OK No check configured "
"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 "
"ssl_certificate: OK IP 127.0.0.1
expires
in > 15 days OK IP "
"127.0.0.2
expires
in > 15 days "
"elapsed_time: OK No check configured"
)
...
...
@@ -607,7 +605,7 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"dns_query: OK No check configured "
"tcp_server: OK No check configured "
"http_query: OK IP 127.0.0.1 status_code 302 "
"ssl_certificate: OK IP 127.0.0.1
will expire
in > 2 days "
"ssl_certificate: OK IP 127.0.0.1
expires
in > 2 days "
"elapsed_time: OK No check configured"
)
...
...
@@ -627,7 +625,7 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"dns_query: OK No check configured "
"tcp_server: OK No check configured "
"http_query: OK IP 127.0.0.1 status_code 302 "
"ssl_certificate: ERROR IP 127.0.0.1
will expire
in < 4 days "
"ssl_certificate: ERROR IP 127.0.0.1
expires
in < 4 days "
"elapsed_time: OK No check configured"
)
...
...
@@ -645,7 +643,7 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"dns_query: OK No check configured "
"tcp_server: OK No check configured "
"http_query: OK IP 127.0.0.1 status_code 302 "
"ssl_certificate: ERROR IP 127.0.0.1
will expire
in < 15 days "
"ssl_certificate: ERROR IP 127.0.0.1
expires
in < 15 days "
"elapsed_time: OK No check configured"
)
...
...
@@ -663,7 +661,7 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"dns_query: OK No check configured "
"tcp_server: OK No check configured "
"http_query: OK IP 127.0.0.1 status_code 302 "
"ssl_certificate: ERROR IP 127.0.0.1
will expire
in < 15 days "
"ssl_certificate: ERROR IP 127.0.0.1
expires
in < 15 days "
"elapsed_time: OK No check configured"
)
...
...
@@ -770,10 +768,10 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"https://www.allok.com/ : "
"dns_query: OK No check configured "
"tcp_server: OK No check configured "
"http_query: ERROR IP 127.0.0.1
expected
status_code 302 != 301 ERROR "
"IP 127.0.0.2
expected
status_code 302 != 301 "
"ssl_certificate: OK IP 127.0.0.1
will expire
in > 15 days OK IP "
"127.0.0.2
will expire
in > 15 days "
"http_query: ERROR IP 127.0.0.1 status_code 302 != 301 ERROR "
"IP 127.0.0.2 status_code 302 != 301 "
"ssl_certificate: OK IP 127.0.0.1
expires
in > 15 days OK IP "
"127.0.0.2
expires
in > 15 days "
"elapsed_time: OK No check configured"
)
...
...
@@ -802,7 +800,7 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"http://www.statuscode.com/ : "
"dns_query: OK No check configured "
"tcp_server: OK No check configured "
"http_query: ERROR IP 127.0.0.1
expected
status_code %s != 301 "
"http_query: ERROR IP 127.0.0.1 status_code %s != 301 "
"ssl_certificate: OK No check needed "
"elapsed_time: OK No check configured"
%
(
explanation
,)
)
...
...
@@ -835,7 +833,7 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
self
.
assertFailedMessage
(
self
.
getPromiseResult
(
self
.
promise_name
),
"http://www.badip.com/ : "
"dns_query: ERROR resolver
1.2.3.4 expected
127.0.0.1 127.0.0.2 != "
"dns_query: ERROR resolver
's 1.2.3.4:
127.0.0.1 127.0.0.2 != "
"127.0.0.1 127.0.0.4 "
"tcp_server: OK IP 127.0.0.1:80 ERROR IP 127.0.0.2:80 "
"http_query: OK IP 127.0.0.1 status_code 302 OK IP 127.0.0.4 "
...
...
@@ -919,7 +917,7 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
)
self
.
runAndAssertFailedMessage
(
"http://www.httpallok.com/ : "
"dns_query: ERROR resolver
1.2.3.4 expected
127.0.0.1 127.0.0.9 != "
"dns_query: ERROR resolver
's 1.2.3.4:
127.0.0.1 127.0.0.9 != "
"127.0.0.1 127.0.0.2 "
"tcp_server: OK IP 127.0.0.1:80 ERROR IP 127.0.0.9:80 "
"http_query: OK IP 127.0.0.1 status_code 302 OK IP 127.0.0.2 "
...
...
@@ -940,8 +938,7 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
)
self
.
runAndAssertFailedMessage
(
"http://www.dnsquerynoreply.com/ : "
"dns_query: ERROR resolver 1.2.3.4 expected 127.0.0.1 != "
"empty-reply "
"dns_query: ERROR resolver's 1.2.3.4: 127.0.0.1 != empty-reply "
"tcp_server: ERROR No data "
"http_query: ERROR No data "
"ssl_certificate: OK No check needed "
...
...
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