Skip to content

Commit 4d165b5

Browse files
committed
fixes to script
1 parent 750fc64 commit 4d165b5

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

scaletest/scaletest.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ SCALETEST_SCENARIO="${SCALETEST_SCENARIO:-}"
1414
SCALETEST_PROJECT="${SCALETEST_PROJECT:-}"
1515
SCALETEST_PROMETHEUS_REMOTE_WRITE_USER="${SCALETEST_PROMETHEUS_REMOTE_WRITE_USER:-}"
1616
SCALETEST_PROMETHEUS_REMOTE_WRITE_PASSWORD="${SCALETEST_PROMETHEUS_REMOTE_WRITE_PASSWORD:-}"
17-
SCALETEST_SKIP_CLEANUP="${SCALETEST_SKIP_CLEANUP:-}"
17+
SCALETEST_SKIP_CLEANUP="${SCALETEST_SKIP_CLEANUP:-0}"
1818

1919
script_name=$(basename "$0")
2020
args="$(getopt -o "" -l dry-run,help,name:,num-workspaces:,project:,scenario:,skip-cleanup -- "$@")"
@@ -26,7 +26,7 @@ while true; do
2626
shift
2727
;;
2828
--help)
29-
echo "Usage: $script_name --name <name> --project <project> [--num-workspaces <num-workspaces>] [--scenario <scenario>] [--dry-run]"
29+
echo "Usage: $script_name --name <name> --project <project> --num-workspaces <num-workspaces> --scenario <scenario> [--dry-run] [--skip-cleanup]"
3030
exit 1
3131
;;
3232
--name)
@@ -99,11 +99,17 @@ if [[ ! -f "${SCALETEST_SCENARIO_VARS}" ]]; then
9999
exit 1
100100
fi
101101

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

106106
CONFIG_DIR="${PROJECT_ROOT}/scaletest/.coderv2"
107+
if [[ -d "${CONFIG_DIR}" ]] && files=$(ls -qAH -- "${CONFIG_DIR}") && [[ -z "$files" ]]; then
108+
echo "Cleaning previous configuration"
109+
maybedryrun "$DRY_RUN" rm -fv "${CONFIG_DIR}/*"
110+
fi
111+
maybedryrun "$DRY_RUN" mkdir -p "${CONFIG_DIR}"
112+
107113
SCALETEST_SCENARIO_VARS="${PROJECT_ROOT}/scaletest/terraform/scenario-${SCALETEST_SCENARIO}.tfvars"
108114
SCALETEST_SECRETS="${PROJECT_ROOT}/scaletest/terraform/secrets.tfvars"
109115
SCALETEST_SECRETS_TEMPLATE="${PROJECT_ROOT}/scaletest/terraform/secrets.tfvars.tpl"
@@ -128,7 +134,7 @@ if [[ "${DRY_RUN}" != 1 ]]; then
128134
else
129135
SCALETEST_CODER_URL="http://coder.dryrun.local:3000"
130136
fi
131-
KUBECONFIG="${PWD}/.coderv2/${SCALETEST_NAME}-cluster.kubeconfig"
137+
KUBECONFIG="${PROJECT_ROOT}/scaletest/.coderv2/${SCALETEST_NAME}-cluster.kubeconfig"
132138
echo "Waiting for Coder deployment at ${SCALETEST_CODER_URL} to become ready"
133139
maybedryrun "$DRY_RUN" kubectl --kubeconfig="${KUBECONFIG}" -n "coder-${SCALETEST_NAME}" rollout status deployment/coder
134140

@@ -171,7 +177,7 @@ maybedryrun "$DRY_RUN" curl --silent --fail --output "${SCALETEST_NAME}-heap.ppr
171177
maybedryrun "$DRY_RUN" curl --silent --fail --output "${SCALETEST_NAME}-goroutine.pprof.gz" http://localhost:6061/debug/pprof/goroutine
172178
maybedryrun "$DRY_RUN" kill $pfpid
173179

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

0 commit comments

Comments
 (0)