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
Carlos Ramos Carreño
neoppod
Commits
5b66a6a7
Commit
5b66a6a7
authored
Jan 03, 2017
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qa: rewrite test checking read-locks
parent
327bb1c0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
21 deletions
+38
-21
neo/tests/storage/testClientHandler.py
neo/tests/storage/testClientHandler.py
+1
-21
neo/tests/threaded/test.py
neo/tests/threaded/test.py
+37
-0
No files found.
neo/tests/storage/testClientHandler.py
View file @
5b66a6a7
...
@@ -16,12 +16,11 @@
...
@@ -16,12 +16,11 @@
import
unittest
import
unittest
from
mock
import
Mock
,
ReturnValues
from
mock
import
Mock
,
ReturnValues
from
collections
import
deque
from
..
import
NeoUnitTestBase
from
..
import
NeoUnitTestBase
from
neo.storage.app
import
Application
from
neo.storage.app
import
Application
from
neo.storage.handlers.client
import
ClientOperationHandler
from
neo.storage.handlers.client
import
ClientOperationHandler
from
neo.lib.util
import
p64
from
neo.lib.util
import
p64
from
neo.lib.protocol
import
INVALID_TID
,
INVALID_OID
,
Packets
,
LockState
from
neo.lib.protocol
import
INVALID_TID
,
Packets
,
LockState
class
StorageClientHandlerTests
(
NeoUnitTestBase
):
class
StorageClientHandlerTests
(
NeoUnitTestBase
):
...
@@ -31,11 +30,6 @@ class StorageClientHandlerTests(NeoUnitTestBase):
...
@@ -31,11 +30,6 @@ class StorageClientHandlerTests(NeoUnitTestBase):
# create an application object
# create an application object
config
=
self
.
getStorageConfiguration
(
master_number
=
1
)
config
=
self
.
getStorageConfiguration
(
master_number
=
1
)
self
.
app
=
Application
(
config
)
self
.
app
=
Application
(
config
)
self
.
app
.
transaction_dict
=
{}
self
.
app
.
store_lock_dict
=
{}
self
.
app
.
load_lock_dict
=
{}
self
.
app
.
event_queue
=
deque
()
self
.
app
.
event_queue_dict
=
{}
self
.
app
.
tm
=
Mock
({
'__contains__'
:
True
})
self
.
app
.
tm
=
Mock
({
'__contains__'
:
True
})
# handler
# handler
self
.
operation
=
ClientOperationHandler
(
self
.
app
)
self
.
operation
=
ClientOperationHandler
(
self
.
app
)
...
@@ -60,19 +54,6 @@ class StorageClientHandlerTests(NeoUnitTestBase):
...
@@ -60,19 +54,6 @@ class StorageClientHandlerTests(NeoUnitTestBase):
self
.
operation
.
askTransactionInformation
(
conn
,
INVALID_TID
)
self
.
operation
.
askTransactionInformation
(
conn
,
INVALID_TID
)
self
.
checkErrorPacket
(
conn
)
self
.
checkErrorPacket
(
conn
)
def
test_24_askObject1
(
self
):
# delayed response
conn
=
self
.
_getConnection
()
self
.
app
.
dm
=
Mock
()
self
.
app
.
tm
=
Mock
({
'loadLocked'
:
True
})
self
.
app
.
load_lock_dict
[
INVALID_OID
]
=
object
()
self
.
assertEqual
(
len
(
self
.
app
.
event_queue
),
0
)
self
.
operation
.
askObject
(
conn
,
oid
=
INVALID_OID
,
serial
=
INVALID_TID
,
tid
=
INVALID_TID
)
self
.
assertEqual
(
len
(
self
.
app
.
event_queue
),
1
)
self
.
checkNoPacketSent
(
conn
)
self
.
assertEqual
(
len
(
self
.
app
.
dm
.
mockGetNamedCalls
(
'getObject'
)),
0
)
def
test_25_askTIDs1
(
self
):
def
test_25_askTIDs1
(
self
):
# invalid offsets => error
# invalid offsets => error
app
=
self
.
app
app
=
self
.
app
...
@@ -110,7 +91,6 @@ class StorageClientHandlerTests(NeoUnitTestBase):
...
@@ -110,7 +91,6 @@ class StorageClientHandlerTests(NeoUnitTestBase):
undone_tid
=
self
.
getNextTID
()
undone_tid
=
self
.
getNextTID
()
# Keep 2 entries here, so we check findUndoTID is called only once.
# Keep 2 entries here, so we check findUndoTID is called only once.
oid_list
=
map
(
p64
,
(
1
,
2
))
oid_list
=
map
(
p64
,
(
1
,
2
))
obj2_data
=
[]
# Marker
self
.
app
.
tm
=
Mock
({
self
.
app
.
tm
=
Mock
({
'getObjectFromTransaction'
:
None
,
'getObjectFromTransaction'
:
None
,
})
})
...
...
neo/tests/threaded/test.py
View file @
5b66a6a7
...
@@ -431,6 +431,43 @@ class Test(NEOThreadedTest):
...
@@ -431,6 +431,43 @@ class Test(NEOThreadedTest):
finally
:
finally
:
cluster
.
stop
()
cluster
.
stop
()
def
testDelayedLoad
(
self
):
"""
Check that a storage node delays reads from the database,
when the requested data may still be in a temporary place.
"""
l
=
threading
.
Lock
()
l
.
acquire
()
idle
=
[]
def
askObject
(
orig
,
*
args
):
orig
(
*
args
)
idle
.
append
(
cluster
.
storage
.
em
.
isIdle
())
l
.
release
()
cluster
=
NEOCluster
()
try
:
cluster
.
start
()
t
,
c
=
cluster
.
getTransaction
()
r
=
c
.
root
()
r
[
''
]
=
''
with
Patch
(
ClientOperationHandler
,
askObject
=
askObject
):
with
cluster
.
master
.
filterConnection
(
cluster
.
storage
)
as
m2s
:
m2s
.
add
(
lambda
conn
,
packet
:
# delay unlock
isinstance
(
packet
,
Packets
.
NotifyUnlockInformation
))
t
.
commit
()
c
.
cacheMinimize
()
cluster
.
client
.
_cache
.
clear
()
load
=
self
.
newThread
(
r
.
_p_activate
)
l
.
acquire
()
l
.
acquire
()
# The request from the client is processed again
# (upon reception on unlock notification from the master),
# once exactly, and now with success.
load
.
join
()
self
.
assertEqual
(
idle
,
[
1
,
0
])
self
.
assertIn
(
''
,
r
)
finally
:
cluster
.
stop
()
def
test_notifyNodeInformation
(
self
):
def
test_notifyNodeInformation
(
self
):
# translated from MasterNotificationsHandlerTests
# translated from MasterNotificationsHandlerTests
# (neo.tests.client.testMasterHandler)
# (neo.tests.client.testMasterHandler)
...
...
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