ClickHouse/docker/test/stateless/utils.lib

52 lines
833 B
Plaintext
Raw Normal View History

2023-06-30 14:41:27 +00:00
#!/bin/bash
function run_with_retry()
{
if [[ $- =~ e ]]; then
set_e=true
else
set_e=false
fi
2023-06-30 14:41:27 +00:00
set +e
local total_retries="$1"
shift
local retry=0
until [ "$retry" -ge "$total_retries" ]
do
if "$@"; then
if $set_e; then
set -e
fi
2023-06-30 14:41:27 +00:00
return
else
retry=$((retry + 1))
sleep 5
fi
done
echo "Command '$*' failed after $total_retries retries, exiting"
exit 1
2023-07-02 09:52:50 +00:00
}
function fn_exists() {
declare -F "$1" > /dev/null;
}
2023-08-18 09:17:32 +00:00
2023-12-18 17:08:57 +00:00
function timeout_with_logging() {
local exit_code=0
timeout "${@}" || exit_code="${?}"
if [[ "${exit_code}" -eq "124" ]]
then
echo "The command 'timeout ${*}' has been killed by timeout"
fi
return $exit_code
}
2023-08-18 09:17:32 +00:00
# vi: ft=bash