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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user