Skip to content

feat(scaletest): add scaletest-runner template #9662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
51b5054
feat(scaletest): add scaletest-runner template
mafredri Sep 13, 2023
9a579fb
add setup/scaletest-sa.yaml
mafredri Sep 13, 2023
cde4388
fix typo
mafredri Sep 13, 2023
cd20cb8
shfmt
mafredri Sep 13, 2023
12ecd71
fix typo
mafredri Sep 13, 2023
55d6fd8
fix shellcheck
mafredri Sep 13, 2023
b251af9
fmt
mafredri Sep 13, 2023
1b1b401
improve precondition
mafredri Sep 13, 2023
fa0de66
turn namespace into param
mafredri Sep 14, 2023
77d575c
turn some params to non-ephemeral
mafredri Sep 14, 2023
abab20f
expose concurrency knobs as parameters
mafredri Sep 14, 2023
dac2ff8
refactor phase, create lib
mafredri Sep 14, 2023
059988e
refactor to use state dir in run dir
mafredri Sep 14, 2023
6352ce1
move permission check higher up
mafredri Sep 14, 2023
67e54a6
fixup! turn namespace into param
mafredri Sep 14, 2023
8f6950a
fixup! turn namespace into param
mafredri Sep 14, 2023
964778e
add cleanup strategy and make minor tweaks
mafredri Sep 14, 2023
57fd74e
move prepare/install step to Dockerfile
mafredri Sep 14, 2023
4c22a73
fix
mafredri Sep 14, 2023
35ac68f
add todo for cleanup
mafredri Sep 14, 2023
7cffd30
store timestamps for all status messages
mafredri Sep 14, 2023
5cb0e9b
make fmt/shfmt
mafredri Sep 14, 2023
e037b6b
fix unbound var
mafredri Sep 14, 2023
f336a0a
clean up previous runs if needed
mafredri Sep 14, 2023
047c784
clean up results json files
mafredri Sep 14, 2023
18875f4
add previous phase
mafredri Sep 14, 2023
0507591
fix
mafredri Sep 14, 2023
d83f480
grep -c <3
mafredri Sep 14, 2023
179f5b4
ns
mafredri Sep 14, 2023
5f5d3b1
add compression of old archives
mafredri Sep 14, 2023
c9205ce
s/echo/log/
mafredri Sep 14, 2023
f7b8c00
increase zstd compression level
mafredri Sep 15, 2023
4688f59
make sleep a dry-run op
mafredri Sep 15, 2023
3f4008c
make compression a dry-run op
mafredri Sep 15, 2023
0fce513
show dry-run in status
mafredri Sep 15, 2023
94b49e9
make shellcheck happy
mafredri Sep 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor to use state dir in run dir
  • Loading branch information
mafredri committed Sep 14, 2023
commit 059988e106b157c5079ddb2f51fc3b79a5e431bc
11 changes: 1 addition & 10 deletions scaletest/templates/scaletest-runner/metadata_phase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,4 @@
# shellcheck disable=SC2153 source=scaletest/templates/scaletest-runner/scripts/lib.sh
. "${SCRIPTS_DIR}/lib.sh"

if [[ -f "${SCALETEST_PHASE_FILE}" ]]; then
phase_raw="$(tail -n1 "${SCALETEST_PHASE_FILE}")"
phase="$(echo "${phase_raw}" | cut -d' ' -f3-)"
if [[ ${phase_raw} == *"END:"* ]]; then
phase+=" (done)"
fi
echo "${phase}"
else
echo "None"
fi
get_phase
16 changes: 4 additions & 12 deletions scaletest/templates/scaletest-runner/metadata_status.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
#!/bin/bash

# Order of importance (reverse of creation).
if [[ -f /tmp/.scaletest_failed ]]; then
echo "Failed"
elif [[ -f /tmp/.scaletest_complete ]]; then
echo "Complete"
elif [[ -f /tmp/.scaletest_running ]]; then
echo "Running"
elif [[ -f /tmp/.scaletest_preparing ]]; then
echo "Preparing"
else
echo "Not started"
fi
# shellcheck disable=SC2153 source=scaletest/templates/scaletest-runner/scripts/lib.sh
. "${SCRIPTS_DIR}/lib.sh"

get_status
30 changes: 29 additions & 1 deletion scaletest/templates/scaletest-runner/scripts/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ fi
. ~/coder/scripts/lib.sh

# Environment variables shared between scripts.
SCALETEST_PHASE_FILE=/tmp/.scaletest_phase
SCALETEST_STATE_DIR="${SCALETEST_RUN_DIR}/state"
SCALETEST_PHASE_FILE="${SCALETEST_STATE_DIR}/phase"

coder() {
maybedryrun "$DRY_RUN" command coder "${@}"
Expand All @@ -22,6 +23,21 @@ show_json() {
maybedryrun "$DRY_RUN" jq 'del(.. | .logs?)' "${1}"
}

set_status() {
echo "$*" >"${SCALETEST_STATE_DIR}/status"
}
lock_status() {
chmod 0440 "${SCALETEST_STATE_DIR}/status"
}
get_status() {
# Order of importance (reverse of creation).
if [[ -f "${SCALETEST_STATE_DIR}/status" ]]; then
cat "${SCALETEST_STATE_DIR}/status"
else
echo "Not started"
fi
}

phase_num=0
start_phase() {
((phase_num++))
Expand All @@ -37,6 +53,18 @@ end_phase() {
log "End phase ${phase_num}: ${phase}"
echo "$(date -Iseconds) END:${phase_num}: ${phase}" >>"${SCALETEST_PHASE_FILE}"
}
get_phase() {
if [[ -f "${SCALETEST_PHASE_FILE}" ]]; then
phase_raw="$(tail -n1 "${SCALETEST_PHASE_FILE}")"
phase="$(echo "${phase_raw}" | cut -d' ' -f3-)"
if [[ ${phase_raw} == *"END:"* ]]; then
phase+=" (done)"
fi
echo "${phase}"
else
echo "None"
fi
}

wait_baseline() {
s=${1:-2}
Expand Down
9 changes: 6 additions & 3 deletions scaletest/templates/scaletest-runner/scripts/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ set -euo pipefail

[[ $VERBOSE == 1 ]] && set -x

echo "Preparing scaletest workspace environment..."
touch /tmp/.scaletest_preparing
# shellcheck disable=SC2153 source=scaletest/templates/scaletest-runner/scripts/lib.sh
. "${SCRIPTS_DIR}/lib.sh"

mkdir -p "${SCALETEST_STATE_DIR}"

mkdir -p "${SCALETEST_RUN_DIR}"
echo "Preparing scaletest workspace environment..."
set_status Preparing

echo "Installing prerequisites (terraform, envsubst, gcloud, jq and kubectl)..."

Expand Down
4 changes: 2 additions & 2 deletions scaletest/templates/scaletest-runner/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -euo pipefail
. "${SCRIPTS_DIR}/lib.sh"

log "Running scaletest..."
touch /tmp/.scaletest_running
set_status Running

start_phase "Creating workspaces"
coder exp scaletest create-workspaces \
Expand Down Expand Up @@ -56,4 +56,4 @@ end_phase
wait_baseline 5

log "Scaletest complete!"
touch /tmp/.scaletest_complete
set_status Complete
8 changes: 3 additions & 5 deletions scaletest/templates/scaletest-runner/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ rm /tmp/scripts.zip
# shellcheck disable=SC2153 source=scaletest/templates/scaletest-runner/scripts/lib.sh
. "${SCRIPTS_DIR}/lib.sh"

# Clean up any previous scaletest runs (in case /tmp persists).
rm -rf /tmp/.scaletest_* || true

# Show failure in the UI if script exits with error.
failed() {
echo "Scaletest failed!"
touch /tmp/.scaletest_failed
log "Scaletest failed!"
set_status Failed
lock_status # Ensure we never rewrite the status after a failure.
}
trap failed ERR

Expand Down