diff --git a/tests/system_tests_delivery_counts.py b/tests/system_tests_delivery_counts.py index 33e7f7685..1bf5f995e 100644 --- a/tests/system_tests_delivery_counts.py +++ b/tests/system_tests_delivery_counts.py @@ -875,6 +875,9 @@ def __init__(self, router_addr, count=None, rx_limit=None, self.receiver = None self.max_attempts = 10 self.num_attempts = 0 + self.poll_timer_started = False + self.n_accepted = 0 + self.n_released = 0 def timeout(self): self._cleanup() @@ -935,7 +938,9 @@ def on_start(self, event): name="Tx_Test01") def on_sendable(self, event): - while self.sent < self.count: + # Don't send all messages in one single loop. + # on_sendable is called only when there is credit, so send a message when there is credit. + if self.sent < self.count: if self.large_message: dlv = self.sender.send(Message(body=LARGE_PAYLOAD)) else: @@ -944,6 +949,11 @@ def on_sendable(self, event): dlv.settle() self.sent += 1 + # Start up a poll timer once all the deliveries have been sent/received. + if self.received == self.rx_limit and self.sent == self.count and not self.poll_timer_started and self.outcome is None: + self.poll_timer_started = True + self.poll_timer = event.reactor.schedule(0.5, PollTimeout(self)) + def on_message(self, event): self.received += 1 if self.outcome: @@ -951,12 +961,25 @@ def on_message(self, event): event.delivery.settle() # Start up a poll timer once all the deliveries have been sent/received. - if self.received == self.rx_limit and self.sent == self.count: + if self.received == self.rx_limit and self.sent == self.count and not self.poll_timer_started and self.outcome is None: + self.poll_timer_started = True self.poll_timer = event.reactor.schedule(0.5, PollTimeout(self)) def run(self): Container(self).run() + def on_accepted(self, event): + self.n_accepted += 1 + if self.received == self.rx_limit and self.n_accepted == self.received and not self.poll_timer_started: + self.poll_timer_started = True + self.poll_timer = event.reactor.schedule(0.5, PollTimeout(self)) + + def on_released(self, event): + self.n_released += 1 + if self.received == self.rx_limit and self.n_released == self.count and not self.poll_timer_started: + self.poll_timer_started = True + self.poll_timer = event.reactor.schedule(0.5, PollTimeout(self)) + def verify_released(self, large_message=False): """ Verify the link released count by releasing all received messages