From fc209363d72cb557db02f8cb6f4cdd8d34888a43 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 | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Packages/tests/UTF_HelperFunctions.ipf b/Packages/tests/UTF_HelperFunctions.ipf index 76add5d9cb..49f954eabc 100644 --- a/Packages/tests/UTF_HelperFunctions.ipf +++ b/Packages/tests/UTF_HelperFunctions.ipf @@ -215,17 +215,32 @@ 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)