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
104
Merge Requests
104
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
5a702aa3
Commit
5a702aa3
authored
Oct 20, 2020
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/erp5/test: check that balancer uses HTTP 1.1 with keep alive
parent
74d18b9d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
software/erp5/test/test/test_balancer.py
software/erp5/test/test/test_balancer.py
+37
-0
No files found.
software/erp5/test/test/test_balancer.py
View file @
5a702aa3
...
...
@@ -17,6 +17,7 @@ import idna
import
mock
import
OpenSSL.SSL
import
pexpect
import
psutil
import
requests
from
cryptography
import
x509
from
cryptography.hazmat.backends
import
default_backend
...
...
@@ -350,6 +351,42 @@ class TestBalancer(BalancerTestCase):
'backend_web_server1'
)
class
TestHTTP
(
BalancerTestCase
):
"""Check HTTP protocol
"""
__partition_reference__
=
'h'
def
test_http_version
(
self
):
# type: () -> None
# https://stackoverflow.com/questions/37012486/python-3-x-how-to-get-http-version-using-requests-library/37012810
self
.
assertEqual
(
requests
.
get
(
self
.
default_balancer_url
,
verify
=
False
).
raw
.
version
,
11
)
def
test_keep_alive
(
self
):
# type: () -> None
# when doing two requests, connection is established only once
session
=
requests
.
Session
()
session
.
verify
=
False
# do a first request, which establish a first connection
session
.
get
(
self
.
default_balancer_url
).
raise_for_status
()
# "break" new connection method and check we can make another request
with
mock
.
patch
(
"requests.packages.urllib3.connectionpool.HTTPSConnectionPool._new_conn"
,
)
as
new_conn
:
session
.
get
(
self
.
default_balancer_url
).
raise_for_status
()
new_conn
.
assert_not_called
()
parsed_url
=
urlparse
.
urlparse
(
self
.
default_balancer_url
)
# check that we have an open file for the ip connection
self
.
assertTrue
([
c
for
c
in
psutil
.
Process
(
os
.
getpid
()).
connections
()
if
c
.
status
==
'ESTABLISHED'
and
c
.
raddr
.
ip
==
parsed_url
.
hostname
and
c
.
raddr
.
port
==
parsed_url
.
port
])
class
TestTLS
(
BalancerTestCase
):
"""Check TLS
"""
...
...
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