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(): ...@@ -44,18 +44,21 @@ def patchActivityTool():
@patch @patch
def getDistributingNode(self): 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 @patch
def manage_setDistributingNode(self, distributingNode, REQUEST=None): def manage_setDistributingNode(self, distributingNode, REQUEST=None):
# A property to catch setattr on 'distributingNode' doesn't work proxy = SetDistributingNodeProxy(self)
# because self would lose all acquisition wrappers. proxy._orig_manage_setDistributingNode(distributingNode, REQUEST=REQUEST)
previous_node = self.distributingNode self.getPhysicalRoot().test_distributing_node = proxy.distributingNode
try:
self._orig_manage_setDistributingNode(distributingNode, REQUEST=REQUEST)
self.getPhysicalRoot().test_distributing_node = self.distributingNode
finally:
self.distributingNode = previous_node
# When there is more than 1 node, prevent the distributing node from # When there is more than 1 node, prevent the distributing node from
# processing activities. # processing activities.
...@@ -123,6 +126,8 @@ class ProcessingNodeTestCase(backportUnittest.TestCase, ZopeTestCase.TestCase): ...@@ -123,6 +126,8 @@ class ProcessingNodeTestCase(backportUnittest.TestCase, ZopeTestCase.TestCase):
currentNode = activity_tool.getCurrentNode() currentNode = activity_tool.getCurrentNode()
if distributing: if distributing:
activity_tool.manage_setDistributingNode(currentNode) activity_tool.manage_setDistributingNode(currentNode)
elif currentNode == activity_tool.getDistributingNode():
activity_tool.manage_setDistributingNode('')
if processing: if processing:
activity_tool.manage_addToProcessingList((currentNode,)) activity_tool.manage_addToProcessingList((currentNode,))
else: else:
......
import errno import errno
import os import os
import shutil import shutil
import signal
import socket import socket
import sys import sys
import glob import glob
...@@ -114,6 +115,7 @@ while not zeo_client: ...@@ -114,6 +115,7 @@ while not zeo_client:
else: else:
zeo_client_pid_list = activity_node = None zeo_client_pid_list = activity_node = None
os.close(r) os.close(r)
signal.signal(signal.SIGINT, signal.SIG_IGN)
elif activity_node is not None: elif activity_node is not None:
# run ZEO server but no need to fork # run ZEO server but no need to fork
zeo_server_pid = 0 zeo_server_pid = 0
......
...@@ -497,6 +497,7 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None): ...@@ -497,6 +497,7 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
signum_set.remove(signal.SIGHUP) signum_set.remove(signal.SIGHUP)
else: else:
raise KeyboardInterrupt raise KeyboardInterrupt
if signal.getsignal(signal.SIGINT) is not signal.SIG_IGN:
signal.signal(signal.SIGINT, shutdown) signal.signal(signal.SIGINT, shutdown)
signal.signal(signal.SIGHUP, 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