diff --git a/examples/BUILD b/examples/BUILD index f94b8aa8b7d1..57de50a4d6ff 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -14,6 +14,7 @@ filegroup( "**/*.yaml", ], exclude = [ + "cache/ci-responses.yaml", "cache/responses.yaml", "dynamic-config-fs/**/*", "jaeger-native-tracing/*", diff --git a/examples/cache/ci-responses.yaml b/examples/cache/ci-responses.yaml new file mode 100644 index 000000000000..be571a8338c7 --- /dev/null +++ b/examples/cache/ci-responses.yaml @@ -0,0 +1,13 @@ +valid-for-minute: + body: This response will stay fresh for one minute + headers: + cache-control: max-age=4 + custom-header: any value +private: + body: This is a private response, it will not be cached by Envoy + headers: + cache-control: private +no-cache: + body: This response can be cached, but it has to be validated on each request + headers: + cache-control: max-age=0, no-cache diff --git a/examples/cache/docker-compose.yaml b/examples/cache/docker-compose.yaml index 76d63163b847..9337a7830ae6 100644 --- a/examples/cache/docker-compose.yaml +++ b/examples/cache/docker-compose.yaml @@ -16,7 +16,7 @@ services: context: ../shared/python target: aiohttp-service volumes: - - ./responses.yaml:/etc/responses.yaml + - "${CACHE_RESPONSES_YAML:-./responses.yaml}:/etc/responses.yaml" - ./service.py:/code/service.py environment: - SERVICE_NAME=1 @@ -26,7 +26,7 @@ services: context: ../shared/python target: aiohttp-service volumes: - - ./responses.yaml:/etc/responses.yaml + - "${CACHE_RESPONSES_YAML:-./responses.yaml}:/etc/responses.yaml" - ./service.py:/code/service.py environment: - SERVICE_NAME=2 diff --git a/examples/cache/verify.sh b/examples/cache/verify.sh index d52b3b8f335b..004cdc2da213 100755 --- a/examples/cache/verify.sh +++ b/examples/cache/verify.sh @@ -3,6 +3,8 @@ export NAME=cache export PORT_PROXY="${CACHE_PORT_PROXY:-10300}" +export CACHE_RESPONSES_YAML=./ci-responses.yaml + # shellcheck source=examples/verify-common.sh . "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh" @@ -56,15 +58,15 @@ run_log "Valid-for-minute: First request should be served by the origin" response=$(curl -si "localhost:${PORT_PROXY}/service/1/valid-for-minute") check_from_origin "$response" -run_log "Snooze for 30 seconds" -sleep 30 +run_log "Snooze for 2 seconds" +sleep 2 run_log "Valid-for-minute: Second request should be served from cache" response=$(curl -si "localhost:${PORT_PROXY}/service/1/valid-for-minute") check_cached "$response" -run_log "Snooze for 31 more seconds" -sleep 31 +run_log "Snooze for 3 more seconds" +sleep 3 run_log "Valid-for-minute: More than a minute has passed, this request should get a validated response" response=$(curl -si "localhost:${PORT_PROXY}/service/1/valid-for-minute") diff --git a/examples/front-proxy/verify.sh b/examples/front-proxy/verify.sh index 77b54a68adec..398e85161a7e 100755 --- a/examples/front-proxy/verify.sh +++ b/examples/front-proxy/verify.sh @@ -25,9 +25,7 @@ responds_with \ -k "https://localhost:${PORT_HTTPS}/service/1" run_log "Scale up docker service1=3" -"${DOCKER_COMPOSE[@]}" up -d --scale service1=3 -run_log "Snooze for 5 while docker compose scales..." -sleep 5 +"${DOCKER_COMPOSE[@]}" up --wait -d --scale service1=3 run_log "Test round-robin localhost:${PORT_PROXY}/service/1" "${DOCKER_COMPOSE[@]}" exec -T front-envoy bash -c "\