-
Notifications
You must be signed in to change notification settings - Fork 80
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
base: feat_add_support_for_JSON5/JSONC_config_files
Are you sure you want to change the base?
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: |
a4e4261
|
Status: | ✅ Deploy successful! |
Preview URL: | https://dd7ee1d3.rivet-hub-7jb.pages.dev |
Branch Preview URL: | https://feat-add-basic-websocket-loa.rivet-hub-7jb.pages.dev |
c65e1d9
to
97074b7
Compare
c3e4d57
to
198ece0
Compare
198ece0
to
8c36eb9
Compare
97074b7
to
2b00537
Compare
2b00537
to
a91972e
Compare
8c36eb9
to
a4e4261
Compare
a4e4261
to
8c36eb9
Compare
2b00537
to
07555f6
Compare
8c36eb9
to
825a831
Compare
07555f6
to
a91972e
Compare
825a831
to
a4e4261
Compare
a4e4261
to
8c36eb9
Compare
a91972e
to
2b00537
Compare
2b00537
to
a91972e
Compare
8c36eb9
to
a4e4261
Compare
a4e4261
to
8c36eb9
Compare
2b00537
to
a91972e
Compare
8c36eb9
to
a4e4261
Compare
Changes