Add dispose method to PerfAppHarness for lightweight error-path cleanup

PerfAppHarness only exposed finishRun which bundles teardown with artifact
writing. If finishRun threw after teardown, the original test error was masked.
Tests were also forced to repeat full artifact parameters in finally blocks.

Add a standalone dispose() method (matching ServerPerfHarness API) that tears
down browser/server/temp files without writing artifacts. Simplify test finally
blocks to use dispose() instead of redundant finishRun calls.
This commit is contained in:
Cursor Agent committed 2026-04-13 17:20:02 +00:00
1 parent e9fa2b75dc
commit 03c098d248
3 files changed
+7 -31

No files matched your search

+5
View File
@@ -102,6 +102,7 @@ export interface PerfAppHarness {
readonly browserMetrics: BrowserPerfMetrics;
readonly serverMetrics: ReadonlyArray<PerfServerMetricSample> | null;
}>;
readonly dispose: () => Promise<void>;
}
async function pickFreePort(): Promise<number> {
@@ -467,6 +468,10 @@ export async function startPerfAppHarness(
return await finishPromise;
},
dispose: async () => {
await sampler.stop().catch(() => undefined);
await teardown();
},
};
} catch (error) {
await Promise.allSettled([
+1 -13
View File
@@ -163,19 +163,7 @@ test("virtualization stays bounded and heavy thread switches remain snappy", asy
finished = true;
} finally {
if (harness && !finished) {
await harness.finishRun({
suite: "virtualization",
scenarioId: "large_threads",
thresholds,
metadata: {
heavyThreadMessageCount: harness.seededState.threadSummaries.find(
(thread) => thread.id === PERF_CATALOG_IDS.largeThreads.heavyAThreadId,
)?.messageCount,
},
actionSummary: {
threadSwitchActionPrefix: "thread-switch",
},
});
await harness.dispose();
}
}
});
@@ -117,24 +117,7 @@ test("high-frequency websocket events stay responsive under real built-app flow"
finished = true;
} finally {
if (harness && !finished) {
await harness.finishRun({
suite: "websocket-application",
scenarioId: "dense_assistant_stream",
thresholds,
metadata: {
burstSeedThreadId: PERF_CATALOG_IDS.burstBase.burstThreadId,
navigationThreadId: PERF_CATALOG_IDS.burstBase.navigationThreadId,
fillerThreadId: PERF_CATALOG_IDS.burstBase.fillerThreadId,
navigationLiveAssistantMessageId:
PERF_CATALOG_IDS.provider.navigationLiveAssistantMessageId,
burstLiveAssistantMessageId: PERF_CATALOG_IDS.provider.burstLiveAssistantMessageId,
sentinelText: PERF_PROVIDER_SCENARIOS.dense_assistant_stream.sentinelText,
},
actionSummary: {
threadSwitchActionPrefix: "thread-switch",
burstActionName: "burst-completion",
},
});
await harness.dispose();
}
}
});