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
149708fd
Commit
149708fd
authored
Oct 05, 2023
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: flake8ize
parent
f5f7c68e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
kedifa/test.py
kedifa/test.py
+13
-10
No files found.
kedifa/test.py
View file @
149708fd
...
...
@@ -31,7 +31,6 @@ import requests
import
requests.exceptions
import
shutil
import
signal
import
sys
import
tarfile
import
tempfile
import
time
...
...
@@ -62,6 +61,7 @@ def findFreeTCPPort(ip=''):
s
.
bind
((
ip
,
0
))
return
str
(
s
.
getsockname
()[
1
])
def
retry
(
callback
,
try_count
=
10
,
try_delay
=
0.1
):
"""
Poll <callback> every <try_delay> for <try_count> times or until it returns
...
...
@@ -75,6 +75,7 @@ def retry(callback, try_count=10, try_delay=0.1):
time
.
sleep
(
try_delay
)
return
result
def
canConnect
(
caucase_url
):
"""
Returns True if a connection can be established to given address, False
...
...
@@ -97,13 +98,15 @@ class KedifaMixin(object):
_clean_caucased_snapshot
=
None
class
KedifaCaucaseMixin
(
KedifaMixin
):
def
_startCaucaseServer
(
self
,
argv
=
(),
timeout
=
10
):
"""
Start caucased server
"""
ip
,
port
=
os
.
environ
[
'SLAPOS_TEST_IPV6'
],
\
findFreeTCPPort
(
os
.
environ
[
'SLAPOS_TEST_IPV6'
])
ip
,
port
=
os
.
environ
[
'SLAPOS_TEST_IPV6'
],
findFreeTCPPort
(
os
.
environ
[
'SLAPOS_TEST_IPV6'
])
self
.
caucase_runtime
=
caucase_runtime
=
multiprocessing
.
Process
(
target
=
caucase
.
http
.
main
,
kwargs
=
dict
(
...
...
@@ -120,8 +123,8 @@ class KedifaCaucaseMixin(KedifaMixin):
if
not
retry
(
lambda
:
(
self
.
assertTrue
(
caucase_runtime
.
is_alive
())
or
canConnect
(
self
.
caucase_url
)
self
.
assertTrue
(
caucase_runtime
.
is_alive
())
or
canConnect
(
self
.
caucase_url
)
),
try_count
=
timeout
*
10
,
):
...
...
@@ -141,7 +144,6 @@ class KedifaCaucaseMixin(KedifaMixin):
if
caucase_runtime
.
is_alive
():
raise
ValueError
(
'%r does not wish to die'
%
(
caucase_runtime
,
))
def
createKey
(
self
):
key
=
rsa
.
generate_private_key
(
public_exponent
=
65537
,
key_size
=
2048
,
backend
=
default_backend
())
...
...
@@ -401,14 +403,15 @@ class KedifaIntegrationTest(KedifaCaucaseMixin, unittest.TestCase):
'Entry %r not found in log:
\
n
%s'
%
(
entry
,
''
.
join
(
log_line_list
)))
def
assertLastLogEntry
(
self
,
entry
):
tries_left
=
5
# try few times, as server can store the log line a bit
# later
# try few times, as server can store the log line a bit later
tries_left
=
5
while
True
:
with
open
(
self
.
logfile
)
as
fh
:
last_log_line
=
fh
.
readlines
()[
-
1
]
try
:
self
.
assertTrue
(
entry
in
last_log_line
,
'%r not found in %r'
%
(
entry
,
last_log_line
))
entry
in
last_log_line
,
'%r not found in %r'
%
(
entry
,
last_log_line
))
except
AssertionError
:
if
tries_left
==
0
:
raise
...
...
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