Commit 1a070186 authored by Julien Muchembled's avatar Julien Muchembled

Fix incomplete/incorrect mapping of node ids in logs

In functional tests (or anything reusing this framework),
the mapping could be incorrect at the beginning of logs.
parent 16fdb24d
...@@ -54,6 +54,7 @@ class Application(BaseApplication): ...@@ -54,6 +54,7 @@ class Application(BaseApplication):
# partitions. # partitions.
self.pt = None self.pt = None
self.uuid = config.get('uuid') self.uuid = config.get('uuid')
logging.node(self.name, self.uuid)
self.request_handler = MasterRequestEventHandler(self) self.request_handler = MasterRequestEventHandler(self)
self.master_event_handler = MasterEventHandler(self) self.master_event_handler = MasterEventHandler(self)
self.cluster_state = None self.cluster_state = None
......
...@@ -319,6 +319,10 @@ class NEOLogger(Logger): ...@@ -319,6 +319,10 @@ class NEOLogger(Logger):
self.info('Node ID: %s', uuid_str(cluster_nid[1])) self.info('Node ID: %s', uuid_str(cluster_nid[1]))
self._nid_dict[name] = cluster_nid self._nid_dict[name] = cluster_nid
@property
def resetNids(self):
return self._nid_dict.clear
logging = NEOLogger() logging = NEOLogger()
signal.signal(signal.SIGRTMIN, lambda signum, frame: logging.flush()) signal.signal(signal.SIGRTMIN, lambda signum, frame: logging.flush())
......
...@@ -66,7 +66,7 @@ class Application(BaseApplication): ...@@ -66,7 +66,7 @@ class Application(BaseApplication):
if node.isConnected(True): if node.isConnected(True):
node.getConnection().close() node.getConnection().close()
self._node.setUUID(uuid) self._node.setUUID(uuid)
logging.node(self.name, uuid) logging.node(self.name, uuid)
uuid = property(lambda self: self._node.getUUID(), setUUID) uuid = property(lambda self: self._node.getUUID(), setUUID)
@property @property
...@@ -109,6 +109,7 @@ class Application(BaseApplication): ...@@ -109,6 +109,7 @@ class Application(BaseApplication):
self.nm.createMaster(address=master_address) self.nm.createMaster(address=master_address)
self._node = self.nm.createMaster(address=self.server, self._node = self.nm.createMaster(address=self.server,
uuid=config.get('uuid')) uuid=config.get('uuid'))
logging.node(self.name, self.uuid)
logging.debug('IP address is %s, port is %d', *self.server) logging.debug('IP address is %s, port is %d', *self.server)
......
...@@ -120,6 +120,7 @@ class Process(object): ...@@ -120,6 +120,7 @@ class Process(object):
_coverage_fd = None _coverage_fd = None
_coverage_prefix = os.path.join(getTempDirectory(), 'coverage-') _coverage_prefix = os.path.join(getTempDirectory(), 'coverage-')
_coverage_index = 0 _coverage_index = 0
on_fork = [logging.resetNids]
pid = 0 pid = 0
def __init__(self, command, *args, **kw): def __init__(self, command, *args, **kw):
...@@ -184,6 +185,8 @@ class Process(object): ...@@ -184,6 +185,8 @@ class Process(object):
os.write(w, '\0') os.write(w, '\0')
sys.argv = [command] + args sys.argv = [command] + args
setproctitle(self.command) setproctitle(self.command)
for on_fork in self.on_fork:
on_fork()
self.run() self.run()
status = 0 status = 0
except SystemExit, e: except SystemExit, e:
...@@ -720,6 +723,7 @@ class NEOFunctionalTest(NeoTestBase): ...@@ -720,6 +723,7 @@ class NEOFunctionalTest(NeoTestBase):
def setupLog(self): def setupLog(self):
logging.setup(os.path.join(self.getTempDirectory(), 'test.log')) logging.setup(os.path.join(self.getTempDirectory(), 'test.log'))
logging.resetNids()
def getTempDirectory(self): def getTempDirectory(self):
# build the full path based on test case and current test method # build the full path based on test case and current test method
......
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