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
23b9544d
Commit
23b9544d
authored
Dec 01, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove dead code found by coverage
parent
1e4a4178
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
45 deletions
+16
-45
neo/lib/node.py
neo/lib/node.py
+2
-6
neo/tests/client/testClientApp.py
neo/tests/client/testClientApp.py
+3
-12
neo/tests/master/testElectionHandler.py
neo/tests/master/testElectionHandler.py
+0
-11
neo/tests/master/testRecovery.py
neo/tests/master/testRecovery.py
+4
-0
neo/tests/master/testTransactions.py
neo/tests/master/testTransactions.py
+3
-3
neo/tests/testNodes.py
neo/tests/testNodes.py
+4
-13
No files found.
neo/lib/node.py
View file @
23b9544d
...
@@ -281,8 +281,8 @@ class NodeManager(object):
...
@@ -281,8 +281,8 @@ class NodeManager(object):
self
.
_address_dict
.
pop
(
node
.
getAddress
(),
None
)
self
.
_address_dict
.
pop
(
node
.
getAddress
(),
None
)
# - a master known by address but without UUID
# - a master known by address but without UUID
self
.
_uuid_dict
.
pop
(
node
.
getUUID
(),
None
)
self
.
_uuid_dict
.
pop
(
node
.
getUUID
(),
None
)
self
.
_
_dropSet
(
self
.
_state_dict
,
node
.
getState
(),
node
)
self
.
_
state_dict
[
node
.
getState
()].
remove
(
node
)
self
.
_
_dropSet
(
self
.
_type_dict
,
node
.
getType
(),
node
)
self
.
_
type_dict
[
node
.
getType
()].
remove
(
node
)
uuid
=
node
.
getUUID
()
uuid
=
node
.
getUUID
()
if
node
.
isMaster
()
and
self
.
_master_db
is
not
None
:
if
node
.
isMaster
()
and
self
.
_master_db
is
not
None
:
self
.
_master_db
.
discard
(
node
.
getAddress
())
self
.
_master_db
.
discard
(
node
.
getAddress
())
...
@@ -305,10 +305,6 @@ class NodeManager(object):
...
@@ -305,10 +305,6 @@ class NodeManager(object):
def
_updateUUID
(
self
,
node
,
old_uuid
):
def
_updateUUID
(
self
,
node
,
old_uuid
):
self
.
__update
(
self
.
_uuid_dict
,
old_uuid
,
node
.
getUUID
(),
node
)
self
.
__update
(
self
.
_uuid_dict
,
old_uuid
,
node
.
getUUID
(),
node
)
def
__dropSet
(
self
,
set_dict
,
key
,
node
):
if
key
in
set_dict
:
set_dict
[
key
].
remove
(
node
)
def
__updateSet
(
self
,
set_dict
,
old_key
,
new_key
,
node
):
def
__updateSet
(
self
,
set_dict
,
old_key
,
new_key
,
node
):
""" Update a set index from old to new key """
""" Update a set index from old to new key """
if
old_key
in
set_dict
:
if
old_key
in
set_dict
:
...
...
neo/tests/client/testClientApp.py
View file @
23b9544d
...
@@ -57,9 +57,6 @@ def _ask(self, conn, packet, handler=None, **kw):
...
@@ -57,9 +57,6 @@ def _ask(self, conn, packet, handler=None, **kw):
handler
.
dispatch
(
conn
,
conn
.
fakeReceived
())
handler
.
dispatch
(
conn
,
conn
.
fakeReceived
())
return
self
.
getHandlerData
()
return
self
.
getHandlerData
()
def
resolving_tryToResolveConflict
(
oid
,
conflict_serial
,
serial
,
data
):
return
data
def
failing_tryToResolveConflict
(
oid
,
conflict_serial
,
serial
,
data
):
def
failing_tryToResolveConflict
(
oid
,
conflict_serial
,
serial
,
data
):
raise
ConflictError
raise
ConflictError
...
@@ -85,10 +82,8 @@ class ClientApplicationTests(NeoUnitTestBase):
...
@@ -85,10 +82,8 @@ class ClientApplicationTests(NeoUnitTestBase):
# some helpers
# some helpers
def
_begin
(
self
,
app
,
txn
,
tid
=
None
):
def
_begin
(
self
,
app
,
txn
,
tid
):
txn_context
=
app
.
_txn_container
.
new
(
txn
)
txn_context
=
app
.
_txn_container
.
new
(
txn
)
if
tid
is
None
:
tid
=
self
.
makeTID
()
txn_context
[
'ttid'
]
=
tid
txn_context
[
'ttid'
]
=
tid
return
txn_context
return
txn_context
...
@@ -315,7 +310,7 @@ class ClientApplicationTests(NeoUnitTestBase):
...
@@ -315,7 +310,7 @@ class ClientApplicationTests(NeoUnitTestBase):
app
.
store
(
oid
,
tid
,
'DATA'
,
None
,
txn
)
app
.
store
(
oid
,
tid
,
'DATA'
,
None
,
txn
)
self
.
checkAskStoreObject
(
conn
)
self
.
checkAskStoreObject
(
conn
)
txn_context
[
'queue'
].
put
((
conn
,
packet
,
{}))
txn_context
[
'queue'
].
put
((
conn
,
packet
,
{}))
app
.
waitStoreResponses
(
txn_context
,
resolving_tryToResolveConflict
)
app
.
waitStoreResponses
(
txn_context
,
None
)
# no conflict in this test
self
.
assertEqual
(
txn_context
[
'object_stored_counter_dict'
][
oid
],
self
.
assertEqual
(
txn_context
[
'object_stored_counter_dict'
][
oid
],
{
tid
:
{
uuid
}})
{
tid
:
{
uuid
}})
self
.
assertEqual
(
txn_context
[
'cache_dict'
][
oid
],
'DATA'
)
self
.
assertEqual
(
txn_context
[
'cache_dict'
][
oid
],
'DATA'
)
...
@@ -541,13 +536,9 @@ class ClientApplicationTests(NeoUnitTestBase):
...
@@ -541,13 +536,9 @@ class ClientApplicationTests(NeoUnitTestBase):
conn
.
ask
=
lambda
p
,
queue
=
None
,
**
kw
:
\
conn
.
ask
=
lambda
p
,
queue
=
None
,
**
kw
:
\
type
(
p
)
is
Packets
.
AskObjectUndoSerial
and
\
type
(
p
)
is
Packets
.
AskObjectUndoSerial
and
\
queue
.
put
((
conn
,
undo_serial
,
kw
))
queue
.
put
((
conn
,
undo_serial
,
kw
))
def
tryToResolveConflict
(
oid
,
conflict_serial
,
serial
,
data
,
committedData
=
''
):
raise
Exception
,
'Test called conflict resolution, but there '
\
'is no conflict in this test !'
# The undo
# The undo
txn
=
self
.
beginTransaction
(
app
,
tid
=
tid3
)
txn
=
self
.
beginTransaction
(
app
,
tid
=
tid3
)
app
.
undo
(
tid1
,
txn
,
tryToResolveConflict
)
app
.
undo
(
tid1
,
txn
,
None
)
# no conflict resolution in this test
# Checking what happened
# Checking what happened
moid
,
mserial
,
mdata
,
mdata_serial
=
store_marker
[
0
]
moid
,
mserial
,
mdata
,
mdata_serial
=
store_marker
[
0
]
self
.
assertEqual
(
moid
,
oid0
)
self
.
assertEqual
(
moid
,
oid0
)
...
...
neo/tests/master/testElectionHandler.py
View file @
23b9544d
...
@@ -258,23 +258,12 @@ class MasterServerElectionTests(MasterClientElectionTestBase):
...
@@ -258,23 +258,12 @@ class MasterServerElectionTests(MasterClientElectionTestBase):
self
.
assertEqual
(
node
.
getUUID
(),
new_uuid
)
self
.
assertEqual
(
node
.
getUUID
(),
new_uuid
)
self
.
assertNotEqual
(
node
.
getUUID
(),
uuid
)
self
.
assertNotEqual
(
node
.
getUUID
(),
uuid
)
def
_getNodeList
(
self
):
return
[
x
.
asTuple
()
for
x
in
self
.
app
.
nm
.
getList
()]
def
__getClient
(
self
):
def
__getClient
(
self
):
uuid
=
self
.
getClientUUID
()
uuid
=
self
.
getClientUUID
()
conn
=
self
.
getFakeConnection
(
uuid
=
uuid
,
address
=
self
.
client_address
)
conn
=
self
.
getFakeConnection
(
uuid
=
uuid
,
address
=
self
.
client_address
)
self
.
app
.
nm
.
createClient
(
uuid
=
uuid
,
address
=
self
.
client_address
)
self
.
app
.
nm
.
createClient
(
uuid
=
uuid
,
address
=
self
.
client_address
)
return
conn
return
conn
def
__getMaster
(
self
,
port
=
1000
,
register
=
True
):
uuid
=
self
.
getMasterUUID
()
address
=
(
'127.0.0.1'
,
port
)
conn
=
self
.
getFakeConnection
(
uuid
=
uuid
,
address
=
address
)
if
register
:
self
.
app
.
nm
.
createMaster
(
uuid
=
uuid
,
address
=
address
)
return
conn
def
testRequestIdentification1
(
self
):
def
testRequestIdentification1
(
self
):
""" Check with a non-master node, must be refused """
""" Check with a non-master node, must be refused """
conn
=
self
.
__getClient
()
conn
=
self
.
__getClient
()
...
...
neo/tests/master/testRecovery.py
View file @
23b9544d
...
@@ -56,6 +56,10 @@ class MasterRecoveryTests(NeoUnitTestBase):
...
@@ -56,6 +56,10 @@ class MasterRecoveryTests(NeoUnitTestBase):
# Tests
# Tests
def
test_10_answerPartitionTable
(
self
):
def
test_10_answerPartitionTable
(
self
):
# XXX: This test does much less that it seems, because all 'for' loops
# iterate over empty lists. Currently, only testRecovery covers
# some paths in NodeManager._createNode: apart from that, we could
# delete it entirely.
recovery
=
self
.
recovery
recovery
=
self
.
recovery
uuid
=
self
.
identifyToMasterNode
(
NodeTypes
.
MASTER
,
port
=
self
.
master_port
)
uuid
=
self
.
identifyToMasterNode
(
NodeTypes
.
MASTER
,
port
=
self
.
master_port
)
# not from target node, ignore
# not from target node, ignore
...
...
neo/tests/master/testTransactions.py
View file @
23b9544d
...
@@ -40,7 +40,7 @@ class testTransactionManager(NeoUnitTestBase):
...
@@ -40,7 +40,7 @@ class testTransactionManager(NeoUnitTestBase):
storage_2_uuid
=
self
.
getStorageUUID
()
storage_2_uuid
=
self
.
getStorageUUID
()
oid_list
=
[
self
.
makeOID
(
1
),
]
oid_list
=
[
self
.
makeOID
(
1
),
]
tm
=
TransactionManager
(
lambda
tid
,
txn
:
None
)
tm
=
TransactionManager
(
None
)
# Transaction 1: 2 storage nodes involved, one will die and the other
# Transaction 1: 2 storage nodes involved, one will die and the other
# already answered node lock
# already answered node lock
msg_id_1
=
1
msg_id_1
=
1
...
@@ -117,7 +117,7 @@ class testTransactionManager(NeoUnitTestBase):
...
@@ -117,7 +117,7 @@ class testTransactionManager(NeoUnitTestBase):
Note: this implementation might change later, for more parallelism.
Note: this implementation might change later, for more parallelism.
"""
"""
client_uuid
,
client
=
self
.
makeNode
(
NodeTypes
.
CLIENT
)
client_uuid
,
client
=
self
.
makeNode
(
NodeTypes
.
CLIENT
)
tm
=
TransactionManager
(
lambda
tid
,
txn
:
None
)
tm
=
TransactionManager
(
None
)
# With a requested TID, lock spans from begin to remove
# With a requested TID, lock spans from begin to remove
ttid1
=
self
.
getNextTID
()
ttid1
=
self
.
getNextTID
()
ttid2
=
self
.
getNextTID
()
ttid2
=
self
.
getNextTID
()
...
@@ -134,7 +134,7 @@ class testTransactionManager(NeoUnitTestBase):
...
@@ -134,7 +134,7 @@ class testTransactionManager(NeoUnitTestBase):
def
testClientDisconectsAfterBegin
(
self
):
def
testClientDisconectsAfterBegin
(
self
):
client_uuid1
,
node1
=
self
.
makeNode
(
NodeTypes
.
CLIENT
)
client_uuid1
,
node1
=
self
.
makeNode
(
NodeTypes
.
CLIENT
)
tm
=
TransactionManager
(
lambda
tid
,
txn
:
None
)
tm
=
TransactionManager
(
None
)
tid1
=
self
.
getNextTID
()
tid1
=
self
.
getNextTID
()
tid2
=
self
.
getNextTID
()
tid2
=
self
.
getNextTID
()
tm
.
begin
(
node1
,
tid1
)
tm
.
begin
(
node1
,
tid1
)
...
...
neo/tests/testNodes.py
View file @
23b9544d
...
@@ -14,13 +14,14 @@
...
@@ -14,13 +14,14 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
shutil
import
unittest
import
unittest
from
mock
import
Mock
from
mock
import
Mock
from
neo.lib.protocol
import
NodeTypes
,
NodeStates
from
neo.lib.protocol
import
NodeTypes
,
NodeStates
from
neo.lib.node
import
Node
,
MasterDB
from
neo.lib.node
import
Node
,
MasterDB
from
.
import
NeoUnitTestBase
,
getTempDirectory
from
.
import
NeoUnitTestBase
,
getTempDirectory
from
time
import
time
from
time
import
time
from
os
import
chmod
,
mkdir
,
rmdir
,
unlink
from
os
import
chmod
,
mkdir
,
rmdir
from
os.path
import
join
,
exists
from
os.path
import
join
,
exists
class
NodesTests
(
NeoUnitTestBase
):
class
NodesTests
(
NeoUnitTestBase
):
...
@@ -182,12 +183,6 @@ class NodeManagerTests(NeoUnitTestBase):
...
@@ -182,12 +183,6 @@ class NodeManagerTests(NeoUnitTestBase):
self
.
assertEqual
(
self
.
admin
.
getState
(),
NodeStates
.
UNKNOWN
)
self
.
assertEqual
(
self
.
admin
.
getState
(),
NodeStates
.
UNKNOWN
)
class
MasterDBTests
(
NeoUnitTestBase
):
class
MasterDBTests
(
NeoUnitTestBase
):
def
_checkMasterDB
(
self
,
path
,
expected_master_list
):
db
=
list
(
MasterDB
(
path
))
db_set
=
set
(
db
)
# Generic sanity check
self
.
assertEqual
(
len
(
db
),
len
(
db_set
))
self
.
assertEqual
(
db_set
,
set
(
expected_master_list
))
def
testInitialAccessRights
(
self
):
def
testInitialAccessRights
(
self
):
"""
"""
...
@@ -227,9 +222,7 @@ class MasterDBTests(NeoUnitTestBase):
...
@@ -227,9 +222,7 @@ class MasterDBTests(NeoUnitTestBase):
db2
=
MasterDB
(
db_file
)
db2
=
MasterDB
(
db_file
)
self
.
assertFalse
(
address
in
db2
,
[
x
for
x
in
db2
])
self
.
assertFalse
(
address
in
db2
,
[
x
for
x
in
db2
])
finally
:
finally
:
if
exists
(
db_file
):
shutil
.
rmtree
(
directory
)
unlink
(
db_file
)
rmdir
(
directory
)
def
testPersistence
(
self
):
def
testPersistence
(
self
):
temp_dir
=
getTempDirectory
()
temp_dir
=
getTempDirectory
()
...
@@ -253,9 +246,7 @@ class MasterDBTests(NeoUnitTestBase):
...
@@ -253,9 +246,7 @@ class MasterDBTests(NeoUnitTestBase):
self
.
assertFalse
(
address
in
db3
,
[
x
for
x
in
db3
])
self
.
assertFalse
(
address
in
db3
,
[
x
for
x
in
db3
])
self
.
assertTrue
(
address2
in
db3
,
[
x
for
x
in
db3
])
self
.
assertTrue
(
address2
in
db3
,
[
x
for
x
in
db3
])
finally
:
finally
:
if
exists
(
db_file
):
shutil
.
rmtree
(
directory
)
unlink
(
db_file
)
rmdir
(
directory
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
...
...
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