Skip to content

Commit 2ae6f53

Browse files
committed
test: improved stress test command
1 parent 2e871a4 commit 2ae6f53

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

.claude/commands/stress-test-sync-sqlitecloud.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,17 @@ For the network init call throughout the test, use:
6666
- Default address: `SELECT cloudsync_network_init('<MANAGED_DB_ID>');`
6767
- Custom address: `SELECT cloudsync_network_init_custom('<CUSTOM_ADDRESS>', '<MANAGED_DB_ID>');`
6868

69-
### Step 4: Get Auth Tokens (if RLS enabled)
69+
### Step 4: Set Up Authentication
7070

71-
Create tokens for the test users. Create as many users as needed for the number of concurrent databases (assign 2 databases per user, or 1 per user if NUM_DBS <= 2).
71+
Authentication depends on the RLS mode:
72+
73+
**If RLS is disabled:** Use the project `APIKEY` (already extracted from the connection string). After each `cloudsync_network_init`/`cloudsync_network_init_custom` call, authenticate with:
74+
```sql
75+
SELECT cloudsync_network_set_apikey('<APIKEY>');
76+
```
77+
No tokens are needed. Skip token creation entirely.
78+
79+
**If RLS is enabled:** Create tokens for the test users. Create as many users as needed for the number of concurrent databases (assign 2 databases per user, or 1 per user if NUM_DBS <= 2).
7280

7381
For each user N:
7482
```bash
@@ -78,9 +86,12 @@ curl -s -X "POST" "https://<HOST>/v2/tokens" \
7886
-d '{"name": "claude<N>@sqlitecloud.io", "userId": "018ecfc2-b2b1-7cc3-a9f0-<N_PADDED_12_CHARS>"}'
7987
```
8088

81-
Save each user's `token` and `userId` from the response.
89+
Save each user's `token` and `userId` from the response. After each `cloudsync_network_init`/`cloudsync_network_init_custom` call, authenticate with:
90+
```sql
91+
SELECT cloudsync_network_set_token('<TOKEN>');
92+
```
8293

83-
If RLS is disabled, skip this step — tokens are not required.
94+
**IMPORTANT:** Using a token when RLS is disabled will cause the server to silently reject all sent changes (send appears to succeed but data is not persisted remotely). Always use `cloudsync_network_set_apikey` when RLS is off.
8495

8596
### Step 5: Run the Concurrent Stress Test
8697

@@ -95,9 +106,9 @@ Create a bash script at `/tmp/stress_test_concurrent.sh` that:
95106
2. **Defines a worker function** that runs in a subshell for each database:
96107
- Each worker logs all output to `/tmp/sync_concurrent_<N>.log`
97108
- Each iteration does:
98-
a. **DELETE all rows**`send_changes()``check_changes()`
99-
b. **INSERT <ROWS> rows** (in a single BEGIN/COMMIT transaction) → `send_changes()``check_changes()`
100-
c. **UPDATE all rows**`send_changes()``check_changes()`
109+
a. **DELETE all rows**`cloudsync_network_sync(100, 10)`
110+
b. **INSERT <ROWS> rows** (in a single BEGIN/COMMIT transaction) → `cloudsync_network_sync(100, 10)`
111+
c. **UPDATE all rows**`cloudsync_network_sync(100, 10)`
101112
- Each session must: `.load` the extension, call `cloudsync_network_init()`, `cloudsync_network_set_token()` (if RLS), do the work, call `cloudsync_terminate()`
102113
- Include labeled output lines like `[DB<N>][iter <I>] deleted/inserted/updated, count=<C>` for grep-ability
103114

0 commit comments

Comments
 (0)