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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
neoppod
Commits
bf173404
Commit
bf173404
authored
Jan 17, 2017
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qa: fix resource leak with loopback connections in threaded tests
parent
3bfd4cd4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
28 deletions
+25
-28
neo/tests/threaded/__init__.py
neo/tests/threaded/__init__.py
+12
-14
neo/tests/threaded/test.py
neo/tests/threaded/test.py
+8
-8
neo/tests/threaded/testSSL.py
neo/tests/threaded/testSSL.py
+5
-6
No files found.
neo/tests/threaded/__init__.py
View file @
bf173404
...
@@ -321,7 +321,8 @@ class ServerNode(Node):
...
@@ -321,7 +321,8 @@ class ServerNode(Node):
master_nodes
=
kw
.
get
(
'master_nodes'
,
cluster
.
master_nodes
)
master_nodes
=
kw
.
get
(
'master_nodes'
,
cluster
.
master_nodes
)
name
=
kw
.
get
(
'name'
,
cluster
.
name
)
name
=
kw
.
get
(
'name'
,
cluster
.
name
)
port
=
address
[
1
]
port
=
address
[
1
]
self
.
_node_list
[
port
]
=
weakref
.
proxy
(
self
)
if
address
is
not
BIND
:
self
.
_node_list
[
port
]
=
weakref
.
proxy
(
self
)
self
.
_init_args
=
init_args
=
kw
.
copy
()
self
.
_init_args
=
init_args
=
kw
.
copy
()
init_args
[
'cluster'
]
=
cluster
init_args
[
'cluster'
]
=
cluster
init_args
[
'address'
]
=
address
init_args
[
'address'
]
=
address
...
@@ -933,20 +934,17 @@ class NEOThreadedTest(NeoTestBase):
...
@@ -933,20 +934,17 @@ class NEOThreadedTest(NeoTestBase):
tic
=
Serialized
.
tic
tic
=
Serialized
.
tic
@
contextmanager
def
getLoopbackConnection
(
self
):
def
getLoopbackConnection
(
self
):
app
=
MasterApplication
(
getSSL
=
NEOCluster
.
SSL
,
app
=
MasterApplication
(
address
=
BIND
,
getReplicas
=
0
,
getPartitions
=
1
)
getSSL
=
NEOCluster
.
SSL
,
getReplicas
=
0
,
getPartitions
=
1
)
handler
=
EventHandler
(
app
)
try
:
app
.
listening_conn
=
ListeningConnection
(
app
,
handler
,
app
.
server
)
handler
=
EventHandler
(
app
)
node
=
app
.
nm
.
createMaster
(
address
=
app
.
listening_conn
.
getAddress
(),
app
.
listening_conn
=
ListeningConnection
(
app
,
handler
,
app
.
server
)
uuid
=
app
.
uuid
)
yield
ClientConnection
(
app
,
handler
,
app
.
nm
.
createMaster
(
conn
=
ClientConnection
.
__new__
(
ClientConnection
)
address
=
app
.
listening_conn
.
getAddress
(),
uuid
=
app
.
uuid
))
def
reset
():
finally
:
conn
.
__dict__
.
clear
()
app
.
close
()
conn
.
__init__
(
app
,
handler
,
node
)
conn
.
reset
=
reset
reset
()
return
conn
def
getUnpickler
(
self
,
conn
):
def
getUnpickler
(
self
,
conn
):
reader
=
conn
.
_reader
reader
=
conn
.
_reader
...
...
neo/tests/threaded/test.py
View file @
bf173404
...
@@ -1209,17 +1209,17 @@ class Test(NEOThreadedTest):
...
@@ -1209,17 +1209,17 @@ class Test(NEOThreadedTest):
self
.
assertEqual
(
s
.
dm
.
getLastIDs
()[
0
],
truncate_tid
)
self
.
assertEqual
(
s
.
dm
.
getLastIDs
()[
0
],
truncate_tid
)
def
testConnectionTimeout
(
self
):
def
testConnectionTimeout
(
self
):
conn
=
self
.
getLoopbackConnection
()
with
self
.
getLoopbackConnection
()
as
conn
:
conn
.
KEEP_ALIVE
conn
.
KEEP_ALIVE
with
Patch
(
conn
,
KEEP_ALIVE
=
0
):
while
conn
.
connecting
:
conn
.
em
.
poll
(
1
)
def
onTimeout
(
orig
):
def
onTimeout
(
orig
):
conn
.
idle
()
conn
.
idle
()
orig
()
orig
()
with
Patch
(
conn
,
onTimeout
=
onTimeout
):
with
Patch
(
conn
,
KEEP_ALIVE
=
0
):
conn
.
em
.
poll
(
1
)
while
conn
.
connecting
:
self
.
assertFalse
(
conn
.
isClosed
())
conn
.
em
.
poll
(
1
)
with
Patch
(
conn
,
onTimeout
=
onTimeout
):
conn
.
em
.
poll
(
1
)
self
.
assertFalse
(
conn
.
isClosed
())
@
with_cluster
()
@
with_cluster
()
def
testClientDisconnectedFromMaster
(
self
,
cluster
):
def
testClientDisconnectedFromMaster
(
self
,
cluster
):
...
...
neo/tests/threaded/testSSL.py
View file @
bf173404
...
@@ -36,12 +36,8 @@ class SSLTests(SSLMixin, test.Test):
...
@@ -36,12 +36,8 @@ class SSLTests(SSLMixin, test.Test):
testDeadlockAvoidance
=
None
testDeadlockAvoidance
=
None
testUndoConflict
=
testUndoConflictDuringStore
=
None
testUndoConflict
=
testUndoConflictDuringStore
=
None
def
testAbortConnection
(
self
):
def
testAbortConnection
(
self
,
after_handshake
=
1
):
for
after_handshake
in
1
,
0
:
with
self
.
getLoopbackConnection
()
as
conn
:
try
:
conn
.
reset
()
except
UnboundLocalError
:
conn
=
self
.
getLoopbackConnection
()
conn
.
ask
(
Packets
.
Ping
())
conn
.
ask
(
Packets
.
Ping
())
connector
=
conn
.
getConnector
()
connector
=
conn
.
getConnector
()
del
connector
.
connect_limit
[
connector
.
addr
]
del
connector
.
connect_limit
[
connector
.
addr
]
...
@@ -58,6 +54,9 @@ class SSLTests(SSLMixin, test.Test):
...
@@ -58,6 +54,9 @@ class SSLTests(SSLMixin, test.Test):
conn
.
em
.
poll
(
1
)
conn
.
em
.
poll
(
1
)
self
.
assertIs
(
conn
.
getConnector
(),
None
)
self
.
assertIs
(
conn
.
getConnector
(),
None
)
def
testAbortConnectionBeforeHandshake
(
self
):
self
.
testAbortConnection
(
0
)
class
SSLReplicationTests
(
SSLMixin
,
testReplication
.
ReplicationTests
):
class
SSLReplicationTests
(
SSLMixin
,
testReplication
.
ReplicationTests
):
# do not repeat slowest tests with SSL
# do not repeat slowest tests with SSL
testBackupNodeLost
=
testBackupNormalCase
=
None
testBackupNodeLost
=
testBackupNormalCase
=
None
...
...
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