Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Stabilize telemetry candidate validation

pulse-triage[bot]61a58758b20d
diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml
index 0004507d86..542e893ee8 100644
--- a/.github/workflows/test-e2e.yml
+++ b/.github/workflows/test-e2e.yml
@@ -50,6 +50,12 @@ jobs:
cache: 'npm'
cache-dependency-path: tests/integration/package-lock.json
+ - name: Validate telemetry schema version parity
+ working-directory: tests/integration
+ run: |
+ npm run check:telemetry-schema-version
+ node --test scripts/check-telemetry-schema-version.test.mjs
+
- name: Install integration dependencies
working-directory: tests/integration
run: npm ci
diff --git a/tests/integration/package.json b/tests/integration/package.json
index 8273a8c0c7..3dfd5810fe 100644
--- a/tests/integration/package.json
+++ b/tests/integration/package.json
@@ -7,6 +7,7 @@
"test": "node ./scripts/run-playwright.mjs",
"test:alerts:qualification": "node ./scripts/run-alert-qualification.mjs",
"check:e2e-tiers": "node ./scripts/check-e2e-tiering.mjs",
+ "check:telemetry-schema-version": "node ./scripts/check-telemetry-schema-version.mjs",
"evals": "node ./scripts/run-evals.mjs",
"test:visual": "npm test -- tests/06-theme-visual.spec.ts --project=chromium",
"test:visual:update": "npm test -- tests/06-theme-visual.spec.ts --project=chromium --update-snapshots",
diff --git a/tests/integration/scripts/check-telemetry-schema-version.mjs b/tests/integration/scripts/check-telemetry-schema-version.mjs
new file mode 100644
index 0000000000..c49a41b2e8
--- /dev/null
+++ b/tests/integration/scripts/check-telemetry-schema-version.mjs
@@ -0,0 +1,95 @@
+#!/usr/bin/env node
+
+import fs from "node:fs";
+import path from "node:path";
+import process from "node:process";
+import { fileURLToPath, pathToFileURL } from "node:url";
+
+const GO_SCHEMA_PATTERN = /\bTelemetrySchemaVersion\s*=\s*(\d+)\b/;
+const E2E_SCHEMA_PATTERN =
+ /\bEXPECTED_TELEMETRY_SCHEMA_VERSION\s*=\s*(\d+)\b/;
+
+export function readVersion(source, pattern, label) {
+ const matches = [...source.matchAll(new RegExp(pattern.source, "g"))];
+ if (matches.length !== 1) {
+ throw new Error(
+ `${label} must declare exactly one schema version; found ${matches.length}`,
+ );
+ }
+ return Number.parseInt(matches[0][1], 10);
+}
+
+export function telemetrySchemaVersionErrors(goSource, e2eSource) {
+ const publicVersion = readVersion(
+ goSource,
+ GO_SCHEMA_PATTERN,
+ "internal/telemetry/telemetry.go",
+ );
+ const e2eVersion = readVersion(
+ e2eSource,
+ E2E_SCHEMA_PATTERN,
+ "tests/integration/tests/19-telemetry-disclosure.spec.ts",
+ );
+ if (publicVersion === e2eVersion) return [];
+ return [
+ `telemetry schema version drift: public payload is ${publicVersion}, ` +
+ `stable E2E expects ${e2eVersion}`,
+ ];
+}
+
+export function githubErrorAnnotation(message) {
+ const escaped = message
+ .replaceAll("%", "%25")
+ .replaceAll("\r", "%0D")
+ .replaceAll("\n", "%0A");
+ return (
+ "::error file=tests/integration/tests/19-telemetry-disclosure.spec.ts," +
+ `title=Telemetry schema version parity::${escaped}`
+ );
+}
+
+export function main() {
+ const integrationRoot = path.resolve(
+ fileURLToPath(new URL("..", import.meta.url)),
+ );
+ const repoRoot = path.resolve(integrationRoot, "../..");
+ const goPath = path.join(
+ repoRoot,
+ "internal",
+ "telemetry",
+ "telemetry.go",
+ );
+ const e2ePath = path.join(
+ integrationRoot,
+ "tests",
+ "19-telemetry-disclosure.spec.ts",
+ );
+
+ let errors;
+ try {
+ errors = telemetrySchemaVersionErrors(
+ fs.readFileSync(goPath, "utf8"),
+ fs.readFileSync(e2ePath, "utf8"),
+ );
+ } catch (error) {
+ errors = [error instanceof Error ? error.message : String(error)];
+ }
+ if (errors.length) {
+ console.error("Telemetry schema version validation failed:");
+ for (const error of errors) {
+ console.error(`- ${error}`);
+ console.error(githubErrorAnnotation(error));
+ }
+ return 1;
+ }
+
+ console.log("Telemetry schema version validation passed");
+ return 0;
+}
+
+if (
+ process.argv[1] &&
+ pathToFileURL(path.resolve(process.argv[1])).href === import.meta.url
+) {
+ process.exitCode = main();
+}
diff --git a/tests/integration/scripts/check-telemetry-schema-version.test.mjs b/tests/integration/scripts/check-telemetry-schema-version.test.mjs
new file mode 100644
index 0000000000..9929fc5180
--- /dev/null
+++ b/tests/integration/scripts/check-telemetry-schema-version.test.mjs
@@ -0,0 +1,47 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import {
+ githubErrorAnnotation,
+ readVersion,
+ telemetrySchemaVersionErrors,
+} from "./check-telemetry-schema-version.mjs";
+
+test("accepts a stable E2E expectation matching the public payload", () => {
+ assert.deepEqual(
+ telemetrySchemaVersionErrors(
+ "const ( TelemetrySchemaVersion = 15 )",
+ "const EXPECTED_TELEMETRY_SCHEMA_VERSION = 15;",
+ ),
+ [],
+ );
+});
+
+test("reports both versions when the stable E2E expectation drifts", () => {
+ assert.deepEqual(
+ telemetrySchemaVersionErrors(
+ "TelemetrySchemaVersion = 16",
+ "const EXPECTED_TELEMETRY_SCHEMA_VERSION = 15;",
+ ),
+ ["telemetry schema version drift: public payload is 16, stable E2E expects 15"],
+ );
+});
+
+test("rejects missing or ambiguous version declarations", () => {
+ assert.throws(
+ () => readVersion("", /VERSION=(\d+)/, "fixture"),
+ /fixture must declare exactly one schema version; found 0/,
+ );
+ assert.throws(
+ () => readVersion("VERSION=1 VERSION=2", /VERSION=(\d+)/, "fixture"),
+ /fixture must declare exactly one schema version; found 2/,
+ );
+});
+
+test("emits a source-linked GitHub annotation with escaped data", () => {
+ assert.equal(
+ githubErrorAnnotation("public is 16\nE2E is 15%"),
+ "::error file=tests/integration/tests/19-telemetry-disclosure.spec.ts," +
+ "title=Telemetry schema version parity::public is 16%0AE2E is 15%25",
+ );
+});
diff --git a/tests/integration/tests/19-telemetry-disclosure.spec.ts b/tests/integration/tests/19-telemetry-disclosure.spec.ts
index 165bb8156b..7430762e36 100644
--- a/tests/integration/tests/19-telemetry-disclosure.spec.ts
+++ b/tests/integration/tests/19-telemetry-disclosure.spec.ts
@@ -10,6 +10,7 @@ import {
import { createAuthenticatedStorageState } from "./helpers";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const EXPECTED_TELEMETRY_SCHEMA_VERSION = 15;
type WorkerFixtures = {
authStorageStatePath: string;
@@ -126,7 +127,9 @@ test.describe("Telemetry disclosure", () => {
const initialPreview = await readTelemetryPreview(page);
expect(initialPreview.event).toBe("heartbeat");
expect(initialPreview.install_id).toBeTruthy();
- expect(initialPreview.schema_version).toBe(14);
+ expect(initialPreview.schema_version).toBe(
+ EXPECTED_TELEMETRY_SCHEMA_VERSION,
+ );
expect(initialPreview.active_alerts_warning).toBeGreaterThanOrEqual(0);
expect(
initialPreview.alerts_resolution_under_15m_30d,