Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
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
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos
Commits
47b8cf4f
Commit
47b8cf4f
authored
Sep 14, 2020
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5 wip
parent
0c9b98ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
21 deletions
+44
-21
software/erp5/test/test/test_balancer.py
software/erp5/test/test/test_balancer.py
+44
-21
No files found.
software/erp5/test/test/test_balancer.py
View file @
47b8cf4f
...
...
@@ -62,8 +62,8 @@ class CaucaseService(ManagedResource):
# type: () -> None
# start a caucased and server certificate.
software_release_root_path
=
os
.
path
.
join
(
self
.
_cls
.
slap
.
_software_root
,
hashlib
.
md5
(
self
.
_cls
.
getSoftwareURL
().
encode
()).
hexdigest
(),
self
.
_cls
.
slap
.
_software_root
,
hashlib
.
md5
(
self
.
_cls
.
getSoftwareURL
().
encode
()).
hexdigest
(),
)
caucased_path
=
os
.
path
.
join
(
software_release_root_path
,
'bin'
,
'caucased'
)
...
...
@@ -76,15 +76,15 @@ class CaucaseService(ManagedResource):
backend_caucased_netloc
=
'%s:%s'
%
(
self
.
_cls
.
_ipv4_address
,
findFreeTCPPort
(
self
.
_cls
.
_ipv4_address
))
self
.
url
=
'http://'
+
backend_caucased_netloc
self
.
_caucased_process
=
subprocess
.
Popen
(
[
caucased_path
,
'--db'
,
os
.
path
.
join
(
caucased_dir
,
'caucase.sqlite'
),
'--server-key'
,
os
.
path
.
join
(
caucased_dir
,
'server.key.pem'
),
'--netloc'
,
backend_caucased_netloc
,
'--service-auto-approve-count'
,
'1'
,
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
[
caucased_path
,
'--db'
,
os
.
path
.
join
(
caucased_dir
,
'caucase.sqlite'
),
'--server-key'
,
os
.
path
.
join
(
caucased_dir
,
'server.key.pem'
),
'--netloc'
,
backend_caucased_netloc
,
'--service-auto-approve-count'
,
'1'
,
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
)
for
_
in
range
(
10
):
try
:
...
...
@@ -127,15 +127,15 @@ class BalancerTestCase(ERP5InstanceTestCase):
'apachedex-promise-threshold'
:
100
,
'haproxy-server-check-path'
:
'/'
,
'zope-family-dict'
:
{
'default'
:
[
'dummy_http_server'
],
# TODO: dummy_http_server is bad name
'default'
:
[
'dummy_http_server'
],
# TODO: dummy_http_server is bad name
},
'dummy_http_server'
:
[[
cls
.
getManagedResource
(
"backend_web_server"
,
EchoHTTPServer
).
netloc
,
1
,
False
]],
'backend-path-dict'
:
{
'default'
:
'/'
,
'default'
:
'/'
,
},
'ssl-authentication-dict'
:
{},
'ssl'
:
{
'caucase-url'
:
cls
.
getManagedResource
(
"caucase"
,
CaucaseService
).
url
,
'caucase-url'
:
cls
.
getManagedResource
(
"caucase"
,
CaucaseService
).
url
,
}
}
...
...
@@ -170,7 +170,7 @@ class TestAccessLog(BalancerTestCase, CrontabMixin):
parameter_dict
[
'dummy_http_server'
]
=
[[
cls
.
getManagedResource
(
"slow_web_server"
,
SlowHTTPServer
).
netloc
,
1
,
False
]]
return
parameter_dict
def
test_access_log
(
self
):
def
test_access_log
_format
(
self
):
# type: () -> None
balancer_url
=
json
.
loads
(
self
.
computer_partition
.
getConnectionParameterDict
()[
'_'
])[
'default'
]
requests
.
get
(
...
...
@@ -194,6 +194,9 @@ class TestAccessLog(BalancerTestCase, CrontabMixin):
self.assertLess(request_time, 4000000)
import pdb; pdb.set_trace()
# TODO: log rotation
# TODO: apachedex on logs
class CaucaseClientCertificate(ManagedResource):
ca_crt_file = None # type: str
...
...
@@ -231,9 +234,9 @@ class CaucaseClientCertificate(ManagedResource):
]
key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048,
backend=default_backend()
public_exponent=65537,
key_size=2048,
backend=default_backend()
)
with open(self.key_file, '
wb
') as f:
f.write(
...
...
@@ -259,7 +262,7 @@ class CaucaseClientCertificate(ManagedResource):
csr_id = subprocess.check_output(
cas_args + [
'
--
send
-
csr
', self.csr_file,
'
--
send
-
csr
', self.csr_file,
],
).split()[0]
assert csr_id
...
...
@@ -267,7 +270,7 @@ class CaucaseClientCertificate(ManagedResource):
for _ in range(10):
if not subprocess.call(
cas_args + [
'
--
get
-
crt
', csr_id, self.cert_file,
'
--
get
-
crt
', csr_id, self.cert_file,
],
) == 0:
break
...
...
@@ -335,4 +338,24 @@ class TestFrontendXForwardedFor(BalancerTestCase):
verify=False,
)
del TestAccessLog
\ No newline at end of file
del TestAccessLog
'''before
----------------------------------------------------------------------
Ran 26 tests in 1195.545s
OK
________________________________________________________
Executed in 19.97 mins fish external
usr time 10.32 secs 1657.00 micros 10.31 secs
sys time 3.18 secs 235.00 micros 3.18 secs
/srv/slapgrid/slappart4/srv/slapos/soft/c63ba7265399450b28f9ea6d5667a5e7/eggs/slapos.cookbook-1.0.152-py2.7.egg
/srv/slapgrid/slappart4/srv/slapos/inst/slappart0/tmp/soft/c63ba7265399450b28f9ea6d5667a5e7/eggs/slapos.cookbook-1.0.152-py2.7.egg/slapos/recipe/switch_softwaretype.py
Ran 2 tests in 188.451s
Ran 2 tests in 161.661s
'''
\ No newline at end of file
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