Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kedifa
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
Jérome Perrin
kedifa
Commits
1d871c10
Commit
1d871c10
authored
Jul 31, 2019
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: Randomize ports on each run
parent
2ec3c141
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
kedifa/test.py
kedifa/test.py
+13
-2
No files found.
kedifa/test.py
View file @
1d871c10
...
...
@@ -35,6 +35,7 @@ import tempfile
import
time
import
unittest
import
zc.lockfile
import
socket
from
cryptography
import
x509
from
cryptography.hazmat.backends
import
default_backend
...
...
@@ -50,6 +51,15 @@ import cli
import
updater
def
findFreeTCPPort
(
ip
=
''
):
"""Find a free TCP port to listen to.
"""
family
=
socket
.
AF_INET6
if
':'
in
ip
else
socket
.
AF_INET
with
contextlib
.
closing
(
socket
.
socket
(
family
,
socket
.
SOCK_STREAM
))
as
s
:
s
.
bind
((
ip
,
0
))
return
str
(
s
.
getsockname
()[
1
])
@
contextlib
.
contextmanager
def
captured_output
():
new_out
,
new_err
=
StringIO
.
StringIO
(),
StringIO
.
StringIO
()
...
...
@@ -136,7 +146,8 @@ class KedifaMixinCaucase(KedifaMixin):
self
.
pem
=
certificate_pem
+
key_pem
def
setUpCaucase
(
self
):
ip
,
port
=
os
.
environ
[
'SLAPOS_TEST_IPV6'
],
15080
ip
,
port
=
os
.
environ
[
'SLAPOS_TEST_IPV6'
],
\
findFreeTCPPort
(
os
.
environ
[
'SLAPOS_TEST_IPV6'
])
self
.
caucased
=
os
.
path
.
join
(
self
.
testdir
,
'caucased'
)
caucase_db
=
os
.
path
.
join
(
self
.
caucased
,
'caucase.sqlite'
)
self
.
caucase_service
=
os
.
path
.
join
(
self
.
testdir
,
'service'
)
...
...
@@ -215,7 +226,7 @@ class KedifaMixinCaucase(KedifaMixin):
def
setUpKedifa
(
self
,
ip
):
self
.
db
=
os
.
path
.
join
(
self
.
testdir
,
'pocket.sqlite'
)
self
.
pidfile
=
os
.
path
.
join
(
self
.
testdir
,
'kedifa.pid'
)
port
=
'16080'
port
=
findFreeTCPPort
(
ip
)
self
.
kedifa_runtime
=
multiprocessing
.
Process
(
target
=
cli
.
http
,
args
=
(
...
...
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