Skip to content

Commit 698f341

Browse files
mchwangclaude
andcommitted
Storage release after a pass fails the test again; mark the invented fake answer (#189)
Review round 43: in the two tests whose cleanup now warns instead of throwing, a release that fails after the test's own checks passed fails the test, as on main, while a failure above still stays the one reported; the second holder fake case says its answer is invented. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 4ead18d commit 698f341

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

‎test/agent-container.test.ts‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,6 +2562,7 @@ describe('real Docker agent isolation', () => {
25622562
docker('rm', '--force', filesystems.keeper);
25632563
// Tracked for afterAll too: its create may land after the finally (#189).
25642564
containers.add(filesystems.keeper);
2565+
let passed = false;
25652566
try {
25662567
// Inside the try: this keeper carries another runner's label, so only the finally below removes it (#189).
25672568
docker('run', '--detach', '--name', filesystems.keeper, '--label', `io.codeboost.runner=${'f'.repeat(32)}`,
@@ -2570,13 +2571,16 @@ describe('real Docker agent isolation', () => {
25702571
expect(() => removeTaskFilesystems(filesystems)).toThrow('did not settle');
25712572
expect(docker('container', 'inspect', '--format', '{{.State.Running}}', filesystems.keeper)).toBe('true');
25722573
expect(spawnSync('docker', ['volume', 'inspect', filesystems.workVolume]).status).not.toBe(0);
2574+
passed = true;
25732575
} finally {
25742576
spawnSync('docker', ['rm', '--force', filesystems.keeper], { stdio: 'ignore' });
2575-
// Never throws, so a failure above is the one reported: what the removal leaves, the allocation sweep below removes,
2576-
// the keeper with another runner's label included (#189). The sweep may take up to 5.5 minutes, which the test's
2577-
// budget allows for.
2578-
try { removeTaskFilesystems(filesystems); } catch (error) { console.warn('cleanup: removing the storage failed:', error); }
2577+
// A failure above stays the one reported: what the removal leaves, the allocation sweep below removes, the keeper
2578+
// with another runner's label included (#189). After a pass, the storage must release once the foreign keeper is
2579+
// gone, so its failure fails the test. The sweep may take up to 5.5 minutes, which the test's budget allows for.
2580+
let released: unknown;
2581+
try { removeTaskFilesystems(filesystems); } catch (error) { released = error; console.warn('cleanup: removing the storage failed:', error); }
25792582
removeLabelledObjects('io.codeboost.allocation', owner.allocationId, 'test');
2583+
if (passed && released) throw released;
25802584
}
25812585
}, 7 * 60_000);
25822586

@@ -2586,15 +2590,20 @@ describe('real Docker agent isolation', () => {
25862590
// It carries another runner's label, so no sweep of this run finds it: removed here, and whatever still carries its
25872591
// allocation when the test finishes, should its creation or removal not settle or the test time out (#189).
25882592
sweepWhenFinished('io.codeboost.allocation', allocationId);
2593+
let passed = false;
25892594
try {
25902595
foreign = prepareTaskFilesystems(data.clone, { workBytes: 16 * 1024 * 1024, workInodes: 512,
25912596
metadataBytes: 16 * 1024 * 1024, metadataInodes: 512 }, imageId,
25922597
{ runnerOwner: 'f'.repeat(32), attemptId: 'other-runner', allocationId });
25932598
await expect(createContainerProfile({ ...await governed(invocation(data.clone, 'planning')), filesystems: foreign,
25942599
inputDirectory: data.input, codexAuthFile: data.fakeAuth, imageId })).rejects.toThrow('another runner');
2600+
passed = true;
25952601
} finally {
2596-
// Never throws, so a failure above is the one reported; the sweep removes whatever the removal left.
2597-
try { if (foreign) removeTaskFilesystems(foreign); } catch (error) { console.warn('cleanup: removing the storage failed:', error); }
2602+
// A failure above stays the one reported, and the sweep removes whatever the removal left. After a pass, the
2603+
// storage must release by its handle, so its failure fails the test.
2604+
let released: unknown;
2605+
try { if (foreign) removeTaskFilesystems(foreign); } catch (error) { released = error; console.warn('cleanup: removing the storage failed:', error); }
2606+
if (passed && released) throw released;
25982607
}
25992608
}, 60_000);
26002609

‎test/docker-sweep.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ it.each([
147147
const calls = join(root, 'calls'), net = 'n'.repeat(64), a = 'a'.repeat(64), b = 'b'.repeat(64);
148148
// Answers as Docker 27.4 does for one swept network with two candidate holders, one gone before the inspect: the
149149
// inspect prints the other and exits 1. Every other call gets no output and exit 0, as for `ls` with no match; the
150-
// removals' stdout (the removed IDs or names in 27.4) is not read. The network line holds only the fields the sweep
150+
// removals' stdout (the removed IDs or names in 27.4) is not read. The second case's answer is invented: it stands in
151+
// for an unexpected inspect failure that still printed some holders, which 27.4 is not known to give. The network line holds only the fields the sweep
151152
// reads (27.4 also prints CreatedAt, Driver, IPv6, Internal, Labels and Scope), and the inspect an empty endpoint for
152153
// the network, where 27.4 gives its full settings: the sweep reads only the network names.
153154
writeFileSync(join(root, 'docker'), ['#!/bin/sh', `printf '%s\\n' "$*" >> '${calls}'`,

0 commit comments

Comments
 (0)