Skip to content

Don't leave multiple threads hanging during testing#64

Merged
shaneutt merged 8 commits intopraxis-proxy:mainfrom
esnible:stop-test-threads
Apr 22, 2026
Merged

Don't leave multiple threads hanging during testing#64
shaneutt merged 8 commits intopraxis-proxy:mainfrom
esnible:stop-test-threads

Conversation

@esnible
Copy link
Copy Markdown
Member

@esnible esnible commented Apr 21, 2026

For #56

Many of the tests start threads that hold open resources and don't release them until the entire cargo test terminates. This keeps the tests from running on the Mac and other resource-constrained environments.

With these changes, all integration tests but one now pass on the Mac.

This PRs entire purpose is to shut down resources when each test exits. This should make the integration tests use less resources on any system. The changes aren't Mac-specific.

esnible added 6 commits April 21, 2026 13:53
Signed-off-by: Ed Snible <snible@us.ibm.com>
Signed-off-by: Ed Snible <snible@us.ibm.com>
Signed-off-by: Ed Snible <snible@us.ibm.com>
Signed-off-by: Ed Snible <snible@us.ibm.com>
Signed-off-by: Ed Snible <snible@us.ibm.com>
Signed-off-by: Ed Snible <snible@us.ibm.com>
@esnible esnible marked this pull request as ready for review April 22, 2026 13:29
@shaneutt shaneutt requested a review from Copilot April 22, 2026 16:54
@shaneutt shaneutt self-assigned this Apr 22, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in AI Gateway Apr 22, 2026
@shaneutt shaneutt added this to the v0.5.0 milestone Apr 22, 2026
@shaneutt shaneutt moved this from Backlog to Review in AI Gateway Apr 22, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Rust integration-test utilities and test suites to avoid leaking background threads/resources by introducing RAII guards for spawned proxy/backend servers and updating tests to hold those guards for the test lifetime.

Changes:

  • Introduce ProxyGuard (Pingora server shutdown on drop) and BackendGuard (TCP backend shutdown on drop) in tests/utils.
  • Add new *_with_shutdown backend helpers and update many tests to use guards and proxy.addr() instead of raw address strings.
  • Update tests/utils crate dependencies to support Pingora shutdown signaling (pingora-core, async-trait, tokio/sync).

Reviewed changes

Copilot reviewed 111 out of 112 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/utils/src/proxy.rs Add ProxyGuard and spawn helper using Pingora shutdown signal watch.
tests/utils/src/net/mod.rs Re-export new backend guard helpers.
tests/utils/src/net/backend/specialized.rs Add BackendGuard and spawn_tcp_server_with_shutdown.
tests/utils/src/net/backend/simple.rs Add Backend::start_with_shutdown and start_backend_with_shutdown.
tests/utils/src/net/backend/mod.rs Re-export BackendGuard and new *_with_shutdown helpers.
tests/utils/src/net/backend/echo.rs Add echo backends that return BackendGuard.
tests/utils/src/lib.rs Re-export ProxyGuard from test utils crate.
tests/utils/Cargo.toml Add async-trait, pingora-core, and enable tokio/sync.
tests/smoke/tests/suite/smoke.rs Hold ProxyGuard and use proxy.addr().
tests/security/tests/suite/request_smuggling.rs Hold ProxyGuard and use proxy.addr().
tests/security/tests/suite/ip_acl.rs Hold ProxyGuard and use proxy.addr().
tests/security/tests/suite/info_leakage.rs Hold ProxyGuard and use proxy.addr().
tests/security/tests/suite/host_header.rs Hold ProxyGuard and use proxy.addr().
tests/security/tests/suite/header_injection.rs Hold ProxyGuard and use proxy.addr().
tests/security/tests/suite/forwarded_headers.rs Hold ProxyGuard and use proxy.addr().
tests/security/tests/suite/filter_leakage.rs Hold ProxyGuard and use proxy.addr().
tests/resilience/tests/suite/throughput_simple.rs Hold ProxyGuard and use proxy.addr().
tests/resilience/tests/suite/throughput_production.rs Hold ProxyGuard and use proxy.addr().
tests/resilience/tests/suite/throughput_filter_chain.rs Hold ProxyGuard and use proxy.addr().
tests/resilience/tests/suite/throughput_body.rs Hold ProxyGuard and use proxy.addr().
tests/resilience/tests/suite/rate_limit_burst.rs Hold ProxyGuard and use proxy.addr().
tests/resilience/tests/suite/multi_listener_isolation.rs Keep proxy alive via _proxy guard binding.
tests/resilience/tests/suite/large_payload.rs Hold ProxyGuard and use proxy.addr().
tests/resilience/tests/suite/concurrent_load.rs Hold ProxyGuard; clone proxy.addr() for threads.
tests/resilience/tests/suite/backend_recovery.rs Hold ProxyGuard and use proxy.addr().
tests/resilience/tests/suite/backend_failure.rs Hold ProxyGuard and use proxy.addr().
tests/integration/tests/suite/url_rewrite.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/tcp_access_log.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/security.rs Use header-echo backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/routing/path_based.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/routing/listeners.rs Use backend shutdown helpers and keep proxy alive via guard.
tests/integration/tests/suite/routing/infrastructure.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/routing/host_based.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/routing/filters.rs Use backend shutdown helpers and ProxyGuard for custom registry case.
tests/integration/tests/suite/routing/basic.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/retry.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/rate_limit.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/per_listener_pipeline.rs Use backend shutdown helper and keep proxy alive via guard.
tests/integration/tests/suite/path_rewrite.rs Use URI-echo backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/json_body_field.rs Use header-echo backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/ip_acl.rs Use backend shutdown helpers and keep proxy alive via guard.
tests/integration/tests/suite/health_check.rs Use backend shutdown helper for stable backend in health-check tests.
tests/integration/tests/suite/filter_composition.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/examples/weighted_load_balancing.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/examples/virtual_hosts.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/examples/timeout.rs Use backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/examples/stream_buffer.rs Return (BackendGuard, ProxyGuard) from setup; use guards in tests.
tests/integration/tests/suite/examples/static_response.rs Hold ProxyGuard and use proxy.addr().
tests/integration/tests/suite/examples/session_affinity.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/examples/round_robin.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/examples/redirect.rs Hold ProxyGuard and use proxy.addr().
tests/integration/tests/suite/examples/path_rewriting.rs Use URI-echo backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/examples/path_based_routing.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/examples/multi_listener.rs Use backend shutdown helpers (multi-listener example).
tests/integration/tests/suite/examples/model_to_header.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/examples/max_body_guard.rs Use backend shutdown helper and ProxyGuard for registry-based proxy.
tests/integration/tests/suite/examples/logging.rs Use backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/examples/least_connections.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/examples/header_manipulation.rs Use backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/examples/default_config.rs Hold ProxyGuard and use proxy.addr().
tests/integration/tests/suite/examples/conditional_filters.rs Use backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/examples/canary_routing.rs Use backend shutdown helpers and ProxyGuard.
tests/integration/tests/suite/examples/basic_reverse_proxy.rs Use backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/examples/api_key_filter.rs Use backend shutdown helper and ProxyGuard for registry-based proxy.
tests/integration/tests/suite/examples/access_logging.rs Use backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/downstream_read_timeout.rs Use backend shutdown helper and ProxyGuard (including raw TCP connect).
tests/integration/tests/suite/conditions.rs Use header-echo backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/compression.rs Use backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/adversarial/rate_limit_bypass.rs Use backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/adversarial/path_traversal.rs Use URI-echo backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/adversarial/ipv6_bypass.rs Use backend shutdown helper and ProxyGuard for v4/v6 cases.
tests/integration/tests/suite/adversarial/host_header.rs Use backend shutdown helper and ProxyGuard.
tests/integration/tests/suite/adversarial/header_smuggling.rs Use backend/header-echo shutdown helpers and ProxyGuard.
tests/conformance/tests/suite/tls.rs Update TLS proxy helpers to return/hold ProxyGuard.
tests/conformance/tests/suite/rfcs/rfc9113.rs Use ProxyGuard and proxy.addr() for HTTP/2 conformance tests.
tests/conformance/tests/suite/rfcs/rfc7239.rs Use ProxyGuard and update wrapper to return ProxyGuard.
tests/conformance/tests/suite/rfcs/rfc6265.rs Use ProxyGuard and proxy.addr().
tests/conformance/tests/suite/ipv6.rs Use ProxyGuard and proxy.addr() for v6 tests.
tests/conformance/tests/suite/h2spec.rs Use ProxyGuard and proxy.addr() before invoking h2spec.
tests/conformance/tests/suite/cors.rs Use ProxyGuard and proxy.addr().
tests/conformance/tests/suite/chunked.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/transformation/header_manipulation.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/traffic_management/weighted_load_balancing.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/traffic_management/virtual_hosts.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/traffic_management/timeout.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/traffic_management/static_response.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/traffic_management/session_affinity.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/traffic_management/round_robin.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/traffic_management/path_based_routing.rs Use ProxyGuard and proxy.addr() (retry variant).
tests/configuration/tests/suite/examples/traffic_management/least_connections.rs Use ProxyGuard and proxy.addr() (incl. concurrent case).
tests/configuration/tests/suite/examples/traffic_management/canary_routing.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/traffic_management/basic_reverse_proxy.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/pipeline/default_config.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/pipeline/conditional_filters.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/payload_processing/stream_buffer.rs Update to ProxyGuard usage (but backend still starts without shutdown guard).
tests/configuration/tests/suite/examples/observability/logging.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/observability/access_logging.rs Use ProxyGuard and proxy.addr().
tests/configuration/tests/suite/examples/max_body_guard.rs Use ProxyGuard and proxy.addr() for registry-based proxy.
tests/configuration/tests/suite/examples/api_key_filter.rs Use ProxyGuard and proxy.addr() for registry-based proxy.
tests/configuration/tests/suite/examples/ai/model_to_header.rs Use ProxyGuard and pass proxy.addr() into http_post.
Cargo.lock Add/adjust dependencies due to new tests/utils requirements.

Comment thread tests/utils/src/proxy.rs
Comment thread tests/utils/src/net/backend/simple.rs
@shaneutt shaneutt dismissed their stale review April 22, 2026 17:18

accidental

@shaneutt
Copy link
Copy Markdown
Member

Ignoring the PR size failure for this one.

@shaneutt shaneutt merged commit e5fe941 into praxis-proxy:main Apr 22, 2026
12 of 13 checks passed
@github-project-automation github-project-automation Bot moved this from Review to Done in AI Gateway Apr 22, 2026
@esnible esnible deleted the stop-test-threads branch April 23, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants