Commit 1c3ff213 authored by Vincent Pelletier's avatar Vincent Pelletier

Products.ERP5Type.tests.ProcessingNodeTestCase: Make tic independent from the...

Products.ERP5Type.tests.ProcessingNodeTestCase: Make tic independent from the number of activities processed per tic.

That number was vastly decreased, causing tests to bail with "tic is
looping forever" for no good reason.
Convert such logic into a deadline one.
parent 520ff509
Pipeline #19186 running with stage
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import errno, logging, os, socket, time import errno, logging, os, socket, time
import itertools
from threading import Thread from threading import Thread
from UserDict import IterableUserDict from UserDict import IterableUserDict
import Lifetime import Lifetime
...@@ -278,12 +279,14 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase): ...@@ -278,12 +279,14 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
if verbose: if verbose:
ZopeTestCase._print('Executing pending activities ...') ZopeTestCase._print('Executing pending activities ...')
old_message_count = 0 old_message_count = 0
start = time.time() start = time.time()
count = 1000 deadline = start + 100 # This prevents an infinite loop.
getMessageList = portal_activities.getMessageList getMessageList = portal_activities.getMessageList
message_list = getMessageList() message_list = getMessageList()
message_count = len(message_list) message_count = len(message_list)
while message_count and not stop_condition(message_list): for call_count in itertools.count():
if not message_count or stop_condition(message_list):
break
if verbose and old_message_count != message_count: if verbose and old_message_count != message_count:
ZopeTestCase._print(' %i' % message_count) ZopeTestCase._print(' %i' % message_count)
old_message_count = message_count old_message_count = message_count
...@@ -293,9 +296,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase): ...@@ -293,9 +296,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
raise KeyboardInterrupt raise KeyboardInterrupt
message_list = getMessageList() message_list = getMessageList()
message_count = len(message_list) message_count = len(message_list)
# This prevents an infinite loop. if time.time() >= deadline or message_count and all(x.processing_node == -2
count -= 1
if not count or message_count and all(x.processing_node == -2
for x in message_list): for x in message_list):
# We're about to raise RuntimeError, but maybe we've reached # We're about to raise RuntimeError, but maybe we've reached
# the stop condition, so check just once more: # the stop condition, so check just once more:
...@@ -308,7 +309,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase): ...@@ -308,7 +309,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
error_message += str(e) error_message += str(e)
raise RuntimeError(error_message) raise RuntimeError(error_message)
# This give some time between messages # This give some time between messages
if count % 10 == 0: if call_count % 10 == 0:
portal_activities.timeShift(3 * VALIDATION_ERROR_DELAY) portal_activities.timeShift(3 * VALIDATION_ERROR_DELAY)
if verbose: if verbose:
ZopeTestCase._print(' done (%.3fs)\n' % (time.time() - start)) ZopeTestCase._print(' done (%.3fs)\n' % (time.time() - start))
......
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