Skip to content

Commit 59b9f26

Browse files
committed
fix(qa): keep OTEL smoke output repo-relative
1 parent da6e3c6 commit 59b9f26

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

test/e2e/qa-lab/runtime/qa-otel-smoke-runtime.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,15 @@ function buildQaEnv(port: number): NodeJS.ProcessEnv {
15051505
return env;
15061506
}
15071507

1508-
function buildQaArgs(options: CliOptions): string[] {
1508+
function resolveQaOutputDir(outputDir: string, repoRoot = process.cwd()): string {
1509+
const relative = path.relative(repoRoot, path.resolve(repoRoot, outputDir));
1510+
if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
1511+
throw new Error("--output-dir must stay within the repo root");
1512+
}
1513+
return relative ? relative.split(path.sep).join("/") : ".";
1514+
}
1515+
1516+
function buildQaArgs(options: CliOptions, repoRoot = process.cwd()): string[] {
15091517
const args = [
15101518
"qa",
15111519
"suite",
@@ -1516,7 +1524,7 @@ function buildQaArgs(options: CliOptions): string[] {
15161524
"--concurrency",
15171525
"1",
15181526
"--output-dir",
1519-
options.outputDir,
1527+
resolveQaOutputDir(options.outputDir, repoRoot),
15201528
"--fast",
15211529
];
15221530
if (options.primaryModel) {
@@ -2018,6 +2026,7 @@ export const testing = {
20182026
appendGatewayStdoutArtifactLogs,
20192027
appendCapturedBodyText,
20202028
assertSmoke,
2029+
buildQaArgs,
20212030
buildQaEnv,
20222031
createBoundedTextAccumulator,
20232032
createStdoutDiagnosticLogCapture,

test/e2e/qa-lab/runtime/qa-otel-smoke.e2e.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,27 @@ describe("qa-otel-smoke receiver bounds", () => {
200200
);
201201
});
202202

203+
it("passes a repo-relative output dir to the child QA suite", () => {
204+
const repoRoot = path.join(path.sep, "repo");
205+
const options = testing.parseArgs([
206+
"--output-dir",
207+
path.join(repoRoot, ".artifacts", "qa-e2e", "otel-smoke"),
208+
]);
209+
210+
expect(testing.buildQaArgs(options, repoRoot)).toContain(".artifacts/qa-e2e/otel-smoke");
211+
const repoRootArgs = testing.buildQaArgs(
212+
testing.parseArgs(["--output-dir", repoRoot]),
213+
repoRoot,
214+
);
215+
expect(repoRootArgs[repoRootArgs.indexOf("--output-dir") + 1]).toBe(".");
216+
expect(() =>
217+
testing.buildQaArgs(
218+
testing.parseArgs(["--output-dir", path.join(path.sep, "outside", "otel-smoke")]),
219+
repoRoot,
220+
),
221+
).toThrow("--output-dir must stay within the repo root");
222+
});
223+
203224
it("parses body-size limit env values as strict positive integers", () => {
204225
expect(testing.readPositiveIntegerEnv("OTEL_TEST_LIMIT", 64, {})).toBe(64);
205226
expect(

0 commit comments

Comments
 (0)