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
Labels
Merge Requests
91
Merge Requests
91
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
7cd21cd7
Commit
7cd21cd7
authored
Feb 04, 2020
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XXX caddy-frontend: Test monitoring configuration
XXX: It's not done yet, a lot of improvements have to be applied.
parent
883e3565
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
0 deletions
+99
-0
software/caddy-frontend/test/test.py
software/caddy-frontend/test/test.py
+99
-0
No files found.
software/caddy-frontend/test/test.py
View file @
7cd21cd7
...
...
@@ -47,6 +47,7 @@ import gzip
import
base64
import
re
from
slapos.recipe.librecipe
import
generateHashFromFiles
import
xml.etree.ElementTree
as
ET
try
:
...
...
@@ -1371,6 +1372,104 @@ http://apachecustomhttpsaccepted.example.com:%%(http_port)s {
}
}
monitor_setup_url_key
=
'monitor-setup-url'
def
test_monitor_setup
(
self
):
IP
=
self
.
_ipv6_address
self
.
monitor_configuration_list
=
[
{
'htmlUrl'
:
'https://[%s]:13000/public/feed'
%
(
IP
,),
'text'
:
'testing partition 0'
,
'title'
:
'testing partition 0'
,
'type'
:
'rss'
,
'url'
:
'https://[%s]:13000/share/private/'
%
(
IP
,),
'version'
:
'RSS'
,
'xmlUrl'
:
'https://[%s]:13000/public/feed'
%
(
IP
,),
},
{
'htmlUrl'
:
'https://[%s]:13001/public/feed'
%
(
IP
,),
'text'
:
'caddy-frontend-1'
,
'title'
:
'caddy-frontend-1'
,
'type'
:
'rss'
,
'url'
:
'https://[%s]:13001/share/private/'
%
(
IP
,),
'version'
:
'RSS'
,
'xmlUrl'
:
'https://[%s]:13001/public/feed'
%
(
IP
,),
},
{
'htmlUrl'
:
'https://[%s]:8196/public/feed'
%
(
IP
,),
'text'
:
'kedifa'
,
'title'
:
'kedifa'
,
'type'
:
'rss'
,
'url'
:
'https://[%s]:8196/share/private/'
%
(
IP
,),
'version'
:
'RSS'
,
'xmlUrl'
:
'https://[%s]:8196/public/feed'
%
(
IP
,),
}
]
connection_parameter_dict
=
self
\
.
computer_partition
.
getConnectionParameterDict
()
self
.
assertTrue
(
self
.
monitor_setup_url_key
in
connection_parameter_dict
,
'%s not in %s'
%
(
self
.
monitor_setup_url_key
,
connection_parameter_dict
))
monitor_setup_url_value
=
connection_parameter_dict
[
self
.
monitor_setup_url_key
]
monitor_url_match
=
re
.
match
(
r'.*url=(.*)'
,
monitor_setup_url_value
)
self
.
assertNotEqual
(
None
,
monitor_url_match
,
'%s not parsable'
%
(
monitor_setup_url_value
,))
self
.
assertEqual
(
1
,
len
(
monitor_url_match
.
groups
()))
monitor_url
=
monitor_url_match
.
groups
()[
0
]
monitor_url_split
=
monitor_url
.
split
(
'&'
)
self
.
assertEqual
(
3
,
len
(
monitor_url_split
),
'%s not splitabble'
%
(
monitor_url
,))
self
.
monitor_url
=
monitor_url_split
[
0
]
monitor_username
=
monitor_url_split
[
1
].
split
(
'='
)
self
.
assertEqual
(
2
,
len
(
monitor_username
),
'%s not splittable'
%
(
monitor_username
))
monitor_password
=
monitor_url_split
[
2
].
split
(
'='
)
self
.
assertEqual
(
2
,
len
(
monitor_password
),
'%s not splittable'
%
(
monitor_password
))
self
.
monitor_username
=
monitor_username
[
1
]
self
.
monitor_password
=
monitor_password
[
1
]
opml_text
=
requests
.
get
(
self
.
monitor_url
,
verify
=
False
).
text
opml
=
ET
.
fromstring
(
opml_text
)
body
=
opml
[
1
]
self
.
assertEqual
(
'body'
,
body
.
tag
)
outline_list
=
body
[
0
].
findall
(
'outline'
)
self
.
assertEqual
(
self
.
monitor_configuration_list
,
[
q
.
attrib
for
q
in
outline_list
]
)
return
# rest is disabled for now
expected_status_code_list
=
[]
got_status_code_list
=
[]
for
monitor_configuration
in
self
.
monitor_configuration_list
:
status_code
=
requests
.
get
(
monitor_configuration
[
'url'
],
verify
=
False
,
auth
=
(
self
.
monitor_username
,
self
.
monitor_password
)
).
status_code
expected_status_code_list
.
append
(
{
'url'
:
monitor_configuration
[
'url'
],
'status_code'
:
200
}
)
got_status_code_list
.
append
(
{
'url'
:
monitor_configuration
[
'url'
],
'status_code'
:
status_code
}
)
self
.
assertEqual
(
expected_status_code_list
,
got_status_code_list
)
def
getMasterPartitionPath
(
self
):
# partition w/o etc/trafficserver, but with buildout.cfg
return
[
...
...
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