140 lines
4.2 KiB
JavaScript
140 lines
4.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { after, before, test } from "node:test";
|
|
|
|
import { createServer } from "vite";
|
|
|
|
let server;
|
|
let parseDatasetGatewayCatalog;
|
|
let fetchDatasetGatewayCatalog;
|
|
let DatasetGatewayContractError;
|
|
|
|
before(async () => {
|
|
server = await createServer({
|
|
appType: "custom",
|
|
logLevel: "silent",
|
|
server: { middlewareMode: true },
|
|
});
|
|
({
|
|
parseDatasetGatewayCatalog,
|
|
fetchDatasetGatewayCatalog,
|
|
DatasetGatewayContractError,
|
|
} = await server.ssrLoadModule("/src/core/lidar/datasetGateway.ts"));
|
|
});
|
|
|
|
after(async () => {
|
|
await server?.close();
|
|
});
|
|
|
|
function catalog(overrides = {}) {
|
|
return {
|
|
schema_version: "missioncore.dataset-gateway-catalog/v1",
|
|
access: "read-only",
|
|
storage: {
|
|
configured: false,
|
|
required_windows_root: "D:\\NDC_MISSIONCORE\\datasets",
|
|
required_wsl_root: "/mnt/d/NDC_MISSIONCORE/datasets",
|
|
admitted: false,
|
|
status: "blocked-storage-policy",
|
|
path_exposed: false,
|
|
},
|
|
sources: [{
|
|
source_id: "goose-3d/v2025-08-22",
|
|
display_name: "GOOSE 3D",
|
|
role: "primary-offroad-semantic-baseline",
|
|
license: "CC-BY-SA-4.0",
|
|
format: "semantickitti-xyzi-label",
|
|
frame_semantics: "one-lidar-revolution",
|
|
platforms: ["MuCAR-3", "ALICE", "Spot"],
|
|
annotations: ["semantic-point", "instance-point"],
|
|
superclasses: ["natural-ground", "obstacle"],
|
|
download: {
|
|
automatic: false,
|
|
reason: "operator-admitted-large-artifact-only",
|
|
validation_archive_gb: 3.3,
|
|
},
|
|
admission: {
|
|
status: "blocked-storage-policy",
|
|
},
|
|
}],
|
|
representations: [
|
|
{
|
|
id: "native-scan",
|
|
title: "Одиночный исходный скан",
|
|
purpose: "dataset-ground-truth-and-sensor-domain",
|
|
accumulation: false,
|
|
},
|
|
{
|
|
id: "normalized-scan",
|
|
title: "Нормализованный sensor-frame скан",
|
|
purpose: "deskew-filter-inference-and-algorithm-comparison",
|
|
accumulation: false,
|
|
},
|
|
{
|
|
id: "rolling-local-map",
|
|
title: "Накопленная локальная карта",
|
|
purpose: "stable-operator-view-and-local-planning",
|
|
accumulation: true,
|
|
},
|
|
],
|
|
pipeline: [{
|
|
stage: "deskew",
|
|
requires: ["per-point-time", "imu-or-odometry"],
|
|
produces: "normalized-scan",
|
|
}],
|
|
known_inputs: [{
|
|
source_id: "current-recorded-lidar/vendor-map",
|
|
representation: "vendor-mapped-increment",
|
|
native_scan: false,
|
|
per_point_time: false,
|
|
ring_or_line: false,
|
|
admitted_for_patchworkpp: false,
|
|
reason: "post-lio-map-product-cannot-be-reconstructed-as-a-native-scan",
|
|
}],
|
|
next_action: "configure-dataset-root-on-worker-d",
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
test("parses three distinct LiDAR representations and current-input boundary", () => {
|
|
const parsed = parseDatasetGatewayCatalog(catalog());
|
|
assert.deepEqual(
|
|
parsed.representations.map((item) => item.id),
|
|
["native-scan", "normalized-scan", "rolling-local-map"],
|
|
);
|
|
assert.equal(parsed.representations[2].accumulation, true);
|
|
assert.equal(parsed.currentInput.admittedForPatchworkpp, false);
|
|
assert.equal(parsed.source.frameSemantics, "one-lidar-revolution");
|
|
});
|
|
|
|
test("rejects path exposure and upgraded K1 semantics", () => {
|
|
const exposed = catalog();
|
|
exposed.storage.path_exposed = true;
|
|
assert.throws(
|
|
() => parseDatasetGatewayCatalog(exposed),
|
|
DatasetGatewayContractError,
|
|
);
|
|
|
|
const upgraded = catalog();
|
|
upgraded.known_inputs[0].per_point_time = true;
|
|
assert.throws(
|
|
() => parseDatasetGatewayCatalog(upgraded),
|
|
DatasetGatewayContractError,
|
|
);
|
|
});
|
|
|
|
test("fetches the read-only gateway endpoint", async () => {
|
|
const calls = [];
|
|
const parsed = await fetchDatasetGatewayCatalog({
|
|
fetcher: async (url, init) => {
|
|
calls.push({ url, init });
|
|
return new Response(JSON.stringify(catalog()), {
|
|
status: 200,
|
|
headers: { "Content-Type": "application/json" },
|
|
});
|
|
},
|
|
});
|
|
assert.equal(calls[0].url, "/api/v1/lidar/dataset-gateway");
|
|
assert.equal(calls[0].init.method, "GET");
|
|
assert.equal(parsed.source.displayName, "GOOSE 3D");
|
|
});
|