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 phase, create lib
  • Loading branch information
mafredri committed Sep 14, 2023
commit dac2ff8d4f103b0152e52a2dcfbaedeaf2c1e963
20 changes: 10 additions & 10 deletions scaletest/templates/scaletest-runner/metadata_phase.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash

if [ -f /tmp/.scaletest_phase_creating_workspaces ]; then
echo "Creating workspaces"
elif [ -f /tmp/.scaletest_phase_ssh ]; then
echo "SSH traffic"
elif [ -f /tmp/.scaletest_phase_rpty ]; then
echo "RPTY traffic"
elif [ -f /tmp/.scaletest_phase_dashboard ]; then
echo "Dashboard traffic"
elif [ -f /tmp/.scaletest_phase_wait_baseline ]; then
echo "Waiting $(</tmp/.scaletest_phase_wait_baseline)m (establishing baseline)"
# 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
9 changes: 5 additions & 4 deletions scaletest/templates/scaletest-runner/metadata_status.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/bin/bash

if [ -f /tmp/.scaletest_failed ]; then
# Order of importance (reverse of creation).
if [[ -f /tmp/.scaletest_failed ]]; then
echo "Failed"
elif [ -f /tmp/.scaletest_complete ]; then
elif [[ -f /tmp/.scaletest_complete ]]; then
echo "Complete"
elif [ -f /tmp/.scaletest_running ]; then
elif [[ -f /tmp/.scaletest_running ]]; then
echo "Running"
elif [ -f /tmp/.scaletest_preparing ]; then
elif [[ -f /tmp/.scaletest_preparing ]]; then
echo "Preparing"
else
echo "Not started"
Expand Down
16 changes: 7 additions & 9 deletions scaletest/templates/scaletest-runner/scripts/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -euo pipefail

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

# shellcheck source=scripts/lib.sh
. ~/coder/scripts/lib.sh
# shellcheck disable=SC2153 source=scaletest/templates/scaletest-runner/scripts/lib.sh
. "${SCRIPTS_DIR}/lib.sh"

event=${1:-}

Expand All @@ -21,15 +21,13 @@ if [[ $event = manual ]]; then
fi
fi

echo "Cleaning up scaletest resources (${event})..."

maybedryrun "${DRY_RUN}" coder exp scaletest cleanup \
phase_start "Cleanup (${event})"
coder exp scaletest cleanup \
--cleanup-concurrency "${SCALETEST_CLEANUP_CONCURRENCY}" \
--cleanup-job-timeout 15m \
--cleanup-timeout 30m |
tee "result-cleanup-${event}.txt"

echo "Cleanup complete!"
--cleanup-timeout 30m \
| tee "result-cleanup-${event}.txt"
end_phase

if [[ $event = manual ]]; then
echo 'Press any key to continue...'
Expand Down
46 changes: 46 additions & 0 deletions scaletest/templates/scaletest-runner/scripts/lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
set -euo pipefail

# Only source this script once, this env comes from sourcing
# scripts/lib.sh from coder/coder below.
if [[ ${SCRIPTS_LIB_IS_SOURCED} == 1 ]]; then
return 0
fi

# Source scripts/lib.sh from coder/coder for common functions.
# shellcheck source=scripts/lib.sh
. ~/coder/scripts/lib.sh

# Environment variables shared between scripts.
SCALETEST_PHASE_FILE=/tmp/.scaletest_phase

coder() {
maybedryrun "$DRY_RUN" command coder "${@}"
}

show_json() {
maybedryrun "$DRY_RUN" jq 'del(.. | .logs?)' "${1}"
}

phase_num=0
start_phase() {
((phase_num++))
log "Start phase ${phase_num}: ${*}"
echo "$(date -Iseconds) START:${phase_num}: ${*}" >>"${SCALETEST_PHASE_FILE}"
}
end_phase() {
phase="$(tail -n 1 "${SCALETEST_PHASE_FILE}" | grep "START:${phase_num}:" | cut -d' ' -f3-)"
if [[ -z ${phase} ]]; then
log "BUG: Could not find start phase ${phase_num} in ${SCALETEST_PHASE_FILE}"
exit 1
fi
log "End phase ${phase_num}: ${phase}"
echo "$(date -Iseconds) END:${phase_num}: ${phase}" >>"${SCALETEST_PHASE_FILE}"
}

wait_baseline() {
s=${1:-2}
start_phase "Waiting ${s}m to establish baseline"
sleep $((s * 60))
end_phase
}
45 changes: 14 additions & 31 deletions scaletest/templates/scaletest-runner/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,13 @@ set -euo pipefail

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

# shellcheck source=scripts/lib.sh
. ~/coder/scripts/lib.sh
# shellcheck disable=SC2153 source=scaletest/templates/scaletest-runner/scripts/lib.sh
. "${SCRIPTS_DIR}/lib.sh"

coder() {
maybedryrun "$DRY_RUN" command coder "${@}"
}

show_json() {
maybedryrun "$DRY_RUN" jq 'del(.. | .logs?)' "${1}"
}

wait_baseline() {
s=${1:-2}
echo "Waiting ${s}m (establishing baseline)..."
echo "${s}" >/tmp/.scaletest_phase_wait_baseline
sleep $((s * 60))
rm /tmp/.scaletest_phase_wait_baseline
}

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

touch /tmp/.scaletest_phase_creating_workspaces

start_phase "Creating workspaces"
coder exp scaletest create-workspaces \
--count "${SCALETEST_NUM_WORKSPACES}" \
--template "${SCALETEST_TEMPLATE}" \
Expand All @@ -35,42 +18,42 @@ coder exp scaletest create-workspaces \
--no-cleanup \
--output json:"${SCALETEST_RUN_DIR}/result-create-workspaces.json"
show_json "${SCALETEST_RUN_DIR}/result-create-workspaces.json"
rm /tmp/.scaletest_phase_creating_workspaces
end_phase

wait_baseline 5

touch /tmp/.scaletest_phase_ssh
start_phase "SSH traffic"
coder exp scaletest workspace-traffic \
--ssh \
--bytes-per-tick 10240 \
--tick-interval 1s \
--timeout 5m \
--output json:"${SCALETEST_RUN_DIR}/result-ssh.json"
show_json "${SCALETEST_RUN_DIR}/result-ssh.json"
rm /tmp/.scaletest_phase_ssh
end_phase

wait_baseline 5

touch /tmp/.scaletest_phase_rpty
start_phase "ReconnectingPTY traffic"
coder exp scaletest workspace-traffic \
--bytes-per-tick 10240 \
--tick-interval 1s \
--timeout 5m \
--output json:"${SCALETEST_RUN_DIR}/result-rpty.json"
show_json "${SCALETEST_RUN_DIR}/result-rpty.json"
rm /tmp/.scaletest_phase_rpty
--output json:"${SCALETEST_RUN_DIR}/result-reconnectingpty.json"
show_json "${SCALETEST_RUN_DIR}/result-reconnectingpty.json"
end_phase

wait_baseline 5

touch /tmp/.scaletest_phase_dashboard
start_phase "Dashboard traffic"
coder exp scaletest dashboard \
--count "${SCALETEST_NUM_WORKSPACES}" \
--job-timeout 5m \
--output json:"${SCALETEST_RUN_DIR}/result-dashboard.json"
show_json "${SCALETEST_RUN_DIR}/result-dashboard.json"
rm /tmp/.scaletest_phase_dashboard
end_phase

wait_baseline 5

echo "Scaletest complete!"
log "Scaletest complete!"
touch /tmp/.scaletest_complete
5 changes: 5 additions & 0 deletions scaletest/templates/scaletest-runner/shutdown.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
set -e

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

# shellcheck disable=SC2153 source=scaletest/templates/scaletest-runner/scripts/lib.sh
. "${SCRIPTS_DIR}/lib.sh"

cleanup() {
coder tokens remove scaletest_runner >/dev/null 2>&1 || true
}
Expand Down
4 changes: 4 additions & 0 deletions scaletest/templates/scaletest-runner/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ set -euo pipefail
[[ $VERBOSE == 1 ]] && set -x

# Unzip scripts and add to path.
# shellcheck disable=SC2153
echo "Extracting scaletest scripts into ${SCRIPTS_DIR}..."
base64 -d <<<"${SCRIPTS_ZIP}" >/tmp/scripts.zip
rm -rf "${SCRIPTS_DIR}" || true
mkdir -p "${SCRIPTS_DIR}"
unzip -o /tmp/scripts.zip -d "${SCRIPTS_DIR}"
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

Expand Down