Add k6 and Socket.IO load tests for API and WebSocket endpoints (#60) - #85
Open
BigManly4 wants to merge 2 commits into
Open
Add k6 and Socket.IO load tests for API and WebSocket endpoints (#60)#85BigManly4 wants to merge 2 commits into
BigManly4 wants to merge 2 commits into
Conversation
src/controllers/deliveryController.ts contained two unrelated modules concatenated together (the ETA controller and a separate CRUD controller with its own Request/Response import), causing duplicate identifier errors and a DeliveryStatus type mismatch that made tsc/pnpm build fail. Split the CRUD functions out into deliveryCrudController.ts and updated src/routes/delivery.ts to import from it. Neither route file is currently mounted in routes/index.ts, so this has no effect on live behavior - it only makes the project compile.
Add k6 scenarios covering auth and delivery REST endpoints, plus a socket.io-client based harness for load-testing the real-time location gateway, both driven by real seeded MongoDB data instead of mocks. Also attach the previously unwired Socket.IO gateway (initializeSocketServer) to the HTTP server in server.ts, since it was dead code and there was otherwise no running WebSocket endpoint to test.
|
@BigManly4 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #60
Summary
delivery CRUD + status update endpoints under /api/v1.
the real socket.io-client library, since neither k6 nor Artillery ship
a maintained engine that speaks the Socket.IO protocol. It ramps up N
concurrent simulated driver connections, authenticates each via the
real /api/v1/auth/login endpoint, joins a delivery room, and emits
driver_location_update on an interval, reporting connect/ack success
rates at the end of the run.
documents through the application's own Mongoose models before a run.
No inline mocks or hardcoded response data are used anywhere in the
suite; every scenario exercises the real HTTP/WebSocket API against
that seeded data.
controller -> service -> model layering (documented in
load-tests/README.md).
Required fix to make WebSocket testing possible
src/sockets/connectionHandler.ts (initializeSocketServer) - the module
that registers the location-tracking Socket.IO gateway - was never
attached to the HTTP server in src/server.ts. The app only ever called
app.listen(...) directly, so the WebSocket gateway was dead code with no
way to connect to it. This PR updates server.ts to use
http.createServer(app) + initializeSocketServer(httpServer), with a
graceful shutdown call to shutdownSocketServer. No behavior of the
gateway itself was changed.
Also fixed: pre-existing build failure
src/controllers/deliveryController.ts contained two unrelated modules
concatenated together (apparent bad merge), causing duplicate
Request/Response identifiers and a DeliveryStatus type mismatch that
made tsc/pnpm build fail on main independent of this PR. Split the CRUD
functions into deliveryCrudController.ts and updated the import in
routes/delivery.ts. Neither route file is mounted in routes/index.ts, so
this is a compile-only fix with no behavior change.
Known pre-existing gaps (left out of scope)
are not mounted in src/routes/index.ts, so those endpoints 404 and are
excluded from the load test scenarios.
How to run
See load-tests/README.md. In short:
cd load-tests && npm install && cp .env.example .env
npm run seed
npm run test:api:auth && npm run test:api:deliveries
npm run test:ws
Test plan
(http_req_failed rate < 1%, p95 < 500ms)