mirror of
https://github.com/affaan-m/ECC.git
synced 2026-10-18 14:07:33 +02:00
fix: make concurrency test genuinely overlapping with continuous validity probes
Each writer performs 30 write rounds to widen the race window. Drop the vacuous exitCode liveness assert and the swallowing mid-flight read; instead every wait-loop poll reads and validates the state, so torn reads fail loudly.
This commit is contained in:
@@ -434,9 +434,11 @@ function runTests() {
|
||||
const { spawn } = require('child_process');
|
||||
const script = 'const fs = require("fs");' +
|
||||
'const {readInstallState, writeInstallState} = require(process.env.REPO_ROOT + "/scripts/lib/install-state");' +
|
||||
'for (let round = 0; round < 30; round += 1) {' +
|
||||
'const state = readInstallState(process.env.STATE_PATH);' +
|
||||
'state.lastValidatedAt = process.env.MARKER;' +
|
||||
'writeInstallState(process.env.STATE_PATH, state);' +
|
||||
'}' +
|
||||
'fs.writeFileSync(process.env.DONE_FILE, "ok");';
|
||||
const children = markers.slice(1).map(marker => {
|
||||
const tag = marker.replace(/:/g, '-');
|
||||
@@ -456,18 +458,10 @@ function runTests() {
|
||||
fs.closeSync(errFd);
|
||||
return { child, marker, doneFile, errFile };
|
||||
});
|
||||
assert.ok(
|
||||
children.some(entry => entry.child.exitCode === null),
|
||||
'expected writers to still be running right after launch'
|
||||
);
|
||||
let midRead = null;
|
||||
try {
|
||||
midRead = readInstallState(statePath);
|
||||
} catch (_error) {
|
||||
midRead = null;
|
||||
}
|
||||
const deadline = Date.now() + 60000;
|
||||
const deadline = Date.now() + 120000;
|
||||
for (;;) {
|
||||
const snapshot = readInstallState(statePath);
|
||||
assert.ok(markers.includes(snapshot.lastValidatedAt));
|
||||
const pending = children.filter(entry => !fs.existsSync(entry.doneFile));
|
||||
if (pending.length === 0) break;
|
||||
if (Date.now() > deadline) {
|
||||
@@ -481,9 +475,6 @@ function runTests() {
|
||||
for (const entry of children) {
|
||||
assert.strictEqual(fs.readFileSync(entry.errFile, 'utf8'), '', `writer ${entry.marker} failed`);
|
||||
}
|
||||
if (midRead !== null) {
|
||||
assert.ok(markers.includes(midRead.lastValidatedAt));
|
||||
}
|
||||
const final = readInstallState(statePath);
|
||||
assert.ok(markers.includes(final.lastValidatedAt));
|
||||
assert.deepStrictEqual(listStagingFiles(testDir), []);
|
||||
|
||||
Reference in New Issue
Block a user