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 Nov 18, 2024
1 parent a7ef00e commit a64fd66
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions Packages/tests/UTF_HelperFunctions.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a64fd66

Please sign in to comment.