feat(provider-contract): add Gelios v9 telemetry projection
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { createHash } from "node:crypto";
|
||||
import {
|
||||
L2_EXECUTION_PLAN_COMPILER_VERSION,
|
||||
L2_EXECUTION_PLAN_SUPPORTED_COMPILER_VERSIONS,
|
||||
L2_EXECUTION_PLAN_SCHEMA_VERSION,
|
||||
L2_GRAPH_BLUEPRINT_SCHEMA_VERSION,
|
||||
L2_MAPPING_RUNTIME_SCHEMA_VERSION,
|
||||
@@ -12,23 +14,26 @@ import {
|
||||
validateL2ExecutionPlan,
|
||||
} from "../src/index.mjs";
|
||||
import {
|
||||
geliosProviderPackageV8,
|
||||
geliosTelemetryFieldRegistryV1,
|
||||
} from "../providers/gelios/v8/index.mjs";
|
||||
geliosProviderPackageV9,
|
||||
geliosTelemetryFieldRegistryV2,
|
||||
} from "../providers/gelios/v9/index.mjs";
|
||||
|
||||
const positionsConnection = instantiateL2Connection(geliosProviderPackageV8, {
|
||||
const positionsConnection = instantiateL2Connection(geliosProviderPackageV9, {
|
||||
tenantId: "tenant-compiler-fixture",
|
||||
connectionId: "gelios-compiler-fixture",
|
||||
collectionProfileId: "gelios.positions.current.realtime.v7",
|
||||
providerCredentialRef: "ndc-credref:provider-compiler-fixture-0001",
|
||||
});
|
||||
const positionsPlan = compileL2ExecutionPlan(
|
||||
geliosProviderPackageV8,
|
||||
geliosProviderPackageV9,
|
||||
positionsConnection,
|
||||
{ telemetryFieldRegistry: geliosTelemetryFieldRegistryV1 },
|
||||
{ telemetryFieldRegistry: geliosTelemetryFieldRegistryV2 },
|
||||
);
|
||||
|
||||
assert.equal(positionsPlan.schemaVersion, L2_EXECUTION_PLAN_SCHEMA_VERSION);
|
||||
assert.equal(L2_EXECUTION_PLAN_COMPILER_VERSION, "1.2.0");
|
||||
assert.deepEqual(L2_EXECUTION_PLAN_SUPPORTED_COMPILER_VERSIONS, ["1.1.0", "1.2.0"]);
|
||||
assert.equal(positionsPlan.compilerVersion, "1.2.0");
|
||||
assert.deepEqual(validateL2ExecutionPlan(positionsPlan), { ok: true, errors: [] });
|
||||
assert.match(positionsPlan.executionPlanDigest, /^sha256:[a-f0-9]{64}$/);
|
||||
assert.match(positionsPlan.artifacts.packageDigest, /^sha256:[a-f0-9]{64}$/);
|
||||
@@ -106,48 +111,74 @@ assert.deepEqual(unitsRequest.config.request.query, {
|
||||
const semanticMapping = positionsPlan.steps.find((step) => step.kind === "semantic_mapping");
|
||||
assert.deepEqual(
|
||||
semanticMapping.config.telemetryProjection.entries.map((entry) => entry.reading.id),
|
||||
["sensor.param.in0", "sensor.param.in1"],
|
||||
[
|
||||
"sensor.param.in_0",
|
||||
"sensor.param.in_1",
|
||||
"sensor.param.in0",
|
||||
"sensor.param.in1",
|
||||
],
|
||||
);
|
||||
assert.equal(Object.isFrozen(positionsPlan), true);
|
||||
assert.equal(Object.isFrozen(positionsPlan.steps), true);
|
||||
assert.equal(Object.isFrozen(positionsPlan.graphBlueprint), true);
|
||||
|
||||
const clonedPlan = compileL2ExecutionPlan(
|
||||
structuredClone(geliosProviderPackageV8),
|
||||
structuredClone(geliosProviderPackageV9),
|
||||
structuredClone(positionsConnection),
|
||||
{ telemetryFieldRegistry: structuredClone(geliosTelemetryFieldRegistryV1) },
|
||||
{ telemetryFieldRegistry: structuredClone(geliosTelemetryFieldRegistryV2) },
|
||||
);
|
||||
assert.equal(clonedPlan.executionPlanDigest, positionsPlan.executionPlanDigest);
|
||||
|
||||
const legacyCompilerPlan = structuredClone(positionsPlan);
|
||||
legacyCompilerPlan.compilerVersion = "1.1.0";
|
||||
legacyCompilerPlan.executionPlanDigest = digestWithout(
|
||||
legacyCompilerPlan,
|
||||
"executionPlanDigest",
|
||||
);
|
||||
assert.deepEqual(validateL2ExecutionPlan(legacyCompilerPlan), { ok: true, errors: [] });
|
||||
|
||||
const unsupportedCompilerPlan = structuredClone(positionsPlan);
|
||||
unsupportedCompilerPlan.compilerVersion = "2.0.0";
|
||||
unsupportedCompilerPlan.executionPlanDigest = digestWithout(
|
||||
unsupportedCompilerPlan,
|
||||
"executionPlanDigest",
|
||||
);
|
||||
assert.equal(
|
||||
validateL2ExecutionPlan(unsupportedCompilerPlan).errors.includes(
|
||||
"executionPlan.compilerVersion_mismatch",
|
||||
),
|
||||
true,
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
() => compileL2ExecutionPlan(geliosProviderPackageV8, positionsConnection),
|
||||
() => compileL2ExecutionPlan(geliosProviderPackageV9, positionsConnection),
|
||||
/telemetry_registry_required/,
|
||||
);
|
||||
|
||||
const profileConnection = instantiateL2Connection(geliosProviderPackageV8, {
|
||||
const profileConnection = instantiateL2Connection(geliosProviderPackageV9, {
|
||||
tenantId: "tenant-compiler-fixture",
|
||||
connectionId: "gelios-profile-compiler-fixture",
|
||||
collectionProfileId: "gelios.units.profile.cold.v1",
|
||||
providerCredentialRef: "ndc-credref:provider-compiler-fixture-0001",
|
||||
});
|
||||
const profilePlan = compileL2ExecutionPlan(geliosProviderPackageV8, profileConnection);
|
||||
const profilePlan = compileL2ExecutionPlan(geliosProviderPackageV9, profileConnection);
|
||||
assert.deepEqual(validateL2ExecutionPlan(profilePlan), { ok: true, errors: [] });
|
||||
assert.equal(profilePlan.artifacts.telemetryRegistryDigest, undefined);
|
||||
assert.notEqual(profilePlan.executionPlanDigest, positionsPlan.executionPlanDigest);
|
||||
assert.deepEqual(profilePlan.graphBlueprint.runtime.mappingRuntime.derivationKinds, []);
|
||||
|
||||
for (const collectionProfile of geliosProviderPackageV8.collectionProfiles) {
|
||||
const connection = instantiateL2Connection(geliosProviderPackageV8, {
|
||||
for (const collectionProfile of geliosProviderPackageV9.collectionProfiles) {
|
||||
const connection = instantiateL2Connection(geliosProviderPackageV9, {
|
||||
tenantId: "tenant-all-profiles-fixture",
|
||||
connectionId: `connection-${collectionProfile.id.replaceAll(".", "-")}`,
|
||||
collectionProfileId: collectionProfile.id,
|
||||
providerCredentialRef: "ndc-credref:provider-all-profiles-fixture",
|
||||
});
|
||||
const plan = compileL2ExecutionPlan(
|
||||
geliosProviderPackageV8,
|
||||
geliosProviderPackageV9,
|
||||
connection,
|
||||
collectionProfile.dataProductId === "fleet.positions.current.v5"
|
||||
? { telemetryFieldRegistry: geliosTelemetryFieldRegistryV1 }
|
||||
? { telemetryFieldRegistry: geliosTelemetryFieldRegistryV2 }
|
||||
: {},
|
||||
);
|
||||
assert.deepEqual(validateL2ExecutionPlan(plan), { ok: true, errors: [] });
|
||||
@@ -157,16 +188,16 @@ for (const collectionProfile of geliosProviderPackageV8.collectionProfiles) {
|
||||
assert.equal(plan.graphBlueprint.edges.length, plan.steps.length + expectedEntrypoints - 2);
|
||||
}
|
||||
|
||||
const secondConnection = instantiateL2Connection(geliosProviderPackageV8, {
|
||||
const secondConnection = instantiateL2Connection(geliosProviderPackageV9, {
|
||||
tenantId: "tenant-compiler-fixture",
|
||||
connectionId: "gelios-compiler-fixture-two",
|
||||
collectionProfileId: "gelios.positions.current.realtime.v7",
|
||||
providerCredentialRef: "ndc-credref:provider-compiler-fixture-0002",
|
||||
});
|
||||
const secondPlan = compileL2ExecutionPlan(
|
||||
geliosProviderPackageV8,
|
||||
geliosProviderPackageV9,
|
||||
secondConnection,
|
||||
{ telemetryFieldRegistry: geliosTelemetryFieldRegistryV1 },
|
||||
{ telemetryFieldRegistry: geliosTelemetryFieldRegistryV2 },
|
||||
);
|
||||
assert.notEqual(secondPlan.executionPlanDigest, positionsPlan.executionPlanDigest);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import { geliosProviderPackageV5 } from "../providers/gelios/v5/index.mjs";
|
||||
import { geliosProviderPackageV6 } from "../providers/gelios/v6/index.mjs";
|
||||
import { geliosProviderPackageV7 } from "../providers/gelios/v7/index.mjs";
|
||||
import { geliosProviderPackageV8 } from "../providers/gelios/v8/index.mjs";
|
||||
import { geliosProviderPackageV9 } from "../providers/gelios/v9/index.mjs";
|
||||
import { normalizeDataProductDefinition } from "../../../services/external-data-plane/src/data-product-policy.mjs";
|
||||
|
||||
const expectedFields = [
|
||||
@@ -47,6 +48,10 @@ assert.deepEqual(validateProviderPackage(geliosProviderPackageV5), { ok: true, e
|
||||
assert.deepEqual(validateProviderPackage(geliosProviderPackageV6), { ok: true, errors: [] });
|
||||
assert.deepEqual(validateProviderPackage(geliosProviderPackageV7), { ok: true, errors: [] });
|
||||
assert.deepEqual(validateProviderPackage(geliosProviderPackageV8), { ok: true, errors: [] });
|
||||
assert.deepEqual(validateProviderPackage(geliosProviderPackageV9), { ok: true, errors: [] });
|
||||
assert.equal(geliosProviderPackageV9.id, "gelios.provider.v9");
|
||||
assert.equal(geliosProviderPackageV9.version, "9.0.0");
|
||||
assert.equal(geliosProviderPackageV8.id, "gelios.provider.v8");
|
||||
|
||||
const profileProduct = geliosProviderPackageV8.dataProducts.find((product) => product.id === "fleet.units.profile.current.v1");
|
||||
const registeredProfileProduct = JSON.parse(await readFile(new URL(
|
||||
|
||||
@@ -8,6 +8,9 @@ import {
|
||||
import {
|
||||
geliosTelemetryFieldRegistryV1,
|
||||
} from "../providers/gelios/v8/index.mjs";
|
||||
import {
|
||||
geliosTelemetryFieldRegistryV2,
|
||||
} from "../providers/gelios/v9/index.mjs";
|
||||
|
||||
assert.deepEqual(validateTelemetryFieldRegistry(geliosTelemetryFieldRegistryV1), {
|
||||
ok: true,
|
||||
@@ -31,6 +34,37 @@ assert.equal(projection.entries.some((entry) => entry.sourceKey === "in_0"), fal
|
||||
assert.equal(Object.isFrozen(projection), true);
|
||||
assert.equal(Object.isFrozen(projection.entries), true);
|
||||
|
||||
assert.deepEqual(validateTelemetryFieldRegistry(geliosTelemetryFieldRegistryV2), {
|
||||
ok: true,
|
||||
errors: [],
|
||||
});
|
||||
const expandedProjection = compileTelemetryFieldProjection(
|
||||
geliosTelemetryFieldRegistryV2,
|
||||
{
|
||||
providerPackageId: "gelios.provider.v9",
|
||||
providerPackageVersion: "9.0.0",
|
||||
dataProductId: "fleet.positions.current.v5",
|
||||
surface: "data_product",
|
||||
},
|
||||
);
|
||||
assert.deepEqual(
|
||||
expandedProjection.entries.map((entry) => entry.sourceKey),
|
||||
["in_0", "in_1", "in0", "in1"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
expandedProjection.entries.map((entry) => entry.reading.id),
|
||||
[
|
||||
"sensor.param.in_0",
|
||||
"sensor.param.in_1",
|
||||
"sensor.param.in0",
|
||||
"sensor.param.in1",
|
||||
],
|
||||
);
|
||||
assert.notEqual(
|
||||
digestTelemetryFieldRegistry(geliosTelemetryFieldRegistryV2),
|
||||
digestTelemetryFieldRegistry(geliosTelemetryFieldRegistryV1),
|
||||
);
|
||||
|
||||
const observedExposed = structuredClone(geliosTelemetryFieldRegistryV1);
|
||||
observedExposed.entries.find((entry) => entry.sourceKey === "in_0").allowedSurfaces.push("foundry");
|
||||
assert.equal(
|
||||
|
||||
Reference in New Issue
Block a user