test: allow old Linux package update baselines

This commit is contained in:
Peter Steinberger
2026-05-11 07:20:41 +01:00
parent b58ee9eee2
commit ea663dbb56
2 changed files with 74 additions and 5 deletions

View File

@@ -39,6 +39,32 @@ import { runSmokeLane, type SmokeLane, type SmokeLaneStatus } from "./lane-runne
import { resolveUbuntuVmName, waitForVmStatus } from "./parallels-vm.ts";
import { PhaseRunner } from "./phase-runner.ts";
// Older published baselines predate this warning, but still need update coverage.
const BAD_PLUGIN_DIAGNOSTIC_MIN_VERSION = "2026.5.7";
function parseOpenClawPackageVersion(value: string): string | null {
return value.match(/\b(\d{4}\.\d{1,2}\.\d{1,2}(?:-[A-Za-z0-9.]+)?)\b/u)?.[1] ?? null;
}
function compareOpenClawPackageVersions(left: string, right: string): number {
const parse = (value: string): [number, number, number] => {
const match = parseOpenClawPackageVersion(value)?.match(/^(\d{4})\.(\d+)\.(\d+)/u);
if (!match) {
return [0, 0, 0];
}
return [Number(match[1]), Number(match[2]), Number(match[3])];
};
const leftParts = parse(left);
const rightParts = parse(right);
for (let index = 0; index < leftParts.length; index++) {
const delta = leftParts[index] - rightParts[index];
if (delta !== 0) {
return delta;
}
}
return 0;
}
interface LinuxOptions {
vmName: string;
vmNameExplicit: boolean;
@@ -337,10 +363,12 @@ class LinuxSmoke {
this.status.freshVersion = await this.extractLastVersion("fresh.install-main");
await this.phase("fresh.verify-main-version", 90, () => this.verifyTargetVersion());
await this.phase("fresh.onboard-ref", 180, () => this.runRefOnboard());
await this.phase("fresh.inject-bad-plugin", 90, () => this.injectBadPluginFixture());
await this.phase("fresh.inject-bad-plugin", 90, () =>
this.maybeInjectBadPluginFixture("fresh"),
);
await this.phase("fresh.gateway-start", 240, () => this.startGatewayBackground());
await this.phase("fresh.bad-plugin-diagnostic", 90, () =>
this.verifyBadPluginDiagnostic("fresh"),
this.maybeVerifyBadPluginDiagnostic("fresh"),
);
await this.phase("fresh.gateway-status", 240, () => this.verifyGatewayStatus());
this.status.freshGateway = "pass";
@@ -366,11 +394,13 @@ class LinuxSmoke {
);
this.status.upgradeVersion = await this.extractLastVersion("upgrade.install-main");
await this.phase("upgrade.verify-main-version", 90, () => this.verifyTargetVersion());
await this.phase("upgrade.inject-bad-plugin", 90, () => this.injectBadPluginFixture());
await this.phase("upgrade.inject-bad-plugin", 90, () =>
this.maybeInjectBadPluginFixture("upgrade"),
);
await this.phase("upgrade.onboard-ref", 180, () => this.runRefOnboard());
await this.phase("upgrade.gateway-start", 240, () => this.startGatewayBackground());
await this.phase("upgrade.bad-plugin-diagnostic", 90, () =>
this.verifyBadPluginDiagnostic("upgrade"),
this.maybeVerifyBadPluginDiagnostic("upgrade"),
);
await this.phase("upgrade.gateway-status", 240, () => this.verifyGatewayStatus());
this.status.upgradeGateway = "pass";
@@ -592,6 +622,28 @@ config_path.write_text(json.dumps(config, indent=2) + "\n")
PY`);
}
private versionForLane(lane: "fresh" | "upgrade"): string {
return lane === "fresh" ? this.status.freshVersion : this.status.upgradeVersion;
}
private shouldExpectBadPluginDiagnostic(lane: "fresh" | "upgrade"): boolean {
const version = parseOpenClawPackageVersion(this.versionForLane(lane));
if (!version) {
return true;
}
return compareOpenClawPackageVersions(version, BAD_PLUGIN_DIAGNOSTIC_MIN_VERSION) >= 0;
}
private maybeInjectBadPluginFixture(lane: "fresh" | "upgrade"): void {
if (!this.shouldExpectBadPluginDiagnostic(lane)) {
this.log(
`Skipping bad plugin diagnostic fixture for ${lane}: installed ${this.versionForLane(lane)} predates ${BAD_PLUGIN_DIAGNOSTIC_MIN_VERSION}\n`,
);
return;
}
this.injectBadPluginFixture();
}
private startGatewayBackground(): void {
const bonjourEnv = this.disableBonjour ? " OPENCLAW_DISABLE_BONJOUR=1" : "";
this.guestBash(
@@ -670,7 +722,13 @@ setsid sh -lc ` +
throw new Error("gateway status did not become RPC-ready");
}
private async verifyBadPluginDiagnostic(lane: "fresh" | "upgrade"): Promise<void> {
private async maybeVerifyBadPluginDiagnostic(lane: "fresh" | "upgrade"): Promise<void> {
if (!this.shouldExpectBadPluginDiagnostic(lane)) {
this.log(
`Skipping bad plugin diagnostic assertion for ${lane}: installed ${this.versionForLane(lane)} predates ${BAD_PLUGIN_DIAGNOSTIC_MIN_VERSION}\n`,
);
return;
}
const warning =
"channel plugin manifest declares test-bad-plugin without channelConfigs metadata";
const gatewayStartLog = await readFile(

View File

@@ -245,6 +245,17 @@ console.log(resolveUbuntuVmName("Ubuntu missing"));
expect(script).toContain("DPkg::Lock::Timeout=300");
});
it("keeps Linux bad-plugin diagnostics gated for historical update baselines", () => {
const script = readFileSync(TS_PATHS.linux, "utf8");
expect(script).toContain('BAD_PLUGIN_DIAGNOSTIC_MIN_VERSION = "2026.5.7"');
expect(script).toContain("parseOpenClawPackageVersion");
expect(script).toContain("maybeInjectBadPluginFixture");
expect(script).toContain("maybeVerifyBadPluginDiagnostic");
expect(script).toContain("Skipping bad plugin diagnostic fixture");
expect(script).toContain("Skipping bad plugin diagnostic assertion");
});
it("resolves provider defaults and explicit model overrides", () => {
expect(resolveProviderAuth("openai", { env: { OPENAI_API_KEY: "sk-openai" } })).toEqual({
apiKeyEnv: "OPENAI_API_KEY",