Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
7a0fb57c
Commit
7a0fb57c
authored
Jan 15, 2025
by
Rafael Monnerat
👻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
caucasexx: update to findFreeTCPPortRange
parent
5c9d6d2e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
product/ERP5Type/tests/ERP5TypeCaucaseTestCase.py
product/ERP5Type/tests/ERP5TypeCaucaseTestCase.py
+17
-7
No files found.
product/ERP5Type/tests/ERP5TypeCaucaseTestCase.py
View file @
7a0fb57c
...
...
@@ -54,13 +54,23 @@ def canConnect(caucase_url):
return
False
return
True
def
findFreeTCPPort
(
ip
=
''
):
"""Find a free TCP port to listen to.
def
findFreeTCPPortRange
(
ip
=
''
,
count
=
1
):
# type: (str, int) -> int
"""Find a range of consecutive `count` free TCP ports 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
])
for
_
in
range
(
10
):
# retry 10 times
port
=
random
.
randrange
(
20000
,
30000
)
for
offset
in
range
(
count
):
with
closing
(
socket
.
socket
(
socket
.
AF_INET6
if
':'
in
ip
else
socket
.
AF_INET
,
socket
.
SOCK_STREAM
))
as
s
:
try
:
s
.
bind
((
ip
,
port
+
offset
))
except
OSError
:
port
=
None
break
if
port
is
None
:
raise
RuntimeError
(
"Can't find port"
)
return
port
def
retry
(
callback
,
try_count
=
10
,
try_delay
=
0.1
):
"""
...
...
@@ -89,7 +99,7 @@ class ERP5TypeCaucaseTestCase(ERP5TypeTestCase):
if
_ip
is
not
None
:
ip
=
_ip
break
port
=
findFreeTCPPort
(
ip
)
port
=
findFreeTCPPort
Range
(
ip
)
self
.
caucase_runtime
=
caucase_runtime
=
multiprocessing
.
Process
(
target
=
caucase
.
http
.
main
,
kwargs
=
dict
(
...
...
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