-
Notifications
You must be signed in to change notification settings - Fork 83
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
chore: add basic load test #2060
chore: add basic load test #2060
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR introduces a comprehensive k6 load testing framework for WebSocket functionality in Rivet, with configurable parameters and actor management capabilities.
- In
/tests/load/basic/index.js
, core WebSocket testing functionality is commented out, leaving only actor creation/destruction - this needs to be uncommented and implemented /tests/load/basic/actor.js
lacks proper timeout configuration inwaitForHealth()
function which could lead to hanging tests/tests/load/basic/rivet_api.js
only supports GET/POST methods, limiting test capabilities for DELETE operations/tests/load/basic/rivet_api.js
assumes all successful responses return 200 status code which may not handle 201/204 responses correctly- In
/tests/load/basic/actor.js
, WebSocket error handling doesn't include timeout scenarios or connection failures
5 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile
justfile
Outdated
k6-run TEST: | ||
k6 run --verbose tests/load/{{ TEST }}/index.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: k6-run command lacks explicit VU and iteration settings - could lead to unintended load on systems. Consider adding configurable parameters.
tests/load/basic/index.js
Outdated
//// Get endpoint info | ||
//const port = actor.network.ports.http; | ||
//const actorOrigin = `${port.protocol}://${port.hostname}:${port.port}${port.path ?? ""}`; | ||
// | ||
//// Wait for health check | ||
//const isHealthy = waitForHealth(`${actorOrigin}/health`); | ||
//if (!isHealthy) { | ||
// console.error('Health check failed'); | ||
// return; | ||
//} | ||
// | ||
//// Test WebSocket | ||
//const wsUrl = `${actorOrigin}/ws`; | ||
//testWebSocket(wsUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Core WebSocket testing functionality is commented out. Either uncomment and implement the tests, or remove the commented code if it's not needed.
tests/load/basic/actor.js
Outdated
export function waitForHealth(url) { | ||
let attempts = 0; | ||
const maxAttempts = 30; | ||
|
||
while (attempts < maxAttempts) { | ||
const response = http.get(url); | ||
if (response.status === 200) { | ||
return true; | ||
} | ||
sleep(0.1); | ||
attempts++; | ||
} | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Missing http import. waitForHealth will fail at runtime.
export function waitForHealth(url) { | |
let attempts = 0; | |
const maxAttempts = 30; | |
while (attempts < maxAttempts) { | |
const response = http.get(url); | |
if (response.status === 200) { | |
return true; | |
} | |
sleep(0.1); | |
attempts++; | |
} | |
return false; | |
} | |
import { check, sleep } from "k6"; | |
import ws from "k6/ws"; | |
import http from "k6/http"; | |
import { callRivetApi } from "./rivet_api.js"; |
tests/load/basic/actor.js
Outdated
socket.on("error", () => { | ||
reject(false); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Error handler should include error details in rejection for better debugging
tests/load/basic/rivet_api.js
Outdated
|
||
// Standard checks | ||
const checks = { | ||
"status is 200": (r) => r.status === 200, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Status check is too strict. Some valid responses may use 201 (Created) or 204 (No Content).
"status is 200": (r) => r.status === 200, | |
"status is successful": (r) => r.status >= 200 && r.status < 300, |
tests/load/basic/rivet_api.js
Outdated
fail(`${path} request failed`); | ||
} | ||
|
||
return JSON.parse(response.body); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Attempting to parse response body twice - once in check and once in return. Could cache the parsed result.
52486f4
to
dc6cea5
Compare
7171d0f
to
c7e13e3
Compare
Deploying rivet-hub with
|
Latest commit: |
745d6de
|
Status: | ✅ Deploy successful! |
Preview URL: | https://86749208.rivet-hub-7jb.pages.dev |
Branch Preview URL: | https://feat-add-basic-websocket-loa.rivet-hub-7jb.pages.dev |
0e11e7a
to
1ff560c
Compare
1ff560c
to
745d6de
Compare
7b83adc
to
4c23ff5
Compare
4c23ff5
to
7b83adc
Compare
745d6de
to
1ff560c
Compare
1ff560c
to
745d6de
Compare
7b83adc
to
4c23ff5
Compare
4c23ff5
to
7b83adc
Compare
745d6de
to
1ff560c
Compare
1ff560c
to
745d6de
Compare
7b83adc
to
4c23ff5
Compare
Merge activity
|
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->
Changes