Commit 40f5786d authored by Julien Muchembled's avatar Julien Muchembled

Fix several issues with ZEO-based unit tests

- fix potential ConflictError on Activity Tool at startup
- fix potential AttributeError in getDistributingNode
- make ProcessingNode._registerNode(distributing=0) disable distributing node
  if current node was distributing
- disable SIGINT for child running storage,
  so that a cluster can shutdown properly

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45693 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e973c580
......@@ -44,18 +44,21 @@ def patchActivityTool():
@patch
def getDistributingNode(self):
return self.getPhysicalRoot().test_distributing_node
return getattr(self.getPhysicalRoot(), 'test_distributing_node', '')
# A property to catch setattr on 'distributingNode' would not work
# because self would lose all acquisition wrappers.
class SetDistributingNodeProxy(object):
def __init__(self, ob):
self._ob = ob
def __getattr__(self, attr):
m = getattr(self._ob, attr).im_func
return lambda *args, **kw: m(self, *args, **kw)
@patch
def manage_setDistributingNode(self, distributingNode, REQUEST=None):
# A property to catch setattr on 'distributingNode' doesn't work
# because self would lose all acquisition wrappers.
previous_node = self.distributingNode
try:
self._orig_manage_setDistributingNode(distributingNode, REQUEST=REQUEST)
self.getPhysicalRoot().test_distributing_node = self.distributingNode
finally:
self.distributingNode = previous_node
proxy = SetDistributingNodeProxy(self)
proxy._orig_manage_setDistributingNode(distributingNode, REQUEST=REQUEST)
self.getPhysicalRoot().test_distributing_node = proxy.distributingNode
# When there is more than 1 node, prevent the distributing node from
# processing activities.
......@@ -123,6 +126,8 @@ class ProcessingNodeTestCase(backportUnittest.TestCase, ZopeTestCase.TestCase):
currentNode = activity_tool.getCurrentNode()
if distributing:
activity_tool.manage_setDistributingNode(currentNode)
elif currentNode == activity_tool.getDistributingNode():
activity_tool.manage_setDistributingNode('')
if processing:
activity_tool.manage_addToProcessingList((currentNode,))
else:
......
import errno
import os
import shutil
import signal
import socket
import sys
import glob
......@@ -114,6 +115,7 @@ while not zeo_client:
else:
zeo_client_pid_list = activity_node = None
os.close(r)
signal.signal(signal.SIGINT, signal.SIG_IGN)
elif activity_node is not None:
# run ZEO server but no need to fork
zeo_server_pid = 0
......
......@@ -497,6 +497,7 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
signum_set.remove(signal.SIGHUP)
else:
raise KeyboardInterrupt
if signal.getsignal(signal.SIGINT) is not signal.SIG_IGN:
signal.signal(signal.SIGINT, shutdown)
signal.signal(signal.SIGHUP, shutdown)
......
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