-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathstart-local-rats.sh
More file actions
executable file
·39 lines (28 loc) · 1.87 KB
/
start-local-rats.sh
File metadata and controls
executable file
·39 lines (28 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
set -eo pipefail
ACCEPTANCE_DIR=${ACCEPTANCE_DIR:?"ACCEPTANCE_DIR must be set"}
KIND_DEPLOYMENT_DIR=${KIND_DEPLOYMENT_DIR:?"KIND_DEPLOYMENT_DIR must be set"}
CONFIG=${CONFIG:?"CONFIG must be set"}
RTR_BIN=${RTR_BIN:?"RTR_BIN must be set"}
EXIT_STATUS=0
VERBOSE_MODE="${VERBOSE:+-v}"
export PATH=${RTR_BIN}:${PATH}
export CONFIG
routing_api_ip=$(docker inspect cfk8s-worker --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}')
tcp_apps_domain=$(jq -r '.tcp_apps_domain' "$CONFIG")
jq --arg ip "$routing_api_ip" '.addresses = [$ip]' "$CONFIG" > "${CONFIG}.tmp" && mv "${CONFIG}.tmp" "$CONFIG"
make -C $KIND_DEPLOYMENT_DIR login </dev/null
cf target -o system && cf buildpacks | grep -q "go_buildpack" || make -C $KIND_DEPLOYMENT_DIR bootstrap
cf target -o system && cf domains | grep -q "$tcp_apps_domain" || cf create-shared-domain $tcp_apps_domain --router-group default-tcp
# Retry flaky tests up to 10 times to handle transient network timeouts; sleep 60 seconds between suites to allow connections/DNS caches to clear and prevent port conflicts
echo "HTTP Routing Tests"
ginkgo -randomize-all $VERBOSE_MODE -nodes=1 -keep-going --flake-attempts 10 --after-run-hook "sleep 60" "${ACCEPTANCE_DIR}/http_routes" || EXIT_STATUS=$?
echo "Sleeping for 60 seconds to allow any lingering connections to close before starting TCP routing tests..."
sleep 60
echo "TCP Routing Tests"
ginkgo -randomize-all $VERBOSE_MODE -nodes=1 -keep-going --flake-attempts 10 --after-run-hook "sleep 60" "${ACCEPTANCE_DIR}/tcp_routing" || EXIT_STATUS=$?
echo "Cleaning up test artifacts..."
cf target -o system && sleep 5 && cf delete-shared-domain $tcp_apps_domain -f
[[ "${CLEANUP_CATS_ORGS:-false}" == "true" ]] && echo "Cleanup the orgs" && cf orgs | grep "^CATS-" | xargs -I {} cf delete-org {} -f && sleep 5
echo "Acceptance Tests Complete; exit status: $EXIT_STATUS"
exit $EXIT_STATUS