zotregistry.io/zot@v1.4.4-0.20231124084042-02a8ed785457/test/blackbox/helpers_wait.bash (about) 1 function wait_for_string() { 2 local search_term="$1" 3 local filepath="$2" 4 local wait_time="${3:-2m}" 5 6 wait_file "$filepath" 60 || { echo "server log file missing: '$filepath'"; return 1; } 7 8 wait_str "$filepath" "$search_term" "$wait_time" 9 } 10 11 function wait_str() { 12 local filepath="$1" 13 local search_term="$2" 14 local wait_time="${3:-2m}" 15 16 (timeout $wait_time tail -F -n0 "$filepath" &) | grep -q "$search_term" && return 0 17 18 echo "timeout of $wait_time reached. unable to find '$search_term' in '$filepath'" 19 20 return 1 21 } 22 23 function wait_file() { 24 local file="$1"; shift 25 local wait_seconds="${1:-60}"; shift 26 27 until test $((wait_seconds--)) -eq 0 -o -f "$file" ; do sleep 1; done 28 }