Skip to content

feat: app for testing concurrent sampling#232

Merged
kapishupadhyay22 merged 1 commit into
mainfrom
go-sampling
May 21, 2026
Merged

feat: app for testing concurrent sampling#232
kapishupadhyay22 merged 1 commit into
mainfrom
go-sampling

Conversation

@kapishupadhyay22
Copy link
Copy Markdown
Member

@kapishupadhyay22 kapishupadhyay22 commented May 21, 2026

Summary

Adds a minimal sampling-test sample app used by the new --enable-sampling end-to-end CI pipeline in keploy/keploy (#4209).

The app is intentionally minimal — stdlib net/http only, no external dependencies, no database. Its only job is to make the Keploy proxy's sampling slot semaphore observable from the outside:

  • GET /work sleeps HANDLER_DELAY_MS (default 500 ms) before responding. The long handler delay guarantees that a concurrent burst of curl requests overlaps inside the Keploy proxy, so the slot semaphore is genuinely contended.
  • GET /health is a non-sleeping readiness probe.
  • curl.sh fires TOTAL_REQUESTS (default 20) curls in parallel via & + wait, each with --no-keepalive so every request gets its own TCP connection. It records every response code and exits non-zero if any client saw non-2xx.

With keploy record --enable-sampling=5, the expected outcome is that 5 of the 20 requests are captured as test cases (slot count saturated) while the remaining 15 are proxied transparently without being recorded. The companion keploy workflow asserts exactly that.

Files added

sampling-test/
├── go.mod          # stdlib-only module
├── main.go         # /work (delayed) + /health
├── curl.sh         # N concurrent requests, fails on any non-2xx
└── README.md       # how to reproduce locally

Links

Reproduce locally

cd sampling-test
go build -o sampling-test .
./sampling-test &
TOTAL_REQUESTS=20 bash curl.sh    # all 20 should return 200

Then under keploy record --enable-sampling=5, you should see exactly 5 get-work-*.yaml test cases under ./keploy/test-set-0/tests/.

Type of change

  • New sample app
  • Used by an existing keploy CI workflow

Checklist

  • No external dependencies introduced (go.mod is stdlib-only)
  • go build passes on Go 1.24.2
  • curl.sh is executable and passes bash -n syntax check
  • Sample exposes a /health endpoint for readiness probing
  • No customer data, no internal hostnames, no real credentials

Signed-off-by: kapish <upadhyaykapish@gmail.com>
Copilot AI review requested due to automatic review settings May 21, 2026 08:44
Copy link
Copy Markdown
Contributor

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

Adds a new sampling-test Go module intended to generate bursts of concurrent HTTP requests for validating Keploy’s --enable-sampling behavior (capture limited in-flight requests while bypassing the rest without breaking clients).

Changes:

  • Introduces a minimal net/http server with /work (delayed response) and /health endpoints.
  • Adds a companion curl.sh to fire concurrent requests and verify all clients receive 2xx responses.
  • Documents local usage and the CI intent of the sample.

Reviewed changes

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

File Description
sampling-test/README.md Documents the purpose of the sampling test app and local run steps.
sampling-test/main.go Implements the minimal HTTP server with delayed /work handler for concurrency overlap.
sampling-test/go.mod Adds a standalone Go module definition for the new sample.
sampling-test/curl.sh Adds a concurrent curl driver script that records per-request status/body outputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sampling-test/main.go
Comment thread sampling-test/main.go
Comment thread sampling-test/README.md
@kapishupadhyay22 kapishupadhyay22 merged commit 7a232e1 into main May 21, 2026
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants