Skip to content

Add Grafana K6 performance test scripts for all 5 microservices#27

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1777561484-k6-performance-tests
Open

Add Grafana K6 performance test scripts for all 5 microservices#27
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1777561484-k6-performance-tests

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented Apr 30, 2026

Summary

Adds Grafana K6 performance test scripts for all 5 microservices (Identity, Customer, Order, Product, Notification) plus a combined all-services test that runs 10 VUs across all services simultaneously.

Files added (k6-tests/)

File Purpose
config.js Shared config — service URLs, __ENV mapping, default stages & thresholds
utils.js Auth helpers (Bearer + Basic), check() wrappers for GET/POST
data/*.json 20 production-realistic records per service for data-driven testing via SharedArray
identity-test.js GET /api/identity, GET /api/identity/{id}
customer-test.js GET /api/customer, GET /api/customer/{id}
order-test.js GET /api/order, GET /api/order/{id}
product-test.js GET /api/product, GET /api/product/{id}
notification-test.js GET (paginated), GET by ID, GET preview, POST /events/order-placed
all-services-test.js Combined test — 10 VUs (2 per service), 25 iterations each, ~5 min with pacing

Combined test results (actual run)

All 250 iterations completed, 1750/1750 checks passed (100%), all thresholds met:

Service Requests Avg Med p95 Max
Identity 100 2.10ms 0.98ms 1.77ms 47ms
Customer 100 1.86ms 0.95ms 3.85ms 39.76ms
Order 100 1.94ms 0.99ms 1.98ms 32.46ms
Product 100 2.03ms 1.02ms 2.15ms 30.38ms
Notification 200 8.41ms 2.49ms 7.35ms 408.93ms
Overall 601 4.14ms 1.24ms 6.25ms 408.93ms

Error rate: 0.16% (1/601) — within the 5% threshold.

Bug fix included

Fixed Notification.API.csproj — Shared project reference paths were ../../Shared/ but needed ../../../Shared/ (three levels up from Services/Notification/Notification.API/).

Review & Testing Checklist for Human

  • Run docker compose up --build and execute k6 run k6-tests/all-services-test.js to verify end-to-end
  • Review threshold values in config.js / all-services-test.js for your target SLAs
  • Verify the Notification.API.csproj path fix doesn't break your local IDE or CI build

Notes

  • The combined test uses per-vu-iterations executor for precise control: exactly 2 VUs × 25 iterations = 50 requests per service
  • Pacing (~10s ± 3s jitter between iterations) spreads load realistically across the 5-minute window
  • Each iteration picks different data records (20 per service) to avoid cache hits and emulate production variance

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/c2a7605ddb284e07a746fbc9eabb5eac
Requested by: @vinodsvv


Open in Devin Review

- Identity, Customer, Order, Product, Notification service tests
- Shared config (config.js) with env vars, stages, thresholds
- Shared utils (utils.js) with auth helpers and check functions
- Test data JSON files for data-driven testing via SharedArray
- Bearer token & Basic auth support with setup() function
- Response validation via check() on status, timing, body
- Logical grouping of requests via group()
- Ramp-up/steady/spike/ramp-down load stages
- Per-group threshold assertions for p95/p99 latency
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Contributor Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment on lines +53 to +55
const headers = token
? { 'Content-Type': 'application/json', Accept: 'application/json', Authorization: `Bearer ${token}` }
: { 'Content-Type': 'application/json', Accept: 'application/json' };
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🟡 Notification test setup() missing basic auth fallback, unlike default function

In notification-test.js, the setup() function constructs headers manually (lines 53-55) and sends the seed POST request without any Authorization header when fetchBearerToken() returns null. However, the default function (lines 82-84) correctly falls back to basicAuthHeaders() when no token is available. This inconsistency means the seed request goes out unauthenticated while all other requests use Basic auth. If the service (or API Gateway) requires authentication but the token endpoint is unavailable, the seed request will fail with 401, leaving seededId as null. This silently causes Groups 3 and 4 ("Get By ID" and "Preview") to be skipped entirely (line 158), so half the notification test coverage is lost without any test failure or warning.

Suggested change
const headers = token
? { 'Content-Type': 'application/json', Accept: 'application/json', Authorization: `Bearer ${token}` }
: { 'Content-Type': 'application/json', Accept: 'application/json' };
const headers = token
? { 'Content-Type': 'application/json', Accept: 'application/json', Authorization: `Bearer ${token}` }
: basicAuthHeaders();
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

- all-services-test.js: 10 VUs (2 per service), 25 iterations each, 5 min duration
- Per-VU scenarios using per-vu-iterations executor for precise control
- Expanded data sets to 20 records per service for production-realistic traffic
- Custom metrics (Counter + Trend) per service for granular monitoring
- Pacing with jitter to emulate realistic production request patterns
- Fix Notification.API.csproj Shared project reference paths (../../ -> ../../../)
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.

0 participants