Skip to content

Commit 4821013

Browse files
committed
fix: default aws perf harness region to us-west-2
1 parent 6640423 commit 4821013

File tree

3 files changed

+50
-17
lines changed

3 files changed

+50
-17
lines changed

docs/BENCHMARK.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ If you do not want to benchmark on your laptop/network, use the AWS CLI harness:
7575
2. Run base vs head comparison on an ephemeral EC2 runner (Spot by default, auto-terminates):
7676

7777
```bash
78-
./scripts/aws-perf/ec2-compare.sh --region us-east-1
78+
./scripts/aws-perf/ec2-compare.sh
7979
```
8080

8181
Note: the runner clones from `origin` by default, so both refs must exist in the remote repository (push your branch/commit first if needed).
82+
Default region is `us-west-2`; pass `--region <aws-region>` to override.
8283

8384
The script:
8485

@@ -97,7 +98,7 @@ Useful options:
9798
Safety cleanup:
9899

99100
```bash
100-
./scripts/aws-perf/cleanup-stale.sh us-east-1
101+
./scripts/aws-perf/cleanup-stale.sh
101102
```
102103

103104
This terminates old perf instances tagged with expired TTL metadata.

scripts/aws-perf/cleanup-stale.sh

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,54 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
4+
DEFAULT_REGION="us-west-2"
5+
REGION="${AWS_REGION:-${AWS_DEFAULT_REGION:-$DEFAULT_REGION}}"
6+
POSITIONAL_REGION=""
7+
8+
usage() {
59
cat <<'EOF'
6-
Usage: scripts/aws-perf/cleanup-stale.sh <region>
10+
Usage: scripts/aws-perf/cleanup-stale.sh [options] [region]
11+
12+
Options:
13+
--region <aws-region> AWS region (default: us-west-2)
14+
-h, --help Show help
715
8-
Example:
9-
scripts/aws-perf/cleanup-stale.sh us-east-1
16+
Examples:
17+
scripts/aws-perf/cleanup-stale.sh
18+
scripts/aws-perf/cleanup-stale.sh --region us-west-2
19+
scripts/aws-perf/cleanup-stale.sh us-west-2
1020
EOF
11-
exit 0
12-
fi
21+
}
22+
23+
while [[ $# -gt 0 ]]; do
24+
case "$1" in
25+
--region)
26+
if [[ $# -lt 2 ]]; then
27+
echo "[aws-perf-cleanup] ERROR: --region requires a value" >&2
28+
usage
29+
exit 1
30+
fi
31+
REGION="$2"
32+
shift 2
33+
;;
34+
-h|--help)
35+
usage
36+
exit 0
37+
;;
38+
--*)
39+
echo "[aws-perf-cleanup] ERROR: unknown argument: $1" >&2
40+
usage
41+
exit 1
42+
;;
43+
*)
44+
POSITIONAL_REGION="$1"
45+
shift
46+
;;
47+
esac
48+
done
1349

14-
REGION="${1:-${AWS_REGION:-${AWS_DEFAULT_REGION:-}}}"
15-
if [[ -z "$REGION" ]]; then
16-
echo "[aws-perf-cleanup] ERROR: region is required (arg1 or AWS_REGION)" >&2
17-
exit 1
50+
if [[ -n "$POSITIONAL_REGION" ]]; then
51+
REGION="$POSITIONAL_REGION"
1852
fi
1953

2054
NOW_EPOCH="$(date +%s)"

scripts/aws-perf/ec2-compare.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ INSTANCE_ID=""
99
SHOULD_CLEANUP=true
1010
PARAMS_FILE=""
1111

12-
REGION="${AWS_REGION:-${AWS_DEFAULT_REGION:-}}"
12+
DEFAULT_REGION="us-west-2"
13+
REGION="${AWS_REGION:-${AWS_DEFAULT_REGION:-$DEFAULT_REGION}}"
1314
INSTANCE_PROFILE_NAME="wreq-js-perf-ssm-profile"
1415
INSTANCE_TYPE="c6i.large"
1516
USE_SPOT=true
@@ -33,7 +34,7 @@ usage() {
3334
Usage: scripts/aws-perf/ec2-compare.sh [options]
3435
3536
Options:
36-
--region <aws-region>
37+
--region <aws-region> AWS region (default: us-west-2)
3738
--instance-profile <name> IAM instance profile with AmazonSSMManagedInstanceCore
3839
--instance-type <type> EC2 instance type (default: c6i.large)
3940
--subnet-id <subnet-id> Optional; auto-detected when omitted
@@ -136,9 +137,6 @@ requires grep
136137
requires mktemp
137138
requires node
138139

139-
if [[ -z "$REGION" ]]; then
140-
REGION="$(aws configure get region 2>/dev/null || true)"
141-
fi
142140
[[ -n "$REGION" ]] || fail "AWS region is required (use --region or set AWS_REGION)"
143141

144142
mkdir -p "$OUTPUT_DIR"

0 commit comments

Comments
 (0)