mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 15:59:30 +00:00
fix(qa): avoid direct smoke artifact collisions
This commit is contained in:
parent
307300ac97
commit
67b26126ce
4 changed files with 47 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
|||
// Telegram package Docker harness.
|
||||
// Runs QA live transport code against the package candidate installed in Docker.
|
||||
|
||||
import { randomUUID } from "node:crypto";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
|
@ -40,6 +41,17 @@ function resolveCredentialRole(env: NodeJS.ProcessEnv) {
|
|||
return env.OPENCLAW_NPM_TELEGRAM_CREDENTIAL_ROLE ?? env.OPENCLAW_QA_CREDENTIAL_ROLE;
|
||||
}
|
||||
|
||||
function createRunId() {
|
||||
return `${Date.now().toString(36)}-${randomUUID().slice(0, 8)}`;
|
||||
}
|
||||
|
||||
function resolvePackageTelegramOutputDir(env: NodeJS.ProcessEnv, repoRoot: string) {
|
||||
return (
|
||||
env.OPENCLAW_NPM_TELEGRAM_OUTPUT_DIR?.trim() ||
|
||||
path.join(repoRoot, ".artifacts", "qa-e2e", `npm-telegram-live-${createRunId()}`)
|
||||
);
|
||||
}
|
||||
|
||||
const DEFAULT_RTT_CHECK_ID = "telegram-mentioned-message-reply";
|
||||
|
||||
function resolveRttOptions(env: NodeJS.ProcessEnv, selectedScenarioIds: readonly string[] = []) {
|
||||
|
|
@ -107,9 +119,7 @@ async function main() {
|
|||
const sutOpenClawCommand = await resolveTrustedOpenClawCommand(rawSutOpenClawCommand);
|
||||
|
||||
const repoRoot = path.resolve(process.env.OPENCLAW_NPM_TELEGRAM_REPO_ROOT ?? process.cwd());
|
||||
const outputDir =
|
||||
process.env.OPENCLAW_NPM_TELEGRAM_OUTPUT_DIR?.trim() ||
|
||||
path.join(repoRoot, ".artifacts", "qa-e2e", `npm-telegram-live-${Date.now().toString(36)}`);
|
||||
const outputDir = resolvePackageTelegramOutputDir(process.env, repoRoot);
|
||||
const scenarioIds = splitCsv(process.env.OPENCLAW_NPM_TELEGRAM_SCENARIOS);
|
||||
const result = await runTelegramQaLive({
|
||||
env: process.env,
|
||||
|
|
@ -154,6 +164,7 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
|||
|
||||
export const testing = {
|
||||
parsePositiveIntegerEnv,
|
||||
resolvePackageTelegramOutputDir,
|
||||
resolveCredentialRole,
|
||||
resolveCredentialSource,
|
||||
resolveRttOptions,
|
||||
|
|
|
|||
|
|
@ -201,6 +201,10 @@ function readPositiveIntegerEnv(
|
|||
return parsed;
|
||||
}
|
||||
|
||||
function createOtelSmokeRunId(): string {
|
||||
return `${Date.now().toString(36)}-${randomUUID().slice(0, 8)}`;
|
||||
}
|
||||
|
||||
function oversizedBodyError(
|
||||
label: string,
|
||||
actualBytes: number,
|
||||
|
|
@ -229,7 +233,7 @@ function parseArgs(argv: string[]): CliOptions {
|
|||
const options: CliOptions = {
|
||||
collectorMode: "local",
|
||||
logsExporter: "otlp",
|
||||
outputDir: path.join(".artifacts", "qa-e2e", `otel-smoke-${Date.now().toString(36)}`),
|
||||
outputDir: path.join(".artifacts", "qa-e2e", `otel-smoke-${createOtelSmokeRunId()}`),
|
||||
providerMode: "mock-openai",
|
||||
scenarioId: DEFAULT_SCENARIO_ID,
|
||||
help: false,
|
||||
|
|
|
|||
|
|
@ -172,6 +172,18 @@ describe("qa-otel-smoke receiver bounds", () => {
|
|||
).toBe("custom-stdout-smoke");
|
||||
});
|
||||
|
||||
it("uses unique default output dirs", () => {
|
||||
const firstOutputDir = testing.parseArgs([]).outputDir;
|
||||
const secondOutputDir = testing.parseArgs([]).outputDir;
|
||||
|
||||
expect(path.dirname(firstOutputDir)).toBe(path.join(".artifacts", "qa-e2e"));
|
||||
expect(path.basename(firstOutputDir)).toMatch(/^otel-smoke-[a-z0-9]+-[a-f0-9]{8}$/u);
|
||||
expect(secondOutputDir).not.toBe(firstOutputDir);
|
||||
expect(testing.parseArgs(["--output-dir", ".artifacts/custom"]).outputDir).toBe(
|
||||
".artifacts/custom",
|
||||
);
|
||||
});
|
||||
|
||||
it("parses body-size limit env values as strict positive integers", () => {
|
||||
expect(testing.readPositiveIntegerEnv("OTEL_TEST_LIMIT", 64, {})).toBe(64);
|
||||
expect(
|
||||
|
|
|
|||
|
|
@ -148,6 +148,22 @@ describe("package Telegram live Docker E2E", () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("uses unique direct-run output dirs by default", () => {
|
||||
const repoRoot = mkTempRoot();
|
||||
const firstDir = testing.resolvePackageTelegramOutputDir({}, repoRoot);
|
||||
const secondDir = testing.resolvePackageTelegramOutputDir({}, repoRoot);
|
||||
|
||||
expect(path.dirname(firstDir)).toBe(path.join(repoRoot, ".artifacts", "qa-e2e"));
|
||||
expect(path.basename(firstDir)).toMatch(/^npm-telegram-live-[a-z0-9]+-[a-f0-9]{8}$/u);
|
||||
expect(secondDir).not.toBe(firstDir);
|
||||
expect(
|
||||
testing.resolvePackageTelegramOutputDir(
|
||||
{ OPENCLAW_NPM_TELEGRAM_OUTPUT_DIR: ".artifacts/custom" },
|
||||
repoRoot,
|
||||
),
|
||||
).toBe(".artifacts/custom");
|
||||
});
|
||||
|
||||
it("mounts configured output paths before entering the container", () => {
|
||||
const script = readFileSync(DOCKER_SCRIPT_PATH, "utf8");
|
||||
const dockerEnvStart = script.indexOf("docker_env=(");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue