From c1fc4e9ebdd822f7b85560966cd965b3cdca7bb4 Mon Sep 17 00:00:00 2001 From: Michael Huth Date: Wed, 4 Sep 2024 15:08:42 +0200 Subject: [PATCH] Tests: Adapt FetchPublishedMessage for more tries With a running TP adding zeromq publishing messages for each TP it appears that we have to look through more than the last 100 messages after a test to find the requested. - split logic into two parts: either read out upto 10000 existing messages or wait up to 10 seconds (100 trys with 100 ms sleep) if no message is available --- Packages/tests/UTF_HelperFunctions.ipf | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Packages/tests/UTF_HelperFunctions.ipf b/Packages/tests/UTF_HelperFunctions.ipf index 6eedcfbb97..e36683b33d 100644 --- a/Packages/tests/UTF_HelperFunctions.ipf +++ b/Packages/tests/UTF_HelperFunctions.ipf @@ -213,17 +213,33 @@ static Function CheckMessageFilters_IGNORE(string filter) End Function/S FetchPublishedMessage(string expectedFilter) - variable i + + variable msgCnt, waitCnt string msg, filter - for(i = 0; i < 100; i += 1) + variable MAX_WAITS = 100 + variable MAX_MESSAGES = 10000 + + for(;;) msg = zeromq_sub_recv(filter) if(!cmpstr(filter, expectedFilter)) break endif - Sleep/S 0.1 + if(IsEmpty(msg)) + waitCnt += 1 + if(waitCnt == MAX_WAITS) + break + endif + Sleep/S 0.1 + else + msgCnt += 1 + if(msgCnt == MAX_MESSAGES) + break + endif + endif + endfor CHECK_EQUAL_STR(filter, expectedFilter)