Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
Kirill Smelkov
ZODB
Commits
c1387130
Commit
c1387130
authored
May 29, 2003
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revise the test framework to use ZConfig instead of a custom argv.
parent
7ce5c0a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
10 deletions
+31
-10
trunk/src/ZEO/tests/testZEO.py
trunk/src/ZEO/tests/testZEO.py
+31
-10
No files found.
trunk/src/ZEO/tests/testZEO.py
View file @
c1387130
...
...
@@ -17,6 +17,7 @@
import
os
import
sys
import
time
import
random
import
socket
import
asyncore
import
tempfile
...
...
@@ -37,13 +38,8 @@ from ZODB.tests import StorageTestBase, BasicStorage, VersionStorage, \
PackableStorage
,
Synchronization
,
ConflictResolution
,
RevisionStorage
,
\
MTStorage
,
ReadOnlyStorage
# ZEO imports
from
ZEO.ClientStorage
import
ClientStorage
# ZEO test support
from
ZEO.tests
import
forker
,
Cache
# ZEO test mixin classes
from
ZEO.tests
import
CommitLockTests
,
ThreadTests
class
DummyDB
:
...
...
@@ -80,6 +76,26 @@ class MiscZEOTests:
finally
:
storage2
.
close
()
def
get_port
():
"""Return a port that is not in use.
Checks if a port is in use by trying to connect to it. Assumes it
is not in use if connect raises an exception.
Raises RuntimeError after 10 tries.
"""
for
i
in
range
(
10
):
port
=
random
.
randrange
(
20000
,
30000
)
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
try
:
try
:
s
.
connect
((
'localhost'
,
port
))
except
socket
.
error
:
# XXX check value of error?
return
port
finally
:
s
.
close
()
raise
RuntimeError
,
"Can't find port"
class
GenericTests
(
# Base class for all ZODB tests
...
...
@@ -109,15 +125,20 @@ class GenericTests(
def
setUp
(
self
):
zLOG
.
LOG
(
"testZEO"
,
zLOG
.
INFO
,
"setUp() %s"
%
self
.
id
())
zeoport
,
adminaddr
,
pid
=
forker
.
start_zeo_server
(
self
.
getConfig
())
port
=
get_port
()
zconf
=
forker
.
ZEOConfig
((
''
,
port
))
zport
,
adminaddr
,
pid
,
path
=
forker
.
start_zeo_server
(
self
.
getConfig
(),
zconf
,
port
)
self
.
_pids
=
[
pid
]
self
.
_servers
=
[
adminaddr
]
self
.
_storage
=
ClientStorage
(
zeoport
,
'1'
,
cache_size
=
20000000
,
self
.
_conf_path
=
path
self
.
_storage
=
ClientStorage
(
zport
,
'1'
,
cache_size
=
20000000
,
min_disconnect_poll
=
0.5
,
wait
=
1
)
self
.
_storage
.
registerDB
(
DummyDB
(),
None
)
def
tearDown
(
self
):
self
.
_storage
.
close
()
os
.
remove
(
self
.
_conf_path
)
for
server
in
self
.
_servers
:
forker
.
shutdown_zeo_server
(
server
)
if
hasattr
(
os
,
'waitpid'
):
...
...
@@ -150,7 +171,7 @@ class FileStorageTests(GenericTests):
def
getConfig
(
self
):
filename
=
self
.
__fs_base
=
tempfile
.
mktemp
()
return
"""
\
<filestorage>
<filestorage
1
>
path %s
</filestorage>
"""
%
filename
...
...
@@ -162,7 +183,7 @@ class BDBTests(FileStorageTests):
def
getConfig
(
self
):
self
.
_envdir
=
tempfile
.
mktemp
()
return
"""
\
<fullstorage>
<fullstorage
1
>
name %s
</fullstorage>
"""
%
self
.
_envdir
...
...
@@ -171,7 +192,7 @@ class MappingStorageTests(FileStorageTests):
"""ZEO backed by a Mapping storage."""
def
getConfig
(
self
):
return
"""<mappingstorage/>"""
return
"""<mappingstorage
1
/>"""
# Tests which MappingStorage can't possibly pass, because it doesn't
# support versions or undo.
...
...
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