Commit 57a219d6 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Define get<NodeType>UUID in base test class to fit better with implementation.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1460 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent a41b720e
...@@ -31,13 +31,6 @@ DB_ADMIN = 'root' ...@@ -31,13 +31,6 @@ DB_ADMIN = 'root'
DB_PASSWD = None DB_PASSWD = None
DB_USER = 'test' DB_USER = 'test'
def getNewUUID():
""" Return a valid UUID """
uuid = protocol.INVALID_UUID
while uuid == protocol.INVALID_UUID:
uuid = os.urandom(16)
return uuid
class NeoTestBase(unittest.TestCase): class NeoTestBase(unittest.TestCase):
""" Base class for neo tests, implements common checks """ """ Base class for neo tests, implements common checks """
...@@ -90,11 +83,30 @@ class NeoTestBase(unittest.TestCase): ...@@ -90,11 +83,30 @@ class NeoTestBase(unittest.TestCase):
'getAdapter': 'MySQL', 'getAdapter': 'MySQL',
}) })
# XXX: according to changes with namespaced UUIDs, it would be better to def _makeUUID(self, prefix):
# implement get<NodeType>UUID() methods """
Retuns a 16-bytes UUID according to namespace 'prefix'
"""
assert len(prefix) == 1
uuid = protocol.INVALID_UUID
while uuid[1:] == protocol.INVALID_UUID[1:]:
uuid = prefix + os.urandom(15)
return uuid
def getNewUUID(self): def getNewUUID(self):
self.uuid = getNewUUID() return self._makeUUID('\0')
return self.uuid
def getClientUUID(self):
return self._makeUUID('C')
def getMasterUUID(self):
return self._makeUUID('M')
def getStorageUUID(self):
return self._makeUUID('S')
def getAdminUUID(self):
return self._makeUUID('A')
def getNextTID(self, ltid): def getNextTID(self, ltid):
tm = time() tm = time()
......
...@@ -29,7 +29,6 @@ import traceback ...@@ -29,7 +29,6 @@ import traceback
from neo.neoctl.neoctl import NeoCTL, NotReadyException from neo.neoctl.neoctl import NeoCTL, NotReadyException
from neo.protocol import ClusterStates, NodeTypes, CellStates from neo.protocol import ClusterStates, NodeTypes, CellStates
from neo.client.Storage import Storage from neo.client.Storage import Storage
from neo.tests import getNewUUID
from neo.util import dump from neo.util import dump
NEO_MASTER = 'neomaster' NEO_MASTER = 'neomaster'
...@@ -196,11 +195,8 @@ class NEOCluster(object): ...@@ -196,11 +195,8 @@ class NEOCluster(object):
return port return port
def __allocateUUID(self): def __allocateUUID(self):
uuid_set = self.uuid_set uuid = os.urandom(16)
uuid = None self.uuid_set.add(uuid)
while uuid is None or uuid in uuid_set:
uuid = getNewUUID()
uuid_set.add(uuid)
return uuid return uuid
def setupDB(self): def setupDB(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment