codearts: test an IDE write-ahead log rewritten in one clock tick (#1012)
Test only. Adds a codearts regression for #1007's fix (029c628f): the IDE's -wal is rewritten within one clock tick, with the main database's bytes, the sidecar's size and its mtime unchanged, and the reader still picks up the new credential. No package bump: nothing shipped changes. Run at the reviewed head d53a142a (on mote, temp HOME): - packages/codearts `bun test`: 203 pass, 0 fail. `bun scripts/check.mjs`: ok. - Root `bun test` (suite lock) on origin/maina69931ecmerged with #1009, #1012 and #1013: 8373 pass, 0 fail (8392 tests across 590 files, 361s; the rest skipped), on Linux (Ubuntu 24.04, magpie-desktop) because both Macs' suite locks were held by hours-long runs. `bun scripts/check.mjs` on that tree: ok. Broken by hand: ideReader's sidecar loop changed to `for (const suffix of [])`, so -wal and -journal no longer go into the stamp. Only the new test fails (202 pass, 1 fail: "the IDE's write-ahead log rewritten in one clock tick is read again"); none of the existing tests caught it. With the code restored, it passes. Not tried: a real CodeArts Agent IDE writing its WAL. Co-authored-by: zhou.han <18181754+yetihan@users.noreply.github.com>
This commit is contained in:
@@ -4571,6 +4571,25 @@ test("the IDE's file rewritten in one clock tick, at the same size, is read agai
|
||||
assert.equal((await read()).cred, undefined)
|
||||
})
|
||||
|
||||
test("the IDE's write-ahead log rewritten in one clock tick is read again", async () => {
|
||||
const first = await ideFixture({ value: ideValue(ideOrigin()), wal: true })
|
||||
const second = await ideFixture({ value: ideValue(ideOrigin({ accessKey: "IDEAK2" })), wal: true })
|
||||
const t = new Date(2000000000000)
|
||||
fs.utimesSync(first.file, t, t)
|
||||
fs.utimesSync(`${first.file}-wal`, t, t)
|
||||
const mainBefore = fs.readFileSync(first.file)
|
||||
const walBefore = fs.statSync(`${first.file}-wal`)
|
||||
const read = x.ideReader(first.file)
|
||||
assert.equal((await read()).cred?.access_key_id, "IDEAK1")
|
||||
|
||||
fs.copyFileSync(`${second.file}-wal`, `${first.file}-wal`)
|
||||
fs.utimesSync(`${first.file}-wal`, walBefore.atime, walBefore.mtime)
|
||||
assert.deepEqual(fs.readFileSync(first.file), mainBefore, "the main database is unchanged")
|
||||
assert.equal(fs.statSync(`${first.file}-wal`).size, walBefore.size)
|
||||
assert.equal(fs.statSync(`${first.file}-wal`).mtimeMs, walBefore.mtimeMs)
|
||||
assert.equal((await read()).cred?.access_key_id, "IDEAK2")
|
||||
})
|
||||
|
||||
test("an international account chats, reads and renews on its own station only", async () => {
|
||||
const fx = await ideFixture({ value: ideValue(ideOrigin()) })
|
||||
const urls = []
|
||||
|
||||
Reference in New Issue
Block a user