Skip to content

Commit

Permalink
Switch to bash script
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin committed Sep 1, 2023
1 parent 076743b commit 3ecdc71
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 27 deletions.
66 changes: 66 additions & 0 deletions .buildkite/it/run_serverless.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash

set -eo pipefail

export TERM=dumb
export LC_ALL=en_US.UTF-8
export TZ=Etc/UTC
export DEBIAN_FRONTEND=noninteractive
# https://askubuntu.com/questions/1367139/apt-get-upgrade-auto-restart-services
sudo mkdir -p /etc/needrestart
echo "\$nrconf{restart} = 'a';" | sudo tee -a /etc/needrestart/needrestart.conf > /dev/null

# based on https://gist.github.com/sj26/88e1c6584397bb7c13bd11108a579746?permalink_comment_id=4155247#gistcomment-4155247
function retry {
local retries=$1
shift
local cmd=($@)
local cmd_string="${@}"
local count=0

# be lenient with non-zero exit codes, to allow retries
set +o errexit
set +o pipefail
until "${cmd[@]}"; do
retcode=$?
wait=$(( 2 ** count ))
count=$(( count + 1))
if [[ $count -le $retries ]]; then
printf "Command [%s] failed. Retry [%d/%d] in [%d] seconds.\n" "$cmd_string" $count $retries $wait
sleep $wait
else
printf "Exhausted all [%s] retries for command [%s]. Exiting.\n" "$cmd_string" $retries
# restore settings to fail immediately on error
set -o errexit
set -o pipefail
return $retcode
fi
done
# restore settings to fail immediately on error
set -o errexit
set -o pipefail
return 0
}
echo "--- System dependencies"

PYTHON_VERSION="$1"
retry 5 sudo add-apt-repository --yes ppa:deadsnakes/ppa
retry 5 sudo apt-get update
retry 5 sudo apt-get install -y \
"python${PYTHON_VERSION}" "python${PYTHON_VERSION}-dev" "python${PYTHON_VERSION}-venv" \
dnsutil

echo "--- Run IT test :pytest:"

export RALLY_HOME=$HOME
export THESPLOG_FILE="${THESPLOG_FILE:-${RALLY_HOME}/.rally/logs/actor-system-internal.log}"
# this value is in bytes, the default is 50kB. We increase it to 200kiB.
export THESPLOG_FILE_MAXSIZE=${THESPLOG_FILE_MAXSIZE:-204800}
# adjust the default log level from WARNING
export THESPLOG_THRESHOLD="INFO"

"python${PYTHON_VERSION}" -m venv .venv
source .venv/bin/activate

pip install nox
nox -s "it_serverless
28 changes: 1 addition & 27 deletions .buildkite/it/serverless-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,4 @@ steps:
path: "secret/ci/elastic-rally/employees/cloud/it-serverless"
field: "api_key"
env_var: "RALLY_IT_SERVERLESS_API_KEY"
command: |
set -exo pipefail
echo "--- System dependencies"
export PYTHON_VERSION="3.11"
sudo add-apt-repository --yes ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install -y \
"python${PYTHON_VERSION}" "python${PYTHON_VERSION}-dev" "python${PYTHON_VERSION}-venv" \
dnsutil
echo "--- Run IT serverless test :pytest:"
export RALLY_HOME=$HOME
export THESPLOG_FILE="${THESPLOG_FILE:-${RALLY_HOME}/.rally/logs/actor-system-internal.log}"
# this value is in bytes, the default is 50kB. We increase it to 200kiB.
export THESPLOG_FILE_MAXSIZE=${THESPLOG_FILE_MAXSIZE:-204800}
# adjust the default log level from WARNING
export THESPLOG_THRESHOLD="INFO"
export TERM=dumb
export LC_ALL=en_US.UTF-8
"python${PYTHON_VERSION}" -m venv .venv
source .venv/bin/activate
pip install nox
nox -s "it_serverless"
command: bash .buildkite/it/run_serverless.sh 3.11

0 comments on commit 3ecdc71

Please sign in to comment.