github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/tests/acceptance/lib/connection_map_utils.bash (about) 1 # Function to check if all 'state' values 2 # in the steampipe_connection_state stable are "ready" 3 wait_connection_map_stable() { 4 local timeout_duration=5 5 local end_time=$(( $(date +%s) + timeout_duration )) 6 local all_ready=false 7 8 while [[ $(date +%s) -lt $end_time ]] 9 do 10 # Run the steampipe query and parse the JSON output 11 local json_output=$(steampipe query "select * from steampipe_connection_state" --output json) 12 if [ $? -ne 0 ]; then 13 echo "Failed to execute steampipe query" 14 return 1 15 fi 16 17 for state in $(echo $json_output | jq -r '.[].state') 18 do 19 if [ "$state" != "ready" ]; then 20 # wait for sometime 21 sleep 0.5 22 # and try again 23 continue 24 fi 25 done 26 27 # if we are here that means all are in the ready state 28 all_ready=true 29 # we can break out of the loop 30 break 31 done 32 33 if [ "$all_ready" = true ]; then 34 return 0 35 else 36 return 1 37 fi 38 } 39 40