Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion examples/brotli/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export PORT_STATS1="${BROTLI_PORT_PROXY:-10202}"
# shellcheck source=examples/verify-common.sh
. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh"

sleep 5
wait_for 10 bash -c "\
responds_with_header \
'content-encoding: br' \
https://localhost:${PORT_PROXY}/file.json -ki -H 'Accept-Encoding: br'"

run_log "Test service: localhost:${PORT_PROXY}/file.json with compression"
responds_with_header \
Expand Down
11 changes: 6 additions & 5 deletions examples/dynamic-config-cp/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ curl -s http://localhost:19000/config_dump \

run_log "Bring up go-control-plane"
"$DOCKER_COMPOSE" up --build -d go-control-plane

wait_for 30 sh -c "${DOCKER_COMPOSE} ps go-control-plane | grep healthy | grep -v unhealthy"

sleep 2
wait_for 10 bash -c "responds_with 'Request served by service1' http://localhost:10000"

run_log "Check for response from service1 backend"
responds_with \
Expand All @@ -42,7 +40,10 @@ curl -s http://localhost:19000/config_dump \
run_log "Bring down the control plane"
"$DOCKER_COMPOSE" stop go-control-plane

sleep 2
wait_for 10 sh -c "\
curl -s http://localhost:19000/config_dump \
| jq -r '.configs[1].dynamic_active_clusters' \
| grep '\"version_info\": \"1\"'"

run_log "Check for continued response from service1 backend"
responds_with \
Expand All @@ -63,7 +64,7 @@ sed -i'.bak' s/\"1\",/\"2\",/ resource.go

run_log "Bring back up the control plane"
"$DOCKER_COMPOSE" up --build -d go-control-plane
wait_for 30 sh -c "$DOCKER_COMPOSE ps go-control-plane | grep healthy | grep -v unhealthy"
wait_for 30 sh -c "${DOCKER_COMPOSE} ps go-control-plane | grep healthy | grep -v unhealthy"

run_log "Check for response from service2 backend"
responds_with \
Expand Down
1 change: 1 addition & 0 deletions examples/dynamic-config-fs/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ curl -s http://localhost:19000/config_dump \

run_log "Set upstream to service2"
"$DOCKER_COMPOSE" exec -T proxy sed -i s/service1/service2/ /var/lib/envoy/cds.yaml
wait_for 10 bash -c "responds_with 'Request served by service2' http://localhost:10000"

run_log "Check for response comes from service2 upstream"
responds_with \
Expand Down
12 changes: 10 additions & 2 deletions examples/ext_authz/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ responds_with_header \
run_log "Restart front-envoy with FRONT_ENVOY_YAML=config/http-service.yaml"
"$DOCKER_COMPOSE" down
FRONT_ENVOY_YAML=config/http-service.yaml "$DOCKER_COMPOSE" up -d
sleep 10

wait_for 15 bash -c "\
responds_with_header \
'HTTP/1.1 200 OK' \
-H 'Authorization: Bearer token1' \
http://localhost:${PORT_PROXY}/service"

run_log "Test service responds with 403"
responds_with_header \
Expand All @@ -31,7 +36,10 @@ responds_with_header \
run_log "Restart front-envoy with FRONT_ENVOY_YAML=config/opa-service/v3.yaml"
"$DOCKER_COMPOSE" down
FRONT_ENVOY_YAML=config/opa-service/v3.yaml "$DOCKER_COMPOSE" up -d
sleep 10
wait_for 15 bash -c "\
responds_with_header \
'HTTP/1.1 200 OK' \
http://localhost:${PORT_PROXY}/service"

run_log "Test OPA service responds with 200"
responds_with_header \
Expand Down
13 changes: 12 additions & 1 deletion examples/verify-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,17 @@ wait_for () {
local i=1 returns=1 seconds="$1"
shift
while ((i<=seconds)); do
if "$@"; then
if "${@}" &> /dev/null; then
returns=0
break
else
sleep 1
((i++))
fi
done
if [[ "$returns" != 0 ]]; then
echo "Wait (${seconds}) failed: ${*}" >&2
fi
return "$returns"
}

Expand All @@ -171,3 +174,11 @@ fi
if [[ -z "$MANUAL" ]]; then
bring_up_example
fi


# These allow the functions to be used in subshells, e.g. in `wait_for`
export -f responds_with
export -f responds_without
export -f responds_with_header
export -f responds_without_header
export -f _curl
7 changes: 4 additions & 3 deletions examples/wasm-cc/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ sed -i'.bak' s/\\.\\/lib\\/envoy_filter_http_wasm_example.wasm/.\\/lib\\/envoy_f

run_log "Bring the proxy back up"
docker-compose up --build -d proxy

run_log "Snooze for 5 while proxy starts"
sleep 5
wait_for 10 bash -c "\
responds_with \
'Hello, Wasm world' \
http://localhost:8000"

run_log "Test updated connection"
responds_with \
Expand Down
8 changes: 6 additions & 2 deletions examples/zipkin-tracing/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ responds_with \
"Hello from behind Envoy (service 1)!" \
"http://localhost:${PORT_PROXY}/trace/1"

run_log "Test dashboard"
# this could do with using the healthcheck and waiting
sleep 20
wait_for 30 bash -c "\
responds_with \
'<!doctype html>' \
http://localhost:${PORT_ADMIN}/zipkin/"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might be missing context, why are we querying it twice with same query? Here and a few other places

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the most reliable way of checking that the test is ready to be run is just waiting for the test to pass

ditto elsewhere

despite trying i didnt find a way to make this wait for docker correctly - i guess i could just move these to healthchecks on the compositions

my pref is to land and iterate because these make ci less flakey and faster

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

iteration sgtm.


run_log "Test dashboard"
responds_with \
"<!doctype html>" \
"http://localhost:${PORT_ADMIN}/zipkin/"