Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
Xavier Thompson
neoppod
Commits
ebabc92e
Commit
ebabc92e
authored
Aug 14, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add threaded test decorator to help writing backup tests
parent
00b76f60
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
27 deletions
+36
-27
neo/tests/threaded/testReplication.py
neo/tests/threaded/testReplication.py
+36
-27
No files found.
neo/tests/threaded/testReplication.py
View file @
ebabc92e
...
@@ -20,6 +20,7 @@ import time
...
@@ -20,6 +20,7 @@ import time
import
threading
import
threading
import
transaction
import
transaction
import
unittest
import
unittest
from
functools
import
wraps
from
neo.lib
import
logging
from
neo.lib
import
logging
from
neo.storage.checker
import
CHECK_COUNT
from
neo.storage.checker
import
CHECK_COUNT
from
neo.storage.replicator
import
Replicator
from
neo.storage.replicator
import
Replicator
...
@@ -34,6 +35,26 @@ from . import ConnectionFilter, NEOCluster, NEOThreadedTest, Patch, \
...
@@ -34,6 +35,26 @@ from . import ConnectionFilter, NEOCluster, NEOThreadedTest, Patch, \
from
neo.client.pool
import
CELL_CONNECTED
,
CELL_GOOD
from
neo.client.pool
import
CELL_CONNECTED
,
CELL_GOOD
def
backup_test
(
partitions
=
1
,
upstream_kw
=
{},
backup_kw
=
{}):
def
decorator
(
wrapped
):
def
wrapper
(
self
):
upstream
=
NEOCluster
(
partitions
,
**
upstream_kw
)
try
:
upstream
.
start
()
backup
=
NEOCluster
(
partitions
,
upstream
=
upstream
,
**
backup_kw
)
try
:
backup
.
start
()
backup
.
neoctl
.
setClusterState
(
ClusterStates
.
STARTING_BACKUP
)
backup
.
tic
()
wrapped
(
self
,
backup
)
finally
:
backup
.
stop
()
finally
:
upstream
.
stop
()
return
wraps
(
wrapped
)(
wrapper
)
return
decorator
class
ReplicationTests
(
NEOThreadedTest
):
class
ReplicationTests
(
NEOThreadedTest
):
def
checksumPartition
(
self
,
storage
,
partition
,
max_tid
=
MAX_TID
):
def
checksumPartition
(
self
,
storage
,
partition
,
max_tid
=
MAX_TID
):
...
@@ -220,7 +241,8 @@ class ReplicationTests(NEOThreadedTest):
...
@@ -220,7 +241,8 @@ class ReplicationTests(NEOThreadedTest):
finally
:
finally
:
upstream
.
stop
()
upstream
.
stop
()
def
testBackupUpstreamMasterDead
(
self
):
@
backup_test
()
def
testBackupUpstreamMasterDead
(
self
,
backup
):
"""Check proper behaviour when upstream master is unreachable
"""Check proper behaviour when upstream master is unreachable
More generally, this checks that when a handler raises when a connection
More generally, this checks that when a handler raises when a connection
...
@@ -228,32 +250,19 @@ class ReplicationTests(NEOThreadedTest):
...
@@ -228,32 +250,19 @@ class ReplicationTests(NEOThreadedTest):
be, for example, closed again after the exception is catched, without
be, for example, closed again after the exception is catched, without
assertion failure.
assertion failure.
"""
"""
upstream
=
NEOCluster
()
conn
,
=
backup
.
master
.
getConnectionList
(
backup
.
upstream
.
master
)
try
:
# trigger ping
upstream
.
start
()
conn
.
updateTimeout
(
1
)
importZODB
=
upstream
.
importZODB
()
self
.
assertFalse
(
conn
.
isPending
())
backup
=
NEOCluster
(
upstream
=
upstream
)
conn
.
checkTimeout
(
time
.
time
())
try
:
self
.
assertTrue
(
conn
.
isPending
())
backup
.
start
()
# force ping to have expired
backup
.
neoctl
.
setClusterState
(
ClusterStates
.
STARTING_BACKUP
)
conn
.
updateTimeout
(
1
)
backup
.
tic
()
# connection will be closed before upstream master has time
conn
,
=
backup
.
master
.
getConnectionList
(
upstream
.
master
)
# to answer
# trigger ping
backup
.
tic
(
force
=
1
)
conn
.
updateTimeout
(
1
)
new_conn
,
=
backup
.
master
.
getConnectionList
(
backup
.
upstream
.
master
)
self
.
assertFalse
(
conn
.
isPending
())
self
.
assertFalse
(
new_conn
is
conn
)
conn
.
checkTimeout
(
time
.
time
())
self
.
assertTrue
(
conn
.
isPending
())
# force ping to have expired
conn
.
updateTimeout
(
1
)
# connection will be closed before upstream master has time
# to answer
backup
.
tic
(
force
=
1
)
new_conn
,
=
backup
.
master
.
getConnectionList
(
upstream
.
master
)
self
.
assertFalse
(
new_conn
is
conn
)
finally
:
backup
.
stop
()
finally
:
upstream
.
stop
()
def
testReplicationAbortedBySource
(
self
):
def
testReplicationAbortedBySource
(
self
):
"""
"""
...
...
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