-
Notifications
You must be signed in to change notification settings - Fork 8
[TILES-V2-10]: add load testing scripts for tiles database #1011
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
base: tiles-v2/frontend-temp
Are you sure you want to change the base?
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Datadog ReportBranch report: ✅ 0 Failed, 773 Passed, 0 Skipped, 2m 46.06s Total Time |
99c1ebb
to
b33d2f0
Compare
3dbe636
to
fe3bddb
Compare
e122f70
to
dde79fa
Compare
fe3bddb
to
671f353
Compare
dde79fa
to
7bdb006
Compare
671f353
to
cee0f04
Compare
7bdb006
to
08bb207
Compare
cee0f04
to
86f6844
Compare
08bb207
to
44bdd6a
Compare
86f6844
to
8a0169b
Compare
44bdd6a
to
445c1c6
Compare
8a0169b
to
6707e1a
Compare
445c1c6
to
87878a6
Compare
6707e1a
to
a960b53
Compare
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.
Bug: SQL Syntax Error and Incorrect Result Validation
The script contains two bugs: The SQL query ends with a double semicolon (;;
), which is a syntax error. Additionally, it incorrectly uses rowsAffected()
to validate the result of a SELECT query. rowsAffected()
is intended for DML operations (INSERT, UPDATE, DELETE) and typically returns 0 for SELECT queries, causing the check rowsAffected() === 1
to always fail.
tools/load-tests/tiles/read_action.js#L34-L42
plumber/tools/load-tests/tiles/read_action.js
Lines 34 to 42 in a960b53
const result = db.exec(` | |
SELECT * FROM "public"."load_test_table_1" WHERE "column1" = 'row${Math.floor( | |
Math.random() * 1000, | |
)}-col1';; | |
`) | |
// const result = db.exec(` | |
// SELECT 1 FROM "public"."load_test_table_${exec.vu.idInInstance}"; | |
// `) | |
check(result, 'is added', (r) => r.rowsAffected() === 1) |
tools/load-tests/tiles/test.js#L13-L14
plumber/tools/load-tests/tiles/test.js
Lines 13 to 14 in a960b53
const result = db.exec(`SELECT 1 as connection_test`) | |
console.log(result.rowsAffected()) |
Bug: Table Name Mismatch Causes Load Test Failures
The load test scripts (bulk_write.js
, write_action.js
, bulk_read.js
) use exec.vu.idInInstance
for table names, which conflicts with the seed script's use of exec.vu.iterationInInstance
. This mismatch causes read, insert, and bulk insert operations to fail due to non-existent tables. The bulk_read.js
script also lacks the maxVUs
scenario option and has a misleading console.log
message about the number of rows read.
tools/load-tests/tiles/bulk_read.js#L9-L38
plumber/tools/load-tests/tiles/bulk_read.js
Lines 9 to 38 in a960b53
scenarios: { | |
contacts: { | |
executor: 'constant-arrival-rate', | |
duration: '5m', | |
rate: 100, | |
// It should start `rate` iterations per second | |
timeUnit: '10s', | |
// It should preallocate 2 VUs before starting the test | |
preAllocatedVUs: 100, | |
// It is allowed to spin up to 50 maximum VUs to sustain the defined | |
// constant arrival rate. | |
}, | |
}, | |
} | |
export default function () { | |
const db = sql.open(driver, __ENV.POSTGRES_TILES_URL) | |
const i = Math.floor(Math.random() * 30) | |
db.exec(` | |
SELECT * FROM "public"."load_test_table_${ | |
exec.vu.idInInstance | |
}" ORDER BY "rowId" LIMIT 10000 OFFSET ${i * 10000}; | |
`) | |
console.log( | |
`read ${i * 10000} rows in load_test_table_${exec.vu.idInInstance}`, |
tools/load-tests/tiles/write_action.js#L39-L42
plumber/tools/load-tests/tiles/write_action.js
Lines 39 to 42 in a960b53
const result = db.exec(` | |
INSERT INTO "public"."load_test_table_${ | |
exec.vu.idInInstance | |
}" ("rowId", "column0", "column1", "column2", "column3", "column4", "column5", "column6", "column7", "column8", "column9") VALUES ${generatedRows |
tools/load-tests/tiles/bulk_write.js#L39-L42
plumber/tools/load-tests/tiles/bulk_write.js
Lines 39 to 42 in a960b53
const result = db.exec(` | |
INSERT INTO "public"."load_test_table_${ | |
exec.vu.idInInstance | |
}" ("rowId", "column0", "column1", "column2", "column3", "column4", "column5", "column6", "column7", "column8", "column9") VALUES ${generatedRows |
Bug: Update Fails Due to Missing ID and Table Name Mismatch
The UPDATE query fails because the hardcoded rowId
'to update' does not exist (other scripts use generated UUIDs), resulting in 0 rows updated. A potential table name mismatch (idInInstance
vs iterationInInstance
) could also cause the table not to be found. Both issues lead to the check on line 37 failing.
tools/load-tests/tiles/update_action.js#L33-L34
plumber/tools/load-tests/tiles/update_action.js
Lines 33 to 34 in a960b53
const result = db.exec(` | |
UPDATE "public"."load_test_table_${exec.vu.idInInstance}" SET "column2" = 'updated' WHERE "rowId" = 'to update'; |
BugBot free trial expires on June 10, 2025
You have used $0.00 of your $1.00 spend limit so far. Manage your spend limit in the Cursor dashboard.
Was this report helpful? Give feedback by reacting with 👍 or 👎
TL;DR
Added load testing scripts for Postgres database operations with k6 extensions.
What changed?
.env-example
file with Postgres connection stringseed_table.js
- Creates test tablesbulk_write.js
- Tests bulk insert operationsbulk_read.js
- Tests bulk read operationsread_action.js
- Tests single read operationswrite_action.js
- Tests single write operationsupdate_action.js
- Tests update operationstest.js
- Simple connection testHow to test?
.env-example
to.env
and update with your Postgres connection details