Skip to content

chore: add scaletest convenience script #7819

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 17 commits into from
Jun 8, 2023
Merged
Prev Previous commit
Next Next commit
fixes to script
  • Loading branch information
johnstcn committed Jun 7, 2023
commit 4d165b51b31fa1aafbcc4deef16c0c66300ff0be
16 changes: 11 additions & 5 deletions scaletest/scaletest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SCALETEST_SCENARIO="${SCALETEST_SCENARIO:-}"
SCALETEST_PROJECT="${SCALETEST_PROJECT:-}"
SCALETEST_PROMETHEUS_REMOTE_WRITE_USER="${SCALETEST_PROMETHEUS_REMOTE_WRITE_USER:-}"
SCALETEST_PROMETHEUS_REMOTE_WRITE_PASSWORD="${SCALETEST_PROMETHEUS_REMOTE_WRITE_PASSWORD:-}"
SCALETEST_SKIP_CLEANUP="${SCALETEST_SKIP_CLEANUP:-}"
SCALETEST_SKIP_CLEANUP="${SCALETEST_SKIP_CLEANUP:-0}"

script_name=$(basename "$0")
args="$(getopt -o "" -l dry-run,help,name:,num-workspaces:,project:,scenario:,skip-cleanup -- "$@")"
Expand All @@ -26,7 +26,7 @@ while true; do
shift
;;
--help)
echo "Usage: $script_name --name <name> --project <project> [--num-workspaces <num-workspaces>] [--scenario <scenario>] [--dry-run]"
echo "Usage: $script_name --name <name> --project <project> --num-workspaces <num-workspaces> --scenario <scenario> [--dry-run] [--skip-cleanup]"
exit 1
;;
--name)
Expand Down Expand Up @@ -99,11 +99,17 @@ if [[ ! -f "${SCALETEST_SCENARIO_VARS}" ]]; then
exit 1
fi

if [[ "${SCALETEST_SKIP_CLEANUP}" == "true" ]]; then
if [[ "${SCALETEST_SKIP_CLEANUP}" == 1 ]]; then
log "WARNING: you told me to not clean up after myself, so this is now your job!"
fi

CONFIG_DIR="${PROJECT_ROOT}/scaletest/.coderv2"
if [[ -d "${CONFIG_DIR}" ]] && files=$(ls -qAH -- "${CONFIG_DIR}") && [[ -z "$files" ]]; then
echo "Cleaning previous configuration"
maybedryrun "$DRY_RUN" rm -fv "${CONFIG_DIR}/*"
fi
maybedryrun "$DRY_RUN" mkdir -p "${CONFIG_DIR}"

SCALETEST_SCENARIO_VARS="${PROJECT_ROOT}/scaletest/terraform/scenario-${SCALETEST_SCENARIO}.tfvars"
SCALETEST_SECRETS="${PROJECT_ROOT}/scaletest/terraform/secrets.tfvars"
SCALETEST_SECRETS_TEMPLATE="${PROJECT_ROOT}/scaletest/terraform/secrets.tfvars.tpl"
Expand All @@ -128,7 +134,7 @@ if [[ "${DRY_RUN}" != 1 ]]; then
else
SCALETEST_CODER_URL="http://coder.dryrun.local:3000"
fi
KUBECONFIG="${PWD}/.coderv2/${SCALETEST_NAME}-cluster.kubeconfig"
KUBECONFIG="${PROJECT_ROOT}/scaletest/.coderv2/${SCALETEST_NAME}-cluster.kubeconfig"
echo "Waiting for Coder deployment at ${SCALETEST_CODER_URL} to become ready"
maybedryrun "$DRY_RUN" kubectl --kubeconfig="${KUBECONFIG}" -n "coder-${SCALETEST_NAME}" rollout status deployment/coder

Expand Down Expand Up @@ -171,7 +177,7 @@ maybedryrun "$DRY_RUN" curl --silent --fail --output "${SCALETEST_NAME}-heap.ppr
maybedryrun "$DRY_RUN" curl --silent --fail --output "${SCALETEST_NAME}-goroutine.pprof.gz" http://localhost:6061/debug/pprof/goroutine
maybedryrun "$DRY_RUN" kill $pfpid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Could remove trap handler here to avoid error on exit due to missing pid:

Suggested change
maybedryrun "$DRY_RUN" kill $pfpid
maybedryrun "$DRY_RUN" kill $pfpid
maybedryrun "$DRY_RUN" trap - EXIT


if [[ "${SCALETEST_SKIP_CLEANUP}" == "true" ]]; then
if [[ "${SCALETEST_SKIP_CLEANUP}" == 1 ]]; then
echo "Leaving resources up for you to inspect."
echo "Please don't forget to clean up afterwards:"
echo "cd terraform && terraform destroy --var-file=${SCALETEST_SCENARIO_VARS} --var-file=${SCALETEST_SECRETS} --auto-approve"
Expand Down