Skip to content

Commit 6b24ca4

Browse files
andinuxclaude
andcommitted
test(e2e): assert the actionable not-initialized message in the failure path
The Failure Path Test only checked that a lastFailure object existed. Now that cloudsync_payload_chunks propagates its error, the server forwards "cloudsync is not initialized" for the check job too (previously a bare "SQL logic error"), so assert the message on all three surfaces: the send lastFailure JSON, the non-retryable SQL error raised by receive_changes, and the sync JSON. Goes green once the node runs 1.1.1. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 1ad6947 commit 6b24ca4

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

test/integration.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,16 +1521,33 @@ int test_failure_path (const char *db_path) {
15211521
// Give the server time to process and fail the queued apply/check jobs.
15221522
sqlite3_sleep(5000);
15231523

1524-
// Second invocation — failures must surface now.
1525-
// jobId is always > 0 when failure object is present, so ->> + GT0 doubles as
1526-
// an existence check (NULL → atoi returns 0 → fails GT0).
1524+
// Second invocation — failures must surface now. The tenant database is not
1525+
// configured for cloudsync on the node, so every surfaced failure must carry
1526+
// the actionable "cloudsync is not initialized" message (instr on the message
1527+
// doubles as the lastFailure existence check: NULL fails GT0).
15271528
rc = db_expect_gt0(db,
1528-
"SELECT cloudsync_network_send_changes() ->> '$.send.lastFailure.jobId';"); RCHECK
1529-
rc = db_expect_gt0(db,
1530-
"SELECT cloudsync_network_receive_changes() ->> '$.receive.lastFailure.jobId';"); RCHECK
1531-
// sync must surface at least one of the two; instr() catches either path.
1529+
"SELECT instr(cloudsync_network_send_changes() ->> '$.send.lastFailure.message', 'cloudsync is not initialized');"); RCHECK
1530+
1531+
// The server reports the failed check job as non-retryable, so
1532+
// receive_changes raises a SQL error instead of returning JSON.
1533+
char *errmsg = NULL;
1534+
if (sqlite3_exec(db, "SELECT cloudsync_network_receive_changes();", NULL, NULL, &errmsg) == SQLITE_OK) {
1535+
printf("Error: expected cloudsync_network_receive_changes to fail, but it succeeded\n");
1536+
rc = SQLITE_ERROR;
1537+
goto abort_test;
1538+
}
1539+
if (!errmsg || !strstr(errmsg, "cloudsync is not initialized")) {
1540+
printf("Error: unexpected receive_changes error: %s\n", errmsg ? errmsg : "(null)");
1541+
sqlite3_free(errmsg);
1542+
rc = SQLITE_ERROR;
1543+
goto abort_test;
1544+
}
1545+
sqlite3_free(errmsg);
1546+
1547+
// sync keeps emitting structured JSON so its send block survives; the
1548+
// forwarded message must appear in at least one lastFailure object.
15321549
rc = db_expect_gt0(db,
1533-
"SELECT instr(cloudsync_network_sync(250, 1), '\"lastFailure\":');"); RCHECK
1550+
"SELECT instr(cloudsync_network_sync(250, 1), 'cloudsync is not initialized');"); RCHECK
15341551

15351552
rc = db_exec(db, "SELECT cloudsync_terminate();");
15361553

0 commit comments

Comments
 (0)