Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: Further cleanups/optimizations #26204

Merged
merged 1 commit into from
Mar 28, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ filegroup(
"**/*.yaml",
],
exclude = [
"cache/ci-responses.yaml",
"cache/responses.yaml",
"dynamic-config-fs/**/*",
"jaeger-native-tracing/*",
Expand Down
13 changes: 13 additions & 0 deletions examples/cache/ci-responses.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions examples/cache/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
10 changes: 6 additions & 4 deletions examples/cache/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 1 addition & 3 deletions examples/front-proxy/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "\
Expand Down