diff --git a/scripts/qa-otel-smoke.ts b/scripts/qa-otel-smoke.ts index 3bcd7c87ea8..d247ad081b5 100644 --- a/scripts/qa-otel-smoke.ts +++ b/scripts/qa-otel-smoke.ts @@ -10,6 +10,7 @@ import { tmpdir } from "node:os"; import path from "node:path"; import { pathToFileURL } from "node:url"; import { gunzipSync } from "node:zlib"; +import { stripLeadingPackageManagerSeparator } from "./lib/arg-utils.mjs"; type CollectorMode = "local" | "docker"; @@ -169,6 +170,7 @@ Collector container in front of the receiver. } function parseArgs(argv: string[]): CliOptions { + const args = stripLeadingPackageManagerSeparator(argv); const options: CliOptions = { collectorMode: "local", outputDir: path.join(".artifacts", "qa-e2e", `otel-smoke-${Date.now().toString(36)}`), @@ -177,14 +179,14 @@ function parseArgs(argv: string[]): CliOptions { help: false, }; - for (let index = 0; index < argv.length; index += 1) { - const arg = argv[index]; + for (let index = 0; index < args.length; index += 1) { + const arg = args[index]; if (arg === "--help" || arg === "-h") { options.help = true; continue; } const readValue = () => { - const value = argv[index + 1]?.trim(); + const value = args[index + 1]?.trim(); if (!value) { throw new Error(`${arg} requires a value`); } @@ -1334,6 +1336,7 @@ async function main() { export const testing = { appendCapturedBodyText, decodeRequestBody, + parseArgs, readPositiveIntegerEnv, readRequestBody, }; diff --git a/test/scripts/qa-otel-smoke.test.ts b/test/scripts/qa-otel-smoke.test.ts index f9cb90a238b..2bfeba64a1c 100644 --- a/test/scripts/qa-otel-smoke.test.ts +++ b/test/scripts/qa-otel-smoke.test.ts @@ -4,6 +4,24 @@ import { describe, expect, it } from "vitest"; import { testing } from "../../scripts/qa-otel-smoke.ts"; describe("qa-otel-smoke receiver bounds", () => { + it("accepts package-manager forwarded arguments", () => { + expect( + testing.parseArgs([ + "--", + "--collector", + "docker", + "--provider-mode", + "mock-openai", + "--scenario", + "otel-trace-smoke", + ]), + ).toMatchObject({ + collectorMode: "docker", + providerMode: "mock-openai", + scenarioId: "otel-trace-smoke", + }); + }); + it("parses body-size limit env values as strict positive integers", () => { expect(testing.readPositiveIntegerEnv("OTEL_TEST_LIMIT", 64, {})).toBe(64); expect(