mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-21 02:54:25 +00:00
fix(ci): normalize coverage in the remaining log export fixtures
This commit is contained in:
@@ -37,7 +37,7 @@ export function resolveLogExportChild(context: ResolutionContext = {}) {
|
||||
return { childFile: entryJs ?? cwdJs, execArgv: [] as string[] };
|
||||
}
|
||||
interface TestOptions {
|
||||
modulePath: string;
|
||||
modulePath?: string;
|
||||
coveragePreload?: string;
|
||||
beforeAck?: () => Promise<void>;
|
||||
onSpawn?: (child: ChildProcess) => void;
|
||||
|
||||
@@ -8,6 +8,7 @@ import { createHmac } from "node:crypto";
|
||||
import { once } from "node:events";
|
||||
import { getLogExportDestinationType } from "../../src/lib/logExport/registry.ts";
|
||||
import type { LogExportRecord } from "../../src/lib/logExport/types.ts";
|
||||
import { nativeCoverageArgs } from "../_helpers/nativeCoverageArgs.ts";
|
||||
import { createManagementSessionToken } from "../helpers/managementSession.ts";
|
||||
|
||||
const packageVersion: string = JSON.parse(
|
||||
@@ -34,6 +35,7 @@ const source = await import("../../src/lib/usage/callLogExportSource.ts");
|
||||
const route = await import("../../src/app/api/log-export/destinations/route.ts");
|
||||
const oneRoute = await import("../../src/app/api/log-export/destinations/[id]/route.ts");
|
||||
const otlp = await import("../../src/lib/logExport/destinations/otlpHttp.ts");
|
||||
const [, coveragePreload] = nativeCoverageArgs();
|
||||
|
||||
type Payload = ReturnType<typeof otlp.buildOtlpPayload>;
|
||||
type Span = Payload["resourceSpans"][number]["scopeSpans"][number]["spans"][number];
|
||||
@@ -102,6 +104,15 @@ function attributes(span: Span) {
|
||||
const str = (stringValue: string) => ({ stringValue });
|
||||
const int = (value: number) => ({ intValue: String(value) });
|
||||
|
||||
if (coveragePreload) {
|
||||
test.beforeEach(() => {
|
||||
runner.__setLogExportChildOptionsForTest({ coveragePreload });
|
||||
});
|
||||
test.afterEach(() => {
|
||||
runner.__setLogExportChildOptionsForTest(null);
|
||||
});
|
||||
}
|
||||
|
||||
test.after(() => {
|
||||
core.resetDbInstance();
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
@@ -728,6 +739,7 @@ test("child runner end-to-end: cursor advances filtered rows, ttft mapped, secre
|
||||
const originalError = console.error;
|
||||
console.error = (...args: unknown[]) => output.push(args.join(" "));
|
||||
runner.__setLogExportChildOptionsForTest({
|
||||
coveragePreload,
|
||||
onSpawn: (child) => {
|
||||
assert.equal(JSON.stringify(child.spawnargs).includes(secret), false);
|
||||
child.stdout?.on("data", (c: Buffer) => output.push(c.toString()));
|
||||
@@ -845,6 +857,7 @@ test("real runner marks failure, retains pending rows and resends identical span
|
||||
let spawned = 0;
|
||||
runner.__setLogExportChildOptionsForTest({
|
||||
modulePath: "",
|
||||
coveragePreload,
|
||||
onSpawn(child) {
|
||||
spawned++;
|
||||
child.stdout?.on("data", (c: Buffer) => output.push(c.toString()));
|
||||
|
||||
@@ -4,6 +4,7 @@ import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { generateKeyPairSync } from "node:crypto";
|
||||
import { nativeCoverageArgs } from "../_helpers/nativeCoverageArgs.ts";
|
||||
|
||||
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omni-log-export-"));
|
||||
process.env.DATA_DIR = TEST_DATA_DIR;
|
||||
@@ -48,8 +49,10 @@ function installFetchStub(
|
||||
) {
|
||||
const output = path.join(TEST_DATA_DIR, "bigquery-batches.jsonl");
|
||||
fs.rmSync(output, { force: true });
|
||||
const [, coveragePreload] = nativeCoverageArgs();
|
||||
runner.__setLogExportChildOptionsForTest({
|
||||
modulePath: path.join(import.meta.dirname, "fixtures/logExportTestDestination.ts"),
|
||||
coveragePreload,
|
||||
config: {
|
||||
fixtureFailInsert: options.failInsert,
|
||||
fixtureInsertDelayMs: options.insertDelayMs,
|
||||
|
||||
Reference in New Issue
Block a user