Skip to content

Commit

Permalink
Tests: Adapt FetchPublishedMessage for more tries
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MichaelHuth authored and t-b committed Sep 8, 2024
1 parent 248a174 commit 7030c77
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions Packages/tests/UTF_HelperFunctions.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7030c77

Please sign in to comment.