Skip to content

Commit 8954022

Browse files
authored
chore: add test timing to e2e tests (#2614)
Track how long each test takes and output it after the pass/fail message. Also speed up the aws-api test by 70 seconds by only testing one retry count.
1 parent 72a0a0b commit 8954022

File tree

2 files changed

+23
-24
lines changed
  • nodeadm/test/e2e

2 files changed

+23
-24
lines changed

nodeadm/test/e2e/cases/aws-api-connection-timeout/run.sh

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,21 @@ mock::kubelet 1.29.0
1616
DEFAULT_MAX_ATTEMPTS=3
1717
CONNECTION_TIMEOUT=30
1818

19-
# ensure the max retry attempts can be overridden with the standard env var
20-
# we have to test with values that are different from the default
21-
MAX_ATTEMPTS_VALUES=(1 2)
22-
23-
for MAX_ATTEMPTS_VALUE in "${MAX_ATTEMPTS_VALUES[@]}"; do
24-
if [ "$MAX_ATTEMPTS_VALUE" = "$DEFAULT_MAX_ATTEMPTS" ]; then
25-
echo "We can't test with a value ($MAX_ATTEMPTS_VALUE) that is the same as the default!"
26-
exit 1
27-
fi
28-
echo "testing with MAX_ATTEMPTS=${MAX_ATTEMPTS_VALUE}"
29-
START=$(date +%s)
30-
AWS_MAX_ATTEMPTS=${MAX_ATTEMPTS_VALUE} nodeadm init --development --skip run --config-source file://config.yaml || true
31-
END=$(date +%s)
32-
SECONDS_ELAPSED=$((END - START))
33-
LOWER_BOUND=$((MAX_ATTEMPTS_VALUE * CONNECTION_TIMEOUT))
34-
UPPER_BOUND=$((LOWER_BOUND + 5))
35-
echo "MAX_ATTEMPTS=${MAX_ATTEMPTS_VALUE} SECONDS_ELAPSED=${SECONDS_ELAPSED}, LOWER_BOUND=${LOWER_BOUND}, UPPER_BOUND=${UPPER_BOUND}"
36-
if ! ((SECONDS_ELAPSED >= LOWER_BOUND && SECONDS_ELAPSED <= UPPER_BOUND)); then
37-
echo "The observed AWS SDK retry behavior did not fall within the expected range!"
38-
exit 1
39-
fi
40-
done
19+
# This must be different from either our default of 30 or the aws default of 3.
20+
MAX_ATTEMPTS_VALUE=1
21+
22+
echo "testing with MAX_ATTEMPTS=${MAX_ATTEMPTS_VALUE}"
23+
START=$(date +%s)
24+
AWS_MAX_ATTEMPTS=${MAX_ATTEMPTS_VALUE} nodeadm init --development --skip run --config-source file://config.yaml || true
25+
END=$(date +%s)
26+
SECONDS_ELAPSED=$((END - START))
27+
LOWER_BOUND=$((MAX_ATTEMPTS_VALUE * CONNECTION_TIMEOUT))
28+
UPPER_BOUND=$((LOWER_BOUND + 5))
29+
echo "MAX_ATTEMPTS=${MAX_ATTEMPTS_VALUE} SECONDS_ELAPSED=${SECONDS_ELAPSED}, LOWER_BOUND=${LOWER_BOUND}, UPPER_BOUND=${UPPER_BOUND}"
30+
if ! ((SECONDS_ELAPSED >= LOWER_BOUND && SECONDS_ELAPSED <= UPPER_BOUND)); then
31+
echo "The observed AWS SDK retry behavior did not fall within the expected range!"
32+
exit 1
33+
fi
4134

4235
# now, we need to make sure that if no override is specified,
4336
# we use our increased number of attempts instead of the default

nodeadm/test/e2e/run.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,16 @@ function runTest() {
6161
local logfile
6262
logfile=$(mktemp)
6363

64+
local start_time
65+
start_time=$(date +%s)
6466
if docker exec "$containerd_id" ./run.sh > "$logfile" 2>&1; then
65-
echo "passed! ✅"
67+
local elapsed
68+
elapsed=$(($(date +%s) - start_time))
69+
echo "passed! ✅ (${elapsed}s)"
6670
else
67-
echo "failed! ❌"
71+
local elapsed
72+
elapsed=$(($(date +%s) - start_time))
73+
echo "failed! ❌ (${elapsed}s)"
6874
cat "$logfile"
6975
FAILED="true"
7076
fi

0 commit comments

Comments
 (0)