Commit 9c2afb60 authored by Julien Muchembled's avatar Julien Muchembled Committed by Your Name

qa: fix test_getServerAddress (testCMFActivity)

With recent changes in CMFActivity, getServerAddress is now used
when setting up the site, before the ZServer is started, which means:
- getServerAddress memoized a wrong return value;
- the test didn't fail with --load.
parent d2e7cabe
...@@ -2455,15 +2455,8 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -2455,15 +2455,8 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(activity_node, current_node) self.assertEqual(activity_node, current_node)
def test_getServerAddress(self): def test_getServerAddress(self):
ip = port = '' host, port = self.startZServer()
for k, v in socket_map.items(): ip = socket.gethostbyname(host)
if hasattr(v, 'addr'):
type = str(getattr(v, '__class__', 'unknown'))
if type == 'ZServer.HTTPServer.zhttp_server':
ip, port = v.addr
break
if ip == '0.0.0.0':
ip = socket.gethostbyname(socket.gethostname())
server_address = '%s:%s' % (ip, port) server_address = '%s:%s' % (ip, port)
address = getServerAddress() address = getServerAddress()
self.assertEqual(address, server_address) self.assertEqual(address, server_address)
......
...@@ -158,6 +158,13 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase): ...@@ -158,6 +158,13 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
t = Thread(target=Lifetime.loop) t = Thread(target=Lifetime.loop)
t.setDaemon(1) t.setDaemon(1)
t.start() t.start()
from Products.CMFActivity import ActivityTool
# Reset, in case that getServerAddress was already called,
# in which case, the value was ('', '')
if ActivityTool._server_address:
if ActivityTool.currentNode == ActivityTool._server_address:
ActivityTool.currentNode = None
ActivityTool._server_address = None
return utils._Z2HOST, utils._Z2PORT return utils._Z2HOST, utils._Z2PORT
def _registerNode(self, distributing, processing): def _registerNode(self, distributing, processing):
......
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