mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00

That test got flaky probably from #3949 on centosstream9 CI. You can replicate that behavior by increasing the sleep time when waiting for the file such that the test will attempt to read the missing file again. Since the one second wait for file is glacially slow for this, speeding it up should mean that the file gets created sooner and so the test won't try to open the file again. But, it's always still technically possible, since the test will wait for 10 seconds and the heartbeat seems to be 1 second. At least if that happens, it's probably a bug or massive slowdown of some kind.
27 lines
592 B
Bash
Executable file
27 lines
592 B
Bash
Executable file
#! /usr/bin/env bash
|
|
|
|
# Sleeps until a file comes into existence.
|
|
|
|
if [[ $# -ne 2 ]]; then
|
|
echo >&2 "usage: $0 <file to wait for> <max secs to wait>"
|
|
exit 1
|
|
fi
|
|
|
|
SLEEP_INTERVAL=0.1
|
|
SLEEP_INTERVAL_MS=100
|
|
|
|
wait_file=$1
|
|
max_wait=$2
|
|
# Avoid floating point arithmetic by using milliseconds
|
|
wait_countdown=$((${max_wait}000 / ${SLEEP_INTERVAL_MS}))
|
|
|
|
while [[ ! -e $wait_file ]]; do
|
|
let "wait_countdown -= 1"
|
|
|
|
if [[ $wait_countdown -le 0 ]]; then
|
|
echo >&2 "error: file '$wait_file' does not exist after $max_wait seconds"
|
|
exit 1
|
|
fi
|
|
|
|
sleep $SLEEP_INTERVAL
|
|
done
|