mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
test(sqlite): right-size reliability crash payloads (#122016)
* test(sqlite): right-size reliability crash payloads * test(agents): replace hanging provider error integration --------- Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
committed by
GitHub
parent
a6ab4b7d54
commit
686294f9f8
@@ -27,7 +27,9 @@ type WorkerExit = IndexRepairProof["exit"];
|
||||
const INDEX_REPAIR_WORKER_PATH = fileURLToPath(
|
||||
new URL("./sqlite-reliability-index-repair-worker.ts", import.meta.url),
|
||||
);
|
||||
const INDEX_REPAIR_ROWS = 32_768;
|
||||
// Keep enough index pages to spill both rollback-journal and WAL transactions
|
||||
// before the worker reports its explicit crash point.
|
||||
const INDEX_REPAIR_ROWS = 16_384;
|
||||
const INDEX_REPAIR_TIMEOUT_MS = 30_000;
|
||||
|
||||
function fileSize(filePath: string): number {
|
||||
|
||||
@@ -57,7 +57,9 @@ type IterationMetric = {
|
||||
|
||||
type CompactionProof = ReliabilityReport["maintenanceProof"]["compaction"];
|
||||
|
||||
const COMPACTION_BLOAT_ROWS = 256;
|
||||
// Exceed the 1 MiB interruption thresholds without copying an arbitrary 64 MiB
|
||||
// through every repository and restore crash phase.
|
||||
const COMPACTION_BLOAT_ROWS = 64;
|
||||
const COMPACTION_BLOAT_PAYLOAD_BYTES = 256 * 1024;
|
||||
|
||||
function nowMs(): number {
|
||||
|
||||
@@ -231,6 +231,23 @@ describe("formatAssistantErrorText", () => {
|
||||
const result = formatAssistantErrorText(msg, { provider: "Anthropic" });
|
||||
expect(result).toBe(formatBillingErrorMessage("Anthropic", "claude-3-5-sonnet"));
|
||||
});
|
||||
it("uses prepared provider ownership for billing classification", () => {
|
||||
const provider = "custom-openrouter";
|
||||
const model = "anthropic/claude-sonnet-4";
|
||||
const result = formatAssistantErrorText(
|
||||
makeAssistantError("HTTP 403: API key budget limit exceeded"),
|
||||
{
|
||||
provider,
|
||||
providerOwner: {
|
||||
id: "openrouter",
|
||||
classifyFailoverReason: ({ provider: owner, errorMessage }) =>
|
||||
owner === "openrouter" && errorMessage.includes("budget limit") ? "billing" : undefined,
|
||||
},
|
||||
model,
|
||||
},
|
||||
);
|
||||
expect(result).toBe(formatBillingErrorMessage(provider, model));
|
||||
});
|
||||
it("returns generic billing message when provider is not given", () => {
|
||||
const msg = makeAssistantError("insufficient credits");
|
||||
const result = formatAssistantErrorText(msg);
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { formatAssistantErrorText } from "../agents/embedded-agent-helpers/error-text.js";
|
||||
import { formatBillingErrorMessage } from "../agents/failover/user-copy.js";
|
||||
import { makeAssistantMessageFixture } from "../agents/test-helpers/assistant-message-fixtures.js";
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import { resolveProviderRuntimePlugin } from "./provider-runtime.js";
|
||||
|
||||
describe("provider-owned terminal error formatting", () => {
|
||||
it("uses resolved OpenRouter ownership for a custom-provider billing error", () => {
|
||||
const provider = "custom-openrouter";
|
||||
const model = "anthropic/claude-sonnet-4";
|
||||
const config = {
|
||||
models: {
|
||||
providers: {
|
||||
[provider]: {
|
||||
api: "openai-completions",
|
||||
baseUrl: "https://openrouter.ai/api/v1",
|
||||
models: [
|
||||
{
|
||||
id: model,
|
||||
name: model,
|
||||
reasoning: false,
|
||||
input: ["text"],
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
contextWindow: 16_000,
|
||||
maxTokens: 1_024,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
} satisfies OpenClawConfig;
|
||||
const owner = resolveProviderRuntimePlugin({
|
||||
provider,
|
||||
providerOwner: "openrouter",
|
||||
modelId: model,
|
||||
config,
|
||||
});
|
||||
expect(owner?.id).toBe("openrouter");
|
||||
|
||||
const billing = makeAssistantMessageFixture({
|
||||
provider,
|
||||
model,
|
||||
errorMessage: "HTTP 403: API key budget limit exceeded",
|
||||
});
|
||||
expect(
|
||||
formatAssistantErrorText(billing, {
|
||||
provider,
|
||||
providerOwner: owner,
|
||||
model,
|
||||
}),
|
||||
).toBe(formatBillingErrorMessage(provider, model));
|
||||
});
|
||||
});
|
||||
@@ -21,9 +21,10 @@ import {
|
||||
import { useAutoCleanupTempDirTracker } from "../helpers/temp-dir.js";
|
||||
|
||||
const tempDirs = useAutoCleanupTempDirTracker(afterEach);
|
||||
// Windows repeats ACL checks and >64 MiB crash/restore copies throughout the full proof.
|
||||
// Windows repeats ACL checks and crash/restore copies throughout the full proof.
|
||||
const RELIABILITY_PROOF_TIMEOUT_MS = process.platform === "win32" ? 480_000 : 240_000;
|
||||
const RELIABILITY_SMOKE_TEST_TIMEOUT_MS = process.platform === "win32" ? 1_200_000 : 300_000;
|
||||
const MIN_MULTICHUNK_RESTORE_BYTES = 2 * 1024 * 1024;
|
||||
|
||||
function reliabilitySmokeTest(name: string, test: () => void): void {
|
||||
it(name, test, RELIABILITY_SMOKE_TEST_TIMEOUT_MS);
|
||||
@@ -234,7 +235,6 @@ describe("scripts/bench-sqlite-reliability", () => {
|
||||
expect(firstReport.indexRepairInterruptionProof.rollbackJournal).toMatchObject({
|
||||
recoveryVerified: true,
|
||||
repairedIndexes: ["idx_openclaw_reliability_records_identity"],
|
||||
rowsPreserved: 32_768,
|
||||
});
|
||||
expect(
|
||||
firstReport.indexRepairInterruptionProof.rollbackJournal.journalBytesObserved,
|
||||
@@ -246,7 +246,6 @@ describe("scripts/bench-sqlite-reliability", () => {
|
||||
expect(firstReport.indexRepairInterruptionProof.wal).toMatchObject({
|
||||
recoveryVerified: true,
|
||||
repairedIndexes: ["idx_openclaw_reliability_records_identity"],
|
||||
rowsPreserved: 32_768,
|
||||
});
|
||||
expect(firstReport.indexRepairInterruptionProof.wal.walBytesObserved).toBeGreaterThan(0);
|
||||
expect(
|
||||
@@ -344,7 +343,7 @@ describe("scripts/bench-sqlite-reliability", () => {
|
||||
firstReport.maintenanceProof.repositoryInterruption.afterCommit.payload,
|
||||
);
|
||||
expect(firstReport.maintenanceProof.restoreInterruption.snapshotBytes).toBeGreaterThan(
|
||||
64 * 1024 * 1024,
|
||||
MIN_MULTICHUNK_RESTORE_BYTES,
|
||||
);
|
||||
expect(firstReport.maintenanceProof.restoreInterruption.beforePublish).toMatchObject({
|
||||
existingTargetPreserved: false,
|
||||
|
||||
Reference in New Issue
Block a user