Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
7e958f5b
Commit
7e958f5b
authored
Jul 08, 2016
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use 127.0.0.1 and port 0 in more places
parent
1ce6fd78
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
53 deletions
+20
-53
src/ZEO/tests/ConnectionTests.py
src/ZEO/tests/ConnectionTests.py
+3
-3
src/ZEO/tests/client-config.test
src/ZEO/tests/client-config.test
+1
-1
src/ZEO/tests/forker.py
src/ZEO/tests/forker.py
+8
-38
src/ZEO/tests/testZEO.py
src/ZEO/tests/testZEO.py
+6
-9
src/ZEO/tests/testssl.py
src/ZEO/tests/testssl.py
+2
-2
No files found.
src/ZEO/tests/ConnectionTests.py
View file @
7e958f5b
...
...
@@ -84,7 +84,7 @@ class CommonSetupTearDown(StorageTestBase):
self
.
file
=
'storage_conf'
self
.
_servers
=
[]
self
.
caches
=
[]
self
.
addr
=
[(
'
localhost
'
,
0
)]
self
.
addr
=
[(
'
127.0.0.1
'
,
0
)]
self
.
startServer
()
def
tearDown
(
self
):
...
...
@@ -127,7 +127,7 @@ class CommonSetupTearDown(StorageTestBase):
self
.
addr
.
append
(
self
.
_getAddr
())
def
_getAddr
(
self
):
return
'
localhost
'
,
forker
.
get_port
(
self
)
return
'
127.0.0.1
'
,
forker
.
get_port
(
self
)
def
getConfig
(
self
,
path
,
create
,
read_only
):
raise
NotImplementedError
...
...
@@ -966,7 +966,7 @@ class TimeoutTests(CommonSetupTearDown):
self
.
assertRaises
(
ClientDisconnected
,
storage
.
tpc_finish
,
txn
)
# Make sure it's logged as CRITICAL
for
line
in
open
(
"server
-0
.log"
):
for
line
in
open
(
"server.log"
):
if
((
'Transaction timeout after'
in
line
)
and
(
'CRITICAL ZEO.StorageServer'
in
line
)
):
...
...
src/ZEO/tests/client-config.test
View file @
7e958f5b
...
...
@@ -18,7 +18,7 @@ The simplest client configuration specified a server address:
>>>
storage
.
getName
(),
storage
.
__class__
.
__name__
...
# doctest: +ELLIPSIS
(
"[('
localhost
', ...)] (connected)"
,
'ClientStorage'
)
(
"[('
127.0.0.1
', ...)] (connected)"
,
'ClientStorage'
)
>>>
storage
.
blob_dir
>>>
storage
.
_storage
...
...
src/ZEO/tests/forker.py
View file @
7e958f5b
...
...
@@ -37,7 +37,7 @@ class ZEOConfig:
if
isinstance
(
addr
,
str
):
self
.
logpath
=
addr
+
'.log'
else
:
self
.
logpath
=
'server
-%s.log'
%
addr
[
1
]
self
.
logpath
=
'server
.log'
addr
=
'%s:%s'
%
addr
self
.
address
=
addr
self
.
read_only
=
None
...
...
@@ -195,10 +195,10 @@ def start_zeo_server(storage_conf=None, zeo_conf=None, port=None, keep=False,
if
zeo_conf
is
None
or
isinstance
(
zeo_conf
,
dict
):
if
port
is
None
:
raise
AssertionError
(
"The port wasn't specified"
)
port
=
0
if
isinstance
(
port
,
int
):
addr
=
'
localhost
'
,
port
addr
=
'
127.0.0.1
'
,
port
else
:
addr
=
port
...
...
@@ -256,7 +256,7 @@ else:
def
shutdown_zeo_server
(
stop
):
stop
()
def
get_port
(
test
=
None
):
def
get_port
(
ignored
=
None
):
"""Return a port that is not in use.
Checks if a port is in use by trying to connect to it. Assumes it
...
...
@@ -267,23 +267,20 @@ def get_port(test=None):
Raises RuntimeError after 10 tries.
"""
if
test
is
not
None
:
return
get_port2
(
test
)
for
i
in
range
(
10
):
port
=
random
.
randrange
(
20000
,
30000
)
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s1
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
try
:
try
:
s
.
connect
((
'
localhost
'
,
port
))
s
.
connect
((
'
127.0.0.1
'
,
port
))
except
socket
.
error
:
pass
# Perhaps we should check value of error too.
else
:
continue
try
:
s1
.
connect
((
'
localhost
'
,
port
+
1
))
s1
.
connect
((
'
127.0.0.1
'
,
port
+
1
))
except
socket
.
error
:
pass
# Perhaps we should check value of error too.
else
:
...
...
@@ -296,35 +293,11 @@ def get_port(test=None):
s1
.
close
()
raise
RuntimeError
(
"Can't find port"
)
def
get_port2
(
test
):
for
i
in
range
(
10
):
while
1
:
port
=
random
.
randrange
(
20000
,
30000
)
if
port
%
3
==
0
:
break
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
try
:
s
.
bind
((
'localhost'
,
port
+
2
))
except
socket
.
error
as
e
:
if
e
.
args
[
0
]
!=
errno
.
EADDRINUSE
:
raise
s
.
close
()
continue
if
not
(
can_connect
(
port
)
or
can_connect
(
port
+
1
)):
zope
.
testing
.
setupstack
.
register
(
test
,
s
.
close
)
return
port
s
.
close
()
raise
RuntimeError
(
"Can't find port"
)
def
can_connect
(
port
):
c
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
try
:
try
:
c
.
connect
((
'
localhost
'
,
port
))
c
.
connect
((
'
127.0.0.1
'
,
port
))
except
socket
.
error
:
return
False
# Perhaps we should check value of error too.
else
:
...
...
@@ -346,7 +319,7 @@ def setUp(test):
"""
if
port
is
None
:
if
addr
is
None
:
port
=
get_port2
(
test
)
port
=
0
else
:
port
=
addr
[
1
]
elif
addr
is
not
None
:
...
...
@@ -367,9 +340,6 @@ def setUp(test):
test
.
globs
[
'start_server'
]
=
start_server
def
get_port
():
return
get_port2
(
test
)
test
.
globs
[
'get_port'
]
=
get_port
def
stop_server
(
stop
):
...
...
src/ZEO/tests/testZEO.py
View file @
7e958f5b
...
...
@@ -1025,7 +1025,7 @@ def dont_log_poskeyerrors_on_server():
>>> cs.close()
>>> stop_server(admin)
>>> with open('server
-%s.log' % addr[1]
) as f:
>>> with open('server
.log'
) as f:
... 'POSKeyError' in f.read()
False
"""
...
...
@@ -1199,7 +1199,7 @@ constructor.
>>> db.close()
>>> @wait_until
... def check_for_test_label_1():
... with open('server
-%s.log' % addr[1]
) as f:
... with open('server
.log'
) as f:
... for line in f:
... if 'test-label-1' in line:
... print(line.split()[1:4])
...
...
@@ -1220,8 +1220,7 @@ You can specify the client label via a configuration file as well:
>>> db.close()
>>> @wait_until
... def check_for_test_label_2():
... with open('server-%s.log' % addr[1]) as f:
... for line in open('server-%s.log' % addr[1]):
... for line in open('server.log'):
... if 'test-label-2' in line:
... print(line.split()[1:4])
... return True
...
...
@@ -1520,7 +1519,6 @@ class ServerManagingClientStorage(ClientStorage):
else
:
server_blob_dir
=
'server-'
+
blob_dir
self
.
globs
=
{}
port
=
forker
.
get_port2
(
self
)
addr
,
stop
=
forker
.
start_zeo_server
(
"""
<blobstorage>
...
...
@@ -1531,7 +1529,6 @@ class ServerManagingClientStorage(ClientStorage):
</filestorage>
</blobstorage>
"""
%
(
server_blob_dir
,
name
+
'.fs'
,
extrafsoptions
),
port
=
port
,
)
zope
.
testing
.
setupstack
.
register
(
self
,
stop
)
if
shared
:
...
...
src/ZEO/tests/testssl.py
View file @
7e958f5b
...
...
@@ -298,7 +298,7 @@ def ssl_client(**ssl_settings):
"""%import ZEO
<clientstorage>
server
localhost
:0
server
127.0.0.1
:0
{}
</clientstorage>
"""
.
format
(
ssl_conf
(
**
ssl_settings
))
...
...
@@ -309,7 +309,7 @@ def create_server(**ssl_settings):
f
.
write
(
"""
<zeo>
address
localhost
:0
address
127.0.0.1
:0
{}
</zeo>
<mappingstorage>
...
...
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