[Erp5-report] r45693 jm - /erp5/trunk/products/ERP5Type/tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Apr 27 17:05:27 CEST 2011


Author: jm
Date: Wed Apr 27 17:05:27 2011
New Revision: 45693

URL: http://svn.erp5.org?rev=45693&view=rev
Log:
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

Modified:
    erp5/trunk/products/ERP5Type/tests/ProcessingNodeTestCase.py
    erp5/trunk/products/ERP5Type/tests/custom_zodb.py
    erp5/trunk/products/ERP5Type/tests/runUnitTest.py

Modified: erp5/trunk/products/ERP5Type/tests/ProcessingNodeTestCase.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/ProcessingNodeTestCase.py?rev=45693&r1=45692&r2=45693&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/ProcessingNodeTestCase.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/ProcessingNodeTestCase.py [utf8] Wed Apr 27 17:05:27 2011
@@ -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(backportUni
     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:

Modified: erp5/trunk/products/ERP5Type/tests/custom_zodb.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/custom_zodb.py?rev=45693&r1=45692&r2=45693&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/custom_zodb.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/custom_zodb.py [utf8] Wed Apr 27 17:05:27 2011
@@ -1,6 +1,7 @@
 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

Modified: erp5/trunk/products/ERP5Type/tests/runUnitTest.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/runUnitTest.py?rev=45693&r1=45692&r2=45693&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/runUnitTest.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/runUnitTest.py [utf8] Wed Apr 27 17:05:27 2011
@@ -497,7 +497,8 @@ def runUnitTestList(test_list, verbosity
       signum_set.remove(signal.SIGHUP)
     else:
       raise KeyboardInterrupt
-  signal.signal(signal.SIGINT, shutdown)
+  if signal.getsignal(signal.SIGINT) is not signal.SIG_IGN:
+    signal.signal(signal.SIGINT, shutdown)
   signal.signal(signal.SIGHUP, shutdown)
 
   try:



More information about the Erp5-report mailing list