Files
pikasTech-HWLAB/internal/patchpanel/fixture.mjs
T
2026-05-21 14:40:31 +00:00

81 lines
2.0 KiB
JavaScript

import { createBoxState, createGatewayState } from "../sim/model.mjs";
import { createPatchPanelState, createWiringConfig } from "./model.mjs";
export const MVP_BOX_IDS = Object.freeze(["boxsim_alpha", "boxsim_beta"]);
export const MVP_GATEWAY_IDS = Object.freeze(["gwsimu_east", "gwsimu_west"]);
export function createMvpTopology({ now = "2026-01-01T00:00:00.000Z" } = {}) {
const gatewaySessionIds = MVP_GATEWAY_IDS.map((gatewayId) => `gws_${gatewayId}`);
const boxes = MVP_BOX_IDS.map((boxId, index) =>
createBoxState({
boxId,
gatewaySessionId: gatewaySessionIds[index],
now
})
);
const gateways = MVP_GATEWAY_IDS.map((gatewayId, index) =>
createGatewayState({
gatewayId,
endpoint: `http://127.0.0.1:${7101 + index}`,
boxes: [boxes[index].resource.resourceId],
now
})
);
const wiringConfig = createWiringConfig({
gatewaySessionId: gatewaySessionIds[0],
connections: [
{
from: {
resourceId: boxes[0].resource.resourceId,
port: "uart0"
},
to: {
resourceId: boxes[1].resource.resourceId,
port: "uart0"
},
mode: "exclusive"
},
{
from: {
resourceId: boxes[0].resource.resourceId,
port: "gpio0"
},
to: {
resourceId: boxes[1].resource.resourceId,
port: "gpio0"
},
mode: "monitor"
}
],
now
});
const patchPanel = createPatchPanelState({
gatewaySessionId: gatewaySessionIds[0],
wiringConfig,
now
});
return {
topologyId: "top_mvp_l2_l3_sim_patch",
projectId: "prj_mvp_topology",
environment: "dev",
services: {
boxes,
gateways,
patchPanel
},
wiringConfig,
constraints: {
patchPanelIsOnlyCrossDeviceChannel: true,
boxSimuLocalLoopbackForCrossDeviceSync: false
},
dryRunHints: {
cliTarget: "fixtures/mvp-topology/topology.json",
expectedServices: ["hwlab-box-simu", "hwlab-gateway-simu", "hwlab-patch-panel"]
}
};
}