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