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
Léo-Paul Géneau
slapos
Commits
1e9484bf
Commit
1e9484bf
authored
Aug 24, 2020
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
caddy-frontend/test: use getPromisePluginParameterDict from slapos.testing
parent
ec7222b5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
46 deletions
+7
-46
software/caddy-frontend/test/test.py
software/caddy-frontend/test/test.py
+7
-46
No files found.
software/caddy-frontend/test/test.py
View file @
1e9484bf
...
@@ -66,6 +66,7 @@ from cryptography.x509.oid import NameOID
...
@@ -66,6 +66,7 @@ from cryptography.x509.oid import NameOID
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
from
slapos.testing.utils
import
findFreeTCPPort
from
slapos.testing.utils
import
findFreeTCPPort
from
slapos.testing.utils
import
getPromisePluginParameterDict
setUpModule
,
SlapOSInstanceTestCase
=
makeModuleSetUpAndTestCaseClass
(
setUpModule
,
SlapOSInstanceTestCase
=
makeModuleSetUpAndTestCaseClass
(
os
.
path
.
abspath
(
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'software.cfg'
)))
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'software.cfg'
)))
...
@@ -243,44 +244,6 @@ def isHTTP2(domain, ip):
...
@@ -243,44 +244,6 @@ def isHTTP2(domain, ip):
return
'Using HTTP2, server supports multi-use'
in
err
return
'Using HTTP2, server supports multi-use'
in
err
def
getPluginParameterDict
(
software_path
,
filepath
):
"""Load the slapos monitor plugin and returns the configuration used by this plugin.
This allow to check that monitoring plugin are using a proper config.
"""
# This is implemented by creating a wrapper script that loads the plugin wrapper
# script and returns its `extra_config_dict`. This might have to be adjusted if
# internals of slapos promise plugins change.
bin_file
=
os
.
path
.
join
(
software_path
,
'bin'
,
'test-plugin-promise'
)
monitor_python_with_eggs
=
os
.
path
.
join
(
software_path
,
'bin'
,
'monitor-pythonwitheggs'
)
if
not
os
.
path
.
exists
(
monitor_python_with_eggs
):
raise
ValueError
(
"Monitoring stack's python does not exist at %s"
%
monitor_python_with_eggs
)
with
open
(
bin_file
,
'w'
)
as
f
:
f
.
write
(
"""#!%s
import os
import importlib
import sys
import json
filepath = sys.argv[1]
sys.path[0:0] = [os.path.dirname(filepath)]
filename = os.path.basename(filepath)
module = importlib.import_module(os.path.splitext(filename)[0])
print json.dumps(module.extra_config_dict)
"""
%
monitor_python_with_eggs
)
os
.
chmod
(
bin_file
,
0o755
)
result
=
subprocess_output
([
bin_file
,
filepath
]).
strip
()
try
:
return
json
.
loads
(
result
)
except
ValueError
,
e
:
raise
ValueError
(
"%s
\
n
Result was: %s"
%
(
e
,
result
))
class
TestDataMixin
(
object
):
class
TestDataMixin
(
object
):
def
getTrimmedProcessInfo
(
self
):
def
getTrimmedProcessInfo
(
self
):
return
'
\
n
'
.
join
(
sorted
([
return
'
\
n
'
.
join
(
sorted
([
...
@@ -3569,7 +3532,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
...
@@ -3569,7 +3532,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'check-_monitor-ipv6-test-ipv6-packet-list-test.py'
))[
0
]
'check-_monitor-ipv6-test-ipv6-packet-list-test.py'
))[
0
]
# get promise module and check that parameters are ok
# get promise module and check that parameters are ok
self
.
assertEqual
(
self
.
assertEqual
(
getP
luginParameterDict
(
self
.
software_path
,
monitor_file
),
getP
romisePluginParameterDict
(
monitor_file
),
{
{
'frequency'
:
'720'
,
'frequency'
:
'720'
,
'address'
:
'monitor-ipv6-test'
'address'
:
'monitor-ipv6-test'
...
@@ -3606,7 +3569,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
...
@@ -3606,7 +3569,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'check-_monitor-ipv4-test-ipv4-packet-list-test.py'
))[
0
]
'check-_monitor-ipv4-test-ipv4-packet-list-test.py'
))[
0
]
# get promise module and check that parameters are ok
# get promise module and check that parameters are ok
self
.
assertEqual
(
self
.
assertEqual
(
getP
luginParameterDict
(
self
.
software_path
,
monitor_file
),
getP
romisePluginParameterDict
(
monitor_file
),
{
{
'frequency'
:
'720'
,
'frequency'
:
'720'
,
'ipv4'
:
'true'
,
'ipv4'
:
'true'
,
...
@@ -4702,8 +4665,7 @@ class TestRe6stVerificationUrlDefaultSlave(SlaveHttpFrontendTestCase,
...
@@ -4702,8 +4665,7 @@ class TestRe6stVerificationUrlDefaultSlave(SlaveHttpFrontendTestCase,
re6st_connectivity_promise_file = re6st_connectivity_promise_list[0]
re6st_connectivity_promise_file = re6st_connectivity_promise_list[0]
self.assertEqual(
self.assertEqual(
getPluginParameterDict(
getPromisePluginParameterDict(re6st_connectivity_promise_file),
self.software_path, re6st_connectivity_promise_file),
{
{
'
url
': '
http
:
//
[
2001
:
67
c
:
1254
:
4
::
1
]
/
index
.
html
',
'
url
': '
http
:
//
[
2001
:
67
c
:
1254
:
4
::
1
]
/
index
.
html
',
}
}
...
@@ -4757,8 +4719,7 @@ class TestRe6stVerificationUrlSlave(SlaveHttpFrontendTestCase,
...
@@ -4757,8 +4719,7 @@ class TestRe6stVerificationUrlSlave(SlaveHttpFrontendTestCase,
re6st_connectivity_promise_file = re6st_connectivity_promise_list[0]
re6st_connectivity_promise_file = re6st_connectivity_promise_list[0]
self.assertEqual(
self.assertEqual(
getPluginParameterDict(
getPromisePluginParameterDict(re6st_connectivity_promise_file),
self.software_path, re6st_connectivity_promise_file),
{
{
'
url
': '
some
-
re6st
-
verification
-
url
',
'
url
': '
some
-
re6st
-
verification
-
url
',
}
}
...
@@ -6462,7 +6423,7 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase):
...
@@ -6462,7 +6423,7 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase):
# get promise module and check that parameters are ok
# get promise module and check that parameters are ok
self
.
assertEqual
(
self
.
assertEqual
(
getP
luginParameterDict
(
self
.
software_path
,
monitor_file
),
getP
romisePluginParameterDict
(
monitor_file
),
{
{
'frequency'
:
'720'
,
'frequency'
:
'720'
,
'ipv4'
:
'true'
,
'ipv4'
:
'true'
,
...
@@ -6506,7 +6467,7 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase):
...
@@ -6506,7 +6467,7 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase):
'check-_monitor-ipv6-test-unsafe-ipv6-packet-list-test.py'
))[
0
]
'check-_monitor-ipv6-test-unsafe-ipv6-packet-list-test.py'
))[
0
]
# get promise module and check that parameters are ok
# get promise module and check that parameters are ok
self
.
assertEqual
(
self
.
assertEqual
(
getP
luginParameterDict
(
self
.
software_path
,
monitor_file
),
getP
romisePluginParameterDict
(
monitor_file
),
{
{
'frequency'
:
'720'
,
'frequency'
:
'720'
,
'address'
:
'${section:option}
\
n
afternewline ipv6'
'address'
:
'${section:option}
\
n
afternewline ipv6'
...
...
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