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
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
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
Show 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
...
@@ -35,6 +35,7 @@ import tempfile
import
time
import
time
import
unittest
import
unittest
import
zc.lockfile
import
zc.lockfile
import
socket
from
cryptography
import
x509
from
cryptography
import
x509
from
cryptography.hazmat.backends
import
default_backend
from
cryptography.hazmat.backends
import
default_backend
...
@@ -50,6 +51,15 @@ import cli
...
@@ -50,6 +51,15 @@ import cli
import
updater
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
@
contextlib
.
contextmanager
def
captured_output
():
def
captured_output
():
new_out
,
new_err
=
StringIO
.
StringIO
(),
StringIO
.
StringIO
()
new_out
,
new_err
=
StringIO
.
StringIO
(),
StringIO
.
StringIO
()
...
@@ -136,7 +146,8 @@ class KedifaMixinCaucase(KedifaMixin):
...
@@ -136,7 +146,8 @@ class KedifaMixinCaucase(KedifaMixin):
self
.
pem
=
certificate_pem
+
key_pem
self
.
pem
=
certificate_pem
+
key_pem
def
setUpCaucase
(
self
):
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'
)
self
.
caucased
=
os
.
path
.
join
(
self
.
testdir
,
'caucased'
)
caucase_db
=
os
.
path
.
join
(
self
.
caucased
,
'caucase.sqlite'
)
caucase_db
=
os
.
path
.
join
(
self
.
caucased
,
'caucase.sqlite'
)
self
.
caucase_service
=
os
.
path
.
join
(
self
.
testdir
,
'service'
)
self
.
caucase_service
=
os
.
path
.
join
(
self
.
testdir
,
'service'
)
...
@@ -215,7 +226,7 @@ class KedifaMixinCaucase(KedifaMixin):
...
@@ -215,7 +226,7 @@ class KedifaMixinCaucase(KedifaMixin):
def
setUpKedifa
(
self
,
ip
):
def
setUpKedifa
(
self
,
ip
):
self
.
db
=
os
.
path
.
join
(
self
.
testdir
,
'pocket.sqlite'
)
self
.
db
=
os
.
path
.
join
(
self
.
testdir
,
'pocket.sqlite'
)
self
.
pidfile
=
os
.
path
.
join
(
self
.
testdir
,
'kedifa.pid'
)
self
.
pidfile
=
os
.
path
.
join
(
self
.
testdir
,
'kedifa.pid'
)
port
=
'16080'
port
=
findFreeTCPPort
(
ip
)
self
.
kedifa_runtime
=
multiprocessing
.
Process
(
self
.
kedifa_runtime
=
multiprocessing
.
Process
(
target
=
cli
.
http
,
target
=
cli
.
http
,
args
=
(
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