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
Vincent Pelletier
neoppod
Commits
6e32ebb7
Commit
6e32ebb7
authored
Nov 21, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix spelling mistakes
parent
b61f8745
Changes
42
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
85 additions
and
85 deletions
+85
-85
README.rst
README.rst
+1
-1
neo/admin/handler.py
neo/admin/handler.py
+1
-1
neo/client/Storage.py
neo/client/Storage.py
+1
-1
neo/client/__init__.py
neo/client/__init__.py
+1
-1
neo/client/app.py
neo/client/app.py
+3
-3
neo/client/cache.py
neo/client/cache.py
+1
-1
neo/client/handlers/storage.py
neo/client/handlers/storage.py
+1
-1
neo/lib/connection.py
neo/lib/connection.py
+2
-2
neo/lib/connector.py
neo/lib/connector.py
+2
-2
neo/lib/locking.py
neo/lib/locking.py
+2
-2
neo/lib/node.py
neo/lib/node.py
+3
-3
neo/lib/patch.py
neo/lib/patch.py
+1
-1
neo/lib/protocol.py
neo/lib/protocol.py
+5
-5
neo/lib/threaded_app.py
neo/lib/threaded_app.py
+1
-1
neo/lib/util.py
neo/lib/util.py
+1
-1
neo/master/app.py
neo/master/app.py
+3
-3
neo/master/handlers/secondary.py
neo/master/handlers/secondary.py
+1
-1
neo/master/transactions.py
neo/master/transactions.py
+1
-1
neo/neoctl/app.py
neo/neoctl/app.py
+2
-2
neo/scripts/neostorage.py
neo/scripts/neostorage.py
+1
-1
neo/storage/database/manager.py
neo/storage/database/manager.py
+7
-7
neo/storage/database/mysqldb.py
neo/storage/database/mysqldb.py
+2
-2
neo/storage/handlers/client.py
neo/storage/handlers/client.py
+1
-1
neo/storage/handlers/initialization.py
neo/storage/handlers/initialization.py
+1
-1
neo/storage/replicator.py
neo/storage/replicator.py
+1
-1
neo/tests/__init__.py
neo/tests/__init__.py
+4
-4
neo/tests/client/testClientApp.py
neo/tests/client/testClientApp.py
+5
-5
neo/tests/functional/__init__.py
neo/tests/functional/__init__.py
+2
-2
neo/tests/functional/testClient.py
neo/tests/functional/testClient.py
+3
-3
neo/tests/functional/testMaster.py
neo/tests/functional/testMaster.py
+2
-2
neo/tests/functional/testStorage.py
neo/tests/functional/testStorage.py
+2
-2
neo/tests/master/testElectionHandler.py
neo/tests/master/testElectionHandler.py
+1
-1
neo/tests/master/testStorageHandler.py
neo/tests/master/testStorageHandler.py
+1
-1
neo/tests/master/testTransactions.py
neo/tests/master/testTransactions.py
+1
-1
neo/tests/storage/testStorageDBTests.py
neo/tests/storage/testStorageDBTests.py
+4
-4
neo/tests/storage/testTransactions.py
neo/tests/storage/testTransactions.py
+1
-1
neo/tests/testConnection.py
neo/tests/testConnection.py
+1
-1
neo/tests/testNodes.py
neo/tests/testNodes.py
+1
-1
neo/tests/testPT.py
neo/tests/testPT.py
+8
-8
neo/tests/testUtil.py
neo/tests/testUtil.py
+1
-1
neo/tests/threaded/test.py
neo/tests/threaded/test.py
+1
-1
neo/tests/threaded/testReplication.py
neo/tests/threaded/testReplication.py
+1
-1
No files found.
README.rst
View file @
6e32ebb7
...
...
@@ -34,7 +34,7 @@ ZODB API is fully implemented except:
for garbage collection)
- blobs: not implemented (not considered yet)
Any ZODB like FileStorage can be converted to NEO instanteously,
Any ZODB like FileStorage can be converted to NEO instant
an
eously,
which means the database is operational before all data are imported.
There's also a tool to convert back to FileStorage.
...
...
neo/admin/handler.py
View file @
6e32ebb7
...
...
@@ -74,7 +74,7 @@ class AdminEventHandler(EventHandler):
class
MasterEventHandler
(
EventHandler
):
""" This class is just used to dispa
ct
h message to right handler"""
""" This class is just used to dispa
tc
h message to right handler"""
def
_connectionLost
(
self
,
conn
):
app
=
self
.
app
...
...
neo/client/Storage.py
View file @
6e32ebb7
...
...
@@ -108,7 +108,7 @@ class Storage(BaseStorage.BaseStorage,
def
deleteObject
(
self
,
oid
,
serial
,
transaction
):
self
.
app
.
store
(
oid
,
serial
,
None
,
None
,
transaction
)
# mu
tl
iple revisions
# mu
lt
iple revisions
def
loadSerial
(
self
,
oid
,
serial
):
try
:
return
self
.
app
.
load
(
oid
,
serial
)[
0
]
...
...
neo/client/__init__.py
View file @
6e32ebb7
...
...
@@ -87,4 +87,4 @@ def patch():
patch
()
import
app
# set up signal handers early enough to do it in the main thread
import
app
# set up signal hand
l
ers early enough to do it in the main thread
neo/client/app.py
View file @
6e32ebb7
...
...
@@ -132,7 +132,7 @@ class Application(ThreadedApplication):
self
.
_cache_lock_acquire
=
lock
.
acquire
self
.
_cache_lock_release
=
lock
.
release
# _connecting_to_master_node is used to prevent simultaneous master
# node connection attemps
# node connection attemp
t
s
self
.
_connecting_to_master_node
=
Lock
()
self
.
compress
=
compress
...
...
@@ -324,7 +324,7 @@ class Application(ThreadedApplication):
object existed, but its creation was undone
Note that loadSerial is used during conflict resolution to load
object's current version, which is not visible to us normaly (it was
object's current version, which is not visible to us normal
l
y (it was
committed after our snapshot was taken).
"""
# TODO:
...
...
@@ -987,7 +987,7 @@ class Application(ThreadedApplication):
queue
=
txn_context
[
'queue'
]
txn_context
[
'object_stored_counter_dict'
][
oid
]
=
{}
# ZODB.Connection performs calls 'checkCurrentSerialInTransaction'
# after stores, and skips oids that have been succe
e
ssfully stored.
# after stores, and skips oids that have been successfully stored.
assert
oid
not
in
txn_context
[
'cache_dict'
],
(
oid
,
txn_context
)
txn_context
[
'data_dict'
].
setdefault
(
oid
,
CHECKED_SERIAL
)
checked_nodes
=
txn_context
[
'checked_nodes'
]
...
...
neo/client/cache.py
View file @
6e32ebb7
...
...
@@ -203,7 +203,7 @@ class ClientCache(object):
item
=
self
.
_load
(
oid
,
next_tid
)
if
item
:
# We don't handle late invalidations for cached oids, because
# the caller is not supposed to explicit
e
ly asks for tids after
# the caller is not supposed to explicitly asks for tids after
# app.last_tid (and the cache should be empty when app.last_tid
# is still None).
assert
item
.
tid
==
tid
,
(
item
,
tid
)
...
...
neo/client/handlers/storage.py
View file @
6e32ebb7
...
...
@@ -170,7 +170,7 @@ class StorageAnswersHandler(AnswerBaseHandler):
raise
ConflictError
,
'Lock wait timeout for oid %s on %r'
%
(
dump
(
oid
),
conn
)
# HasLock design required that storage is multi-threaded so that
# it can answer to AskHasLock while processing store re
s
quests.
# it can answer to AskHasLock while processing store requests.
# This means that the 2 cases (granted to us or nobody) are legitimate,
# either because it gave us the lock but is/was slow to store our data,
# or because the storage took a lot of time processing a previous
...
...
neo/lib/connection.py
View file @
6e32ebb7
...
...
@@ -72,7 +72,7 @@ class HandlerSwitcher(object):
_pending
=
self
.
_pending
if
self
.
_is_handling
:
# If this is called while handling a packet, the response is to
# be ex
c
pected for the current handler...
# be expected for the current handler...
(
request_dict
,
_
)
=
_pending
[
0
]
else
:
# ...otherwise, queue for the latest handler
...
...
@@ -100,7 +100,7 @@ class HandlerSwitcher(object):
# on_timeout sent a packet with a smaller timeout
# so keep the connection open
return
# Notify that a timeout occured
# Notify that a timeout occur
r
ed
return
msg_id
def
handle
(
self
,
connection
,
packet
):
...
...
neo/lib/connector.py
View file @
6e32ebb7
...
...
@@ -124,8 +124,8 @@ class SocketConnector(object):
def
getDescriptor
(
self
):
# this descriptor must only be used by the event manager, where it
# guarantee uni
city only while the connector is opened and registere
d
# in epoll
# guarantee uni
queness only while the connector is opened an
d
#
registered
in epoll
return
self
.
socket_fd
@
staticmethod
...
...
neo/lib/locking.py
View file @
6e32ebb7
...
...
@@ -12,7 +12,7 @@ from Queue import Empty
Python threading module contains a simple logging mechanism, but:
- It's limitted to RLock class
- It's enabled instance by instance
- Choice to log or not is done at instan
c
iation
- Choice to log or not is done at instan
t
iation
- It does not emit any log before trying to acquire lock
This file defines a VerboseLock class implementing basic lock API and
...
...
@@ -29,7 +29,7 @@ class LockUser(object):
def
__init__
(
self
,
message
,
level
=
0
):
t
=
threading
.
currentThread
()
ident
=
getattr
(
t
,
'node_name'
,
t
.
name
)
# This class is instan
c
iated from a place desiring to known what
# This class is instan
t
iated from a place desiring to known what
# called it.
# limit=1 would return execution position in this method
# limit=2 would return execution position in caller
...
...
neo/lib/node.py
View file @
6e32ebb7
...
...
@@ -227,7 +227,7 @@ class Node(object):
self
.
setState
(
NodeStates
.
PENDING
)
def
asTuple
(
self
):
""" Returned tuple is inten
ted to be used in procot
ol encoders """
""" Returned tuple is inten
ded to be used in protoc
ol encoders """
return
(
self
.
getType
(),
self
.
_address
,
self
.
_uuid
,
self
.
_state
)
def
__gt__
(
self
,
node
):
...
...
@@ -337,7 +337,7 @@ class NodeManager(object):
def
__init__
(
self
,
master_db
=
None
):
"""
master_db (string)
Path to a file containing master nodes'
s
addresses. Used to automate
Path to a file containing master nodes' addresses. Used to automate
master list updates. If not provided, no automation will happen.
"""
self
.
_node_set
=
set
()
...
...
@@ -583,7 +583,7 @@ class NodeManager(object):
'Discrepancy between node_by_uuid (%r) and '
\
'node_by_addr (%r)'
%
(
node_by_uuid
,
node_by_addr
)
if
state
==
NodeStates
.
DOWN
:
logging
.
debug
(
'droping node %r (%r), found with %s '
logging
.
debug
(
'drop
p
ing node %r (%r), found with %s '
'%s %s %s'
,
node
,
node
.
isConnected
(),
*
log_args
)
if
node
.
isConnected
():
# Cut this connection, node removed by handler.
...
...
neo/lib/patch.py
View file @
6e32ebb7
...
...
@@ -16,7 +16,7 @@
#
def
speedupFileStorageTxnLookup
():
"""Speed up lookup of start position when instan
c
iating an iterator
"""Speed up lookup of start position when instan
t
iating an iterator
FileStorage does not index the file positions of transactions.
With this patch, we use the existing {oid->file_pos} index to bisect the
...
...
neo/lib/protocol.py
View file @
6e32ebb7
...
...
@@ -329,7 +329,7 @@ class ParseError(Exception):
class
PItem
(
object
):
"""
Base class for any packet item, _encode and _decode must be overriden
Base class for any packet item, _encode and _decode must be overrid
d
en
by subclasses.
"""
def
__init__
(
self
,
name
):
...
...
@@ -1491,8 +1491,8 @@ class Replicate(Packet):
class
ReplicationDone
(
Packet
):
"""
Notify the master node that a partition has been success
ully replicated from
a storage to another.
Notify the master node that a partition has been success
fully replicated
from
a storage to another.
S -> M
"""
_fmt
=
PStruct
(
'notify_replication_done'
,
...
...
@@ -1527,7 +1527,7 @@ def register(request, ignore_when_closed=None):
# By default, on a closed connection:
# - request: ignore
# - answer: keep
# - no
fit
ication: keep
# - no
tif
ication: keep
ignore_when_closed
=
answer
is
not
None
request
.
_ignore_when_closed
=
ignore_when_closed
if
answer
in
(
Error
,
None
):
...
...
@@ -1564,7 +1564,7 @@ class ParserState(object):
class
Packets
(
dict
):
"""
Packet registry that check
packet code unicity and provide
an index
Packet registry that check
s packet code uniqueness and provides
an index
"""
def
__metaclass__
(
name
,
base
,
d
):
for
k
,
v
in
d
.
iteritems
():
...
...
neo/lib/threaded_app.py
View file @
6e32ebb7
...
...
@@ -150,7 +150,7 @@ class ThreadedApplication(BaseApplication):
if
msg_id
==
qpacket
.
getId
():
if
is_forgotten
:
raise
ValueError
,
'ForgottenPacket for an '
\
'explicit
e
ly expected packet.'
'explicitly expected packet.'
_handlePacket
(
qconn
,
qpacket
,
kw
,
handler
)
break
if
not
is_forgotten
and
qpacket
is
not
None
:
...
...
neo/lib/util.py
View file @
6e32ebb7
...
...
@@ -142,7 +142,7 @@ def parseNodeAddress(address, port_opt=None):
else
:
host
=
address
port
=
port_opt
# Resolve (maybe) and cast to can
n
onical form
# Resolve (maybe) and cast to canonical form
# XXX: Always pick the first result. This might not be what is desired, and
# if so this function should either take a hint on the desired address type
# or return either raw host & port or getaddrinfo return value.
...
...
neo/master/app.py
View file @
6e32ebb7
...
...
@@ -40,7 +40,7 @@ from .verification import VerificationManager
class
Application
(
BaseApplication
):
"""The master node application."""
packing
=
None
# Latest completely commited TID
# Latest completely commit
t
ed TID
last_transaction
=
ZERO_TID
backup_tid
=
None
backup_app
=
None
...
...
@@ -261,7 +261,7 @@ class Application(BaseApplication):
def
provideService
(
self
):
"""
This is the normal mode for a primary master node. Handle transactions
and stop the service only if a catastroph
y
happens or the user commits
and stop the service only if a catastroph
e
happens or the user commits
a shutdown.
"""
logging
.
info
(
'provide service'
)
...
...
@@ -298,7 +298,7 @@ class Application(BaseApplication):
# secondaries, rather than the other way around. This requires
# a bit more work when a new master joins a cluster but makes
# it easier to resolve UUID conflicts with minimal cluster
# impact, and ensure primary master uni
city
(primary masters
# impact, and ensure primary master uni
queness
(primary masters
# become noisy, in that they actively try to maintain
# connections to all other master nodes, so duplicate
# primaries will eventually get in touch with each other and
...
...
neo/master/handlers/secondary.py
View file @
6e32ebb7
...
...
@@ -51,7 +51,7 @@ class PrimaryHandler(EventHandler):
app
=
self
.
app
addr
=
conn
.
getAddress
()
node
=
app
.
nm
.
getByAddress
(
addr
)
# connection successful
l
, set it as running
# connection successful, set it as running
node
.
setRunning
()
conn
.
ask
(
Packets
.
RequestIdentification
(
NodeTypes
.
MASTER
,
...
...
neo/master/transactions.py
View file @
6e32ebb7
...
...
@@ -334,7 +334,7 @@ class TransactionManager(object):
"""
Set that a node has locked the transaction.
If transaction is completely locked, calls function given at
instan
c
iation time.
instan
t
iation time.
"""
logging
.
debug
(
'Lock TXN %s for %s'
,
dump
(
ttid
),
uuid_str
(
uuid
))
if
self
[
ttid
].
lock
(
uuid
)
and
self
.
_queue
[
0
]
==
ttid
:
...
...
neo/neoctl/app.py
View file @
6e32ebb7
...
...
@@ -174,7 +174,7 @@ class TerminalNeoCTL(object):
def
tweakPartitionTable
(
self
,
params
):
"""
Optimize partition table.
No partiti
ti
on will be assigned to specified storage nodes.
No partition will be assigned to specified storage nodes.
Parameters: [node [...]]
"""
return
self
.
neoctl
.
tweakPartitionTable
(
map
(
self
.
asNode
,
params
))
...
...
@@ -294,7 +294,7 @@ class Application(object):
if
docstring
is
None
:
docstring
=
'(no docstring)'
docstring_line_list
=
docstring
.
split
(
'
\
n
'
)
# Strip empty lines at begining & end of line list
# Strip empty lines at begin
n
ing & end of line list
for
end
in
(
0
,
-
1
):
while
len
(
docstring_line_list
)
\
and
docstring_line_list
[
end
]
==
''
:
...
...
neo/scripts/neostorage.py
View file @
6e32ebb7
...
...
@@ -43,7 +43,7 @@ def main(args=None):
# TODO: Forbid using "reset" along with any unneeded argument.
# "reset" is too dangerous to let user a chance of accidentally
# letting it slip through in a long option list.
# We should drop support configation files to make such check useful.
# We should drop support config
ur
ation files to make such check useful.
(
options
,
args
)
=
parser
.
parse_args
(
args
=
args
)
config
=
ConfigurationManager
(
defaults
,
options
,
'storage'
)
...
...
neo/storage/database/manager.py
View file @
6e32ebb7
...
...
@@ -76,7 +76,7 @@ class DatabaseManager(object):
@
abstract
def
_parse
(
self
,
database
):
"""Called during instan
c
iation, to process database parameter."""
"""Called during instan
t
iation, to process database parameter."""
def
setup
(
self
,
reset
=
0
):
"""Set up a database, discarding existing data first if reset is True
...
...
@@ -92,7 +92,7 @@ class DatabaseManager(object):
@
abstract
def
_setup
(
self
):
"""To be overriden by the backend to set up a database
"""To be overrid
d
en by the backend to set up a database
It must recover self._uncommitted_data from temporary object table.
_uncommitted_data is already instantiated and must be updated with
...
...
@@ -411,7 +411,7 @@ class DatabaseManager(object):
@
abstract
def
_pruneData
(
self
,
data_id_list
):
"""To be overriden by the backend to delete any unreferenced data
"""To be overrid
d
en by the backend to delete any unreferenced data
'unreferenced' means:
- not in self._uncommitted_data
...
...
@@ -421,7 +421,7 @@ class DatabaseManager(object):
@
abstract
def
storeData
(
self
,
checksum
,
data
,
compression
):
"""To be overriden by the backend to store object raw data
"""To be overrid
d
en by the backend to store object raw data
If same data was already stored, the storage only has to check there's
no hash collision.
...
...
@@ -485,7 +485,7 @@ class DatabaseManager(object):
tid
Transation doing the undo
ltid
Upper (exclued) bound of transactions visible to transaction doing
Upper (exclu
d
ed) bound of transactions visible to transaction doing
the undo.
undone_tid
Transaction to undo
...
...
@@ -636,7 +636,7 @@ class DatabaseManager(object):
@
abstract
def
checkTIDRange
(
self
,
partition
,
length
,
min_tid
,
max_tid
):
"""
Generate a dig
g
est from transaction list.
Generate a digest from transaction list.
min_tid (packed)
TID at which verification starts.
length (int)
...
...
@@ -653,7 +653,7 @@ class DatabaseManager(object):
@
abstract
def
checkSerialRange
(
self
,
partition
,
length
,
min_tid
,
max_tid
,
min_oid
):
"""
Generate a dig
g
est from object list.
Generate a digest from object list.
min_oid (packed)
OID at which verification starts.
min_tid (packed)
...
...
neo/storage/database/mysqldb.py
View file @
6e32ebb7
...
...
@@ -216,7 +216,7 @@ class MySQLDatabaseManager(DatabaseManager):
engine
+=
" compression='tokudb_uncompressed'"
# The table "data" stores object data.
# We'd like to have partial index on 'hash' colum (e.g. hash(4))
# We'd like to have partial index on 'hash' colum
n
(e.g. hash(4))
# but 'UNIQUE' constraint would not work as expected.
q
(
"""CREATE TABLE IF NOT EXISTS data (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
...
...
@@ -630,7 +630,7 @@ class MySQLDatabaseManager(DatabaseManager):
return
oid_list
,
user
,
desc
,
ext
,
bool
(
packed
),
util
.
p64
(
ttid
)
def
getObjectHistory
(
self
,
oid
,
offset
,
length
):
# FIXME: This method doesn't take client's current ransaction id as
# FIXME: This method doesn't take client's current
t
ransaction id as
# parameter, which means it can return transactions in the future of
# client's transaction.
oid
=
util
.
u64
(
oid
)
...
...
neo/storage/handlers/client.py
View file @
6e32ebb7
...
...
@@ -88,7 +88,7 @@ class ClientOperationHandler(EventHandler):
except
DelayedError
:
# locked by a previous transaction, retry later
# If we are unlocking, we want queueEvent to raise
# AlreadyPendingError, to avoid making
lc
ient wait for an unneeded
# AlreadyPendingError, to avoid making
cl
ient wait for an unneeded
# response.
try
:
self
.
app
.
queueEvent
(
self
.
_askStoreObject
,
conn
,
(
oid
,
serial
,
...
...
neo/storage/handlers/initialization.py
View file @
6e32ebb7
...
...
@@ -29,7 +29,7 @@ class InitializationHandler(BaseMasterHandler):
pt
.
load
(
ptid
,
row_list
,
self
.
app
.
nm
)
if
not
pt
.
filled
():
raise
ProtocolError
(
'Partial partition table received'
)
# Install the partition table into the database for persistenc
y
.
# Install the partition table into the database for persistenc
e
.
cell_list
=
[]
num_partitions
=
pt
.
getPartitions
()
unassigned_set
=
set
(
xrange
(
num_partitions
))
...
...
neo/storage/replicator.py
View file @
6e32ebb7
...
...
@@ -336,7 +336,7 @@ class Replicator(object):
offset
,
message
and
' (%s)'
%
message
)
if
offset
in
self
.
partition_dict
:
# XXX: Try another partition if possible, to increase probability to
# connect to another node. It would be better to explicit
e
ly
# connect to another node. It would be better to explicitly
# search for another node instead.
tid
=
self
.
replicate_dict
.
pop
(
offset
,
None
)
or
self
.
replicate_tid
if
self
.
replicate_dict
:
...
...
neo/tests/__init__.py
View file @
6e32ebb7
...
...
@@ -312,7 +312,7 @@ class NeoUnitTestBase(NeoTestBase):
self
.
assertRaises
(
protocol
.
ProtocolError
,
method
,
*
args
,
**
kwargs
)
def
checkUnexpectedPacketRaised
(
self
,
method
,
*
args
,
**
kwargs
):
""" Check if the UnexpectedPacketError exception w
x
as raised """
""" Check if the UnexpectedPacketError exception was raised """
self
.
assertRaises
(
protocol
.
UnexpectedPacketError
,
method
,
*
args
,
**
kwargs
)
def
checkIdenficationRequired
(
self
,
method
,
*
args
,
**
kwargs
):
...
...
@@ -320,11 +320,11 @@ class NeoUnitTestBase(NeoTestBase):
self
.
checkUnexpectedPacketRaised
(
method
,
*
args
,
**
kwargs
)
def
checkBrokenNodeDisallowedErrorRaised
(
self
,
method
,
*
args
,
**
kwargs
):
""" Check if the BrokenNodeDisallowedError exception w
x
as raised """
""" Check if the BrokenNodeDisallowedError exception was raised """
self
.
assertRaises
(
protocol
.
BrokenNodeDisallowedError
,
method
,
*
args
,
**
kwargs
)
def
checkNotReadyErrorRaised
(
self
,
method
,
*
args
,
**
kwargs
):
""" Check if the NotReadyError exception w
x
as raised """
""" Check if the NotReadyError exception was raised """
self
.
assertRaises
(
protocol
.
NotReadyError
,
method
,
*
args
,
**
kwargs
)
def
checkAborted
(
self
,
conn
):
...
...
@@ -372,7 +372,7 @@ class NeoUnitTestBase(NeoTestBase):
self
.
assertEqual
(
found_uuid
,
uuid
)
# in check(Ask|Answer|Notify)Packet we return the packet so it can be used
# in tests if more accurate
s
checks are required
# in tests if more accurate checks are required
def
checkErrorPacket
(
self
,
conn
,
decode
=
False
):
""" Check if an error packet was answered """
...
...
neo/tests/client/testClientApp.py
View file @
6e32ebb7
...
...
@@ -81,7 +81,7 @@ class ClientApplicationTests(NeoUnitTestBase):
# stop threads
for
app
in
self
.
_to_stop_list
:
app
.
close
()
# restore environ
ne
ment
# restore environment
Application
.
_ask
=
self
.
_ask
Application
.
_getMasterConnection
=
self
.
_getMasterConnection
NeoUnitTestBase
.
_tearDown
(
self
,
success
)
...
...
@@ -596,7 +596,7 @@ class ClientApplicationTests(NeoUnitTestBase):
Object oid previous revision before tid1 is tid0.
Transaction tid2 modified oid (and contains its data).
Undo is rejeced with a raise, because conflict resolution fails.
Undo is rejec
t
ed with a raise, because conflict resolution fails.
"""
oid0
=
self
.
makeOID
(
1
)
tid0
=
self
.
getNextTID
()
...
...
@@ -795,7 +795,7 @@ class ClientApplicationTests(NeoUnitTestBase):
ask_func_list
.
pop
(
0
)(
conn
)
app
.
nm
.
getByAddress
(
conn
.
getAddress
()).
_connection
=
None
app
.
_ask
=
_ask_base
# fake
d environne
ment
# fake
environ
ment
app
.
em
.
close
()
app
.
em
=
Mock
({
'getConnectionList'
:
[]})
app
.
pt
=
Mock
({
'operational'
:
False
})
...
...
@@ -831,11 +831,11 @@ class ClientApplicationTests(NeoUnitTestBase):
self
.
assertTrue
(
self
.
test_ok
)
# check NEOStorageError is raised when the primary connection is lost
app
.
master_conn
=
None
# check disabled since we reonnect to pmn
# check disabled since we re
c
onnect to pmn
#self.assertRaises(NEOStorageError, app._askPrimary, packet)
def
test_threadContextIsolation
(
self
):
""" Thread context properties must not be visible ac
c
ross instances
""" Thread context properties must not be visible across instances
while remaining in the same thread """
app1
=
self
.
getApp
()
app1_local
=
app1
.
_thread_container
...
...
neo/tests/functional/__init__.py
View file @
6e32ebb7
...
...
@@ -183,7 +183,7 @@ class NEOProcess(object):
self
.
wait
()
except
:
# We can ignore all exceptions at this point, since there is no
# garanteed way to handle them (other objects we would depend on
# g
u
aranteed way to handle them (other objects we would depend on
# might already have been deleted).
pass
...
...
@@ -565,7 +565,7 @@ class NEOCluster(object):
def
callback
(
last_try
):
current_try
=
self
.
getPrimary
()
if
None
not
in
(
uuid
,
current_try
)
and
uuid
!=
current_try
:
raise
AssertionError
,
'An unexpected primary ar
ised
: %r, '
\
raise
AssertionError
,
'An unexpected primary ar
ose
: %r, '
\
'expected %r'
%
(
dump
(
current_try
),
dump
(
uuid
))
return
uuid
is
None
or
uuid
==
current_try
,
current_try
self
.
expectCondition
(
callback
,
*
args
,
**
kw
)
...
...
neo/tests/functional/testClient.py
View file @
6e32ebb7
...
...
@@ -43,7 +43,7 @@ class Tree(Persistent):
self
.
left
=
Tree
(
depth
)
# simple persitent object with conflict resolution
# simple persi
s
tent object with conflict resolution
class
PCounter
(
Persistent
):
_value
=
0
...
...
@@ -131,7 +131,7 @@ class ClientTests(NEOFunctionalTest):
c2
.
root
()[
'other'
]
c1
.
root
()[
'item'
]
=
1
t1
.
commit
()
# load objet from zope cache
# load obje
c
t from zope cache
self
.
assertEqual
(
c1
.
root
()[
'item'
],
1
)
self
.
assertEqual
(
c2
.
root
()[
'item'
],
0
)
...
...
@@ -334,7 +334,7 @@ class ClientTests(NEOFunctionalTest):
t3
.
user
=
'user'
t3
.
description
=
'desc'
st3
.
tpc_begin
(
t3
)
# retr
ei
ve the last revision
# retr
ie
ve the last revision
data
,
serial
=
st3
.
load
(
oid
)
# try to store again, should not be delayed
st3
.
store
(
oid
,
serial
,
data
,
''
,
t3
)
...
...
neo/tests/functional/testMaster.py
View file @
6e32ebb7
...
...
@@ -63,7 +63,7 @@ class MasterTests(NEOFunctionalTest):
# BUG: The following check expects neoctl to reconnect before
# the election finishes.
self
.
assertEqual
(
self
.
neo
.
getPrimary
(),
None
)
# Check that a primary master ar
ised
.
# Check that a primary master ar
ose
.
self
.
neo
.
expectPrimary
(
timeout
=
10
)
# Check that the uuid really changed.
new_uuid
=
self
.
neo
.
getPrimary
()
...
...
@@ -83,7 +83,7 @@ class MasterTests(NEOFunctionalTest):
uuid
,
=
self
.
neo
.
killPrimary
()
# Check the state of the primary we just killed
self
.
neo
.
expectMasterState
(
uuid
,
(
None
,
NodeStates
.
UNKNOWN
))
# Check that a primary master ar
ised
.
# Check that a primary master ar
ose
.
self
.
neo
.
expectPrimary
(
timeout
=
10
)
# Check that the uuid really changed.
self
.
assertNotEqual
(
self
.
neo
.
getPrimary
(),
uuid
)
...
...
neo/tests/functional/testStorage.py
View file @
6e32ebb7
...
...
@@ -69,7 +69,7 @@ class StorageTests(NEOFunctionalTest):
def
__checkDatabase
(
self
,
db_name
):
db
=
self
.
neo
.
getSQLConnection
(
db_name
)
# wait for the sql transaction to be commited
# wait for the sql transaction to be commit
t
ed
def
callback
(
last_try
):
db
.
commit
()
# to get a fresh view
# One revision per object and two for the root, before and after
...
...
@@ -185,7 +185,7 @@ class StorageTests(NEOFunctionalTest):
def
testVerificationTriggered
(
self
):
""" Check that the verification stage is executed when a storage node
required to be operation
n
al is lost, and the cluster come back in
required to be operational is lost, and the cluster come back in
running state when the storage is up again """
# start neo with one storages
...
...
neo/tests/master/testElectionHandler.py
View file @
6e32ebb7
...
...
@@ -225,7 +225,7 @@ class MasterServerElectionTests(MasterClientElectionTestBase):
def
_tearDown
(
self
,
success
):
NeoUnitTestBase
.
_tearDown
(
self
,
success
)
# restore environ
ne
ment
# restore environment
del
ClientConnection
.
_addPacket
def
test_requestIdentification1
(
self
):
...
...
neo/tests/master/testStorageHandler.py
View file @
6e32ebb7
...
...
@@ -160,7 +160,7 @@ class MasterStorageHandlerTests(NeoUnitTestBase):
self
.
assertEqual
(
lptid
,
self
.
app
.
pt
.
getID
())
def
test_answerPack
(
self
):
# Note: incom
m
ing status has no meaning here, so it's left to False.
# Note: incoming status has no meaning here, so it's left to False.
node1
,
conn1
=
self
.
_getStorage
()
node2
,
conn2
=
self
.
_getStorage
()
self
.
app
.
packing
=
None
...
...
neo/tests/master/testTransactions.py
View file @
6e32ebb7
...
...
@@ -169,7 +169,7 @@ class testTransactionManager(NeoUnitTestBase):
"""
Transaction lock is present to ensure invalidation TIDs are sent in
strictly increasing order.
Note: this implementation might change later,
to allow more para
lelism.
Note: this implementation might change later,
for more paral
lelism.
"""
client_uuid
,
client
=
self
.
makeNode
(
NodeTypes
.
CLIENT
)
tm
=
TransactionManager
(
lambda
tid
,
txn
:
None
)
...
...
neo/tests/storage/testStorageDBTests.py
View file @
6e32ebb7
...
...
@@ -167,17 +167,17 @@ class StorageDBTests(NeoUnitTestBase):
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid1
),
None
)
# one non-commited version
# one non-commit
t
ed version
with
self
.
commitTransaction
(
tid1
,
objs1
,
txn1
):
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid1
),
None
)
# one commited version
# one commit
t
ed version
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
OBJECT_T1_NO_NEXT
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
OBJECT_T1_NO_NEXT
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid1
),
FOUND_BUT_NOT_VISIBLE
)
# two version available, one non-commited
# two version available, one non-commit
t
ed
with
self
.
commitTransaction
(
tid2
,
objs2
,
txn2
):
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
OBJECT_T1_NO_NEXT
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
OBJECT_T1_NO_NEXT
)
...
...
@@ -187,7 +187,7 @@ class StorageDBTests(NeoUnitTestBase):
FOUND_BUT_NOT_VISIBLE
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid2
),
OBJECT_T1_NO_NEXT
)
# two commited versions
# two commit
t
ed versions
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
OBJECT_T2
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
OBJECT_T1_NEXT
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid1
),
...
...
neo/tests/storage/testTransactions.py
View file @
6e32ebb7
...
...
@@ -187,7 +187,7 @@ class TransactionManagerTests(NeoUnitTestBase):
ttid1
,
serial
,
*
obj
)
def
testResolvableConflict
(
self
):
""" Try to store an object with the la
s
test revision """
""" Try to store an object with the latest revision """
uuid
=
self
.
getClientUUID
()
tid
,
txn
=
self
.
_getTransaction
()
serial
,
obj
=
self
.
_getObject
(
1
)
...
...
neo/tests/testConnection.py
View file @
6e32ebb7
...
...
@@ -330,7 +330,7 @@ class HandlerSwitcherTests(NeoUnitTestBase):
r2
=
self
.
_makeRequest
(
2
)
a2
=
self
.
_makeAnswer
(
2
)
h
=
self
.
_makeHandler
()
# emit requests aroun
g
state setHandler
# emit requests aroun
d
state setHandler
self
.
_handlers
.
emit
(
r1
,
0
,
None
)
applied
=
self
.
_handlers
.
setHandler
(
h
)
self
.
assertFalse
(
applied
)
...
...
neo/tests/testNodes.py
View file @
6e32ebb7
...
...
@@ -301,7 +301,7 @@ class MasterDBTests(NeoUnitTestBase):
def
testInitialAccessRights
(
self
):
"""
Verify MasterDB raises immediately on instan
c
iation if it cannot
Verify MasterDB raises immediately on instan
t
iation if it cannot
create a non-existing database. This does not guarantee any later
open will succeed, but makes the simple error case obvious.
"""
...
...
neo/tests/testPT.py
View file @
6e32ebb7
...
...
@@ -65,9 +65,9 @@ class PartitionTableTests(NeoUnitTestBase):
self
.
assertEqual
(
cell
.
getState
(),
CellStates
.
UP_TO_DATE
)
else
:
self
.
assertEqual
(
len
(
pt
.
partition_list
[
x
]),
0
)
# try to add to a
n unexista
nt partition
# try to add to a
nonexiste
nt partition
self
.
assertRaises
(
IndexError
,
pt
.
setCell
,
10
,
sn1
,
CellStates
.
UP_TO_DATE
)
# if we add in discard
e
s state, must be removed
# if we add in discards state, must be removed
pt
.
setCell
(
0
,
sn1
,
CellStates
.
DISCARDED
)
for
x
in
xrange
(
num_partitions
):
self
.
assertEqual
(
len
(
pt
.
partition_list
[
x
]),
0
)
...
...
@@ -168,7 +168,7 @@ class PartitionTableTests(NeoUnitTestBase):
num_partitions
=
5
num_replicas
=
2
pt
=
PartitionTable
(
num_partitions
,
num_replicas
)
# add two kind of node, usable and unsable
# add two kind of node, usable and un
u
sable
uuid1
=
self
.
getStorageUUID
()
server1
=
(
"127.0.0.1"
,
19001
)
sn1
=
StorageNode
(
Mock
(),
server1
,
uuid1
)
...
...
@@ -214,7 +214,7 @@ class PartitionTableTests(NeoUnitTestBase):
num_partitions
=
5
num_replicas
=
2
pt
=
PartitionTable
(
num_partitions
,
num_replicas
)
# add two kind of node, usable and unsable
# add two kind of node, usable and un
u
sable
uuid1
=
self
.
getStorageUUID
()
server1
=
(
"127.0.0.1"
,
19001
)
sn1
=
StorageNode
(
Mock
(),
server1
,
uuid1
)
...
...
@@ -244,7 +244,7 @@ class PartitionTableTests(NeoUnitTestBase):
num_partitions
=
5
num_replicas
=
2
pt
=
PartitionTable
(
num_partitions
,
num_replicas
)
# add two kind of node, usable and unsable
# add two kind of node, usable and un
u
sable
uuid1
=
self
.
getStorageUUID
()
server1
=
(
"127.0.0.1"
,
19001
)
sn1
=
StorageNode
(
Mock
(),
server1
,
uuid1
)
...
...
@@ -286,7 +286,7 @@ class PartitionTableTests(NeoUnitTestBase):
num_partitions
=
5
num_replicas
=
2
pt
=
PartitionTable
(
num_partitions
,
num_replicas
)
# add two kind of node, usable and unsable
# add two kind of node, usable and un
u
sable
uuid1
=
self
.
getStorageUUID
()
server1
=
(
"127.0.0.1"
,
19001
)
sn1
=
StorageNode
(
Mock
(),
server1
,
uuid1
)
...
...
@@ -294,7 +294,7 @@ class PartitionTableTests(NeoUnitTestBase):
# now test
self
.
assertTrue
(
pt
.
hasOffset
(
0
))
self
.
assertFalse
(
pt
.
hasOffset
(
1
))
# unkno
nw
partition
# unkno
wn
partition
self
.
assertFalse
(
pt
.
hasOffset
(
50
))
def
test_10_operational
(
self
):
...
...
@@ -397,7 +397,7 @@ class PartitionTableTests(NeoUnitTestBase):
self
.
assertEqual
(
len
(
row_3
),
0
)
row_4
=
pt
.
getRow
(
4
)
self
.
assertEqual
(
len
(
row_4
),
0
)
# unkn
wo
n row
# unkn
ow
n row
self
.
assertRaises
(
IndexError
,
pt
.
getRow
,
5
)
if
__name__
==
'__main__'
:
...
...
neo/tests/testUtil.py
View file @
6e32ebb7
...
...
@@ -22,7 +22,7 @@ from neo.lib.util import ReadBuffer, parseNodeAddress
class
UtilTests
(
NeoUnitTestBase
):
def
test_parseNodeAddress
(
self
):
""" Parsing of addesses """
""" Parsing of add
r
esses """
def
test
(
parsed
,
*
args
):
self
.
assertEqual
(
parsed
,
parseNodeAddress
(
*
args
))
http_port
=
socket
.
getservbyname
(
'http'
)
...
...
neo/tests/threaded/test.py
View file @
6e32ebb7
...
...
@@ -970,7 +970,7 @@ class Test(NEOThreadedTest):
self
.
assertFalse
(
storage
.
tm
.
_transaction_dict
)
finally
:
db
.
close
()
# Check we did't get an invalidation, which would cause an
# Check we did
n
't get an invalidation, which would cause an
# assertion failure in the cache. Connection does the same check in
# _setstate_noncurrent so this could be also done by starting a
# transaction before the last one, and clearing the cache before
...
...
neo/tests/threaded/testReplication.py
View file @
6e32ebb7
...
...
@@ -242,7 +242,7 @@ class ReplicationTests(NEOThreadedTest):
More generally, this checks that when a handler raises when a connection
is closed voluntarily, the connection is in a consistent state and can
be, for example, closed again after the exception is ca
tched
, without
be, for example, closed again after the exception is ca
ught
, without
assertion failure.
"""
conn
,
=
backup
.
master
.
getConnectionList
(
backup
.
upstream
.
master
)
...
...
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