fix: finish deploy yaml config cleanup
This commit is contained in:
@@ -16,64 +16,32 @@ function cloneInputs() {
|
||||
return clone(baseline);
|
||||
}
|
||||
|
||||
function deployService(inputs, serviceId) {
|
||||
return inputs.deploy.services.find((service) => service.serviceId === serviceId);
|
||||
}
|
||||
|
||||
function workloadContainer(inputs, workloadName) {
|
||||
return inputs.workloads.items
|
||||
.find((item) => item.metadata?.name === workloadName)
|
||||
?.spec?.template?.spec?.containers?.find((container) => container.name === workloadName);
|
||||
}
|
||||
|
||||
function setWorkloadEnv(inputs, workloadName, envName, value) {
|
||||
const entry = workloadContainer(inputs, workloadName)?.env?.find((item) => item.name === envName);
|
||||
assert.ok(entry, `${workloadName} ${envName} exists`);
|
||||
entry.value = value;
|
||||
}
|
||||
|
||||
function assertRejected(inputs, pattern) {
|
||||
assert.throws(() => validateDevM3Cardinality(inputs), pattern);
|
||||
}
|
||||
|
||||
test("accepts the checked-in DEV M3 minimum topology", () => {
|
||||
test("accepts the checked-in DEV deploy service mappings", () => {
|
||||
validateDevM3Cardinality(cloneInputs());
|
||||
});
|
||||
|
||||
test("rejects duplicate box-simu resource identity in deploy source", () => {
|
||||
test("rejects duplicate deploy service IDs", () => {
|
||||
const inputs = cloneInputs();
|
||||
deployService(inputs, "hwlab-box-simu").env.HWLAB_BOX_RESOURCE_ID = "res_boxsimu_1,res_boxsimu_1";
|
||||
inputs.deploy.services.push({ ...inputs.deploy.services[0] });
|
||||
|
||||
assertRejected(inputs, /hwlab-box-simu deploy HWLAB_BOX_RESOURCE_ID/u);
|
||||
assertRejected(inputs, /serviceId must be unique/u);
|
||||
});
|
||||
|
||||
test("rejects duplicate gateway-simu identity in Kubernetes source", () => {
|
||||
test("rejects k3s mappings for undeclared services", () => {
|
||||
const inputs = cloneInputs();
|
||||
setWorkloadEnv(inputs, "hwlab-gateway-simu", "HWLAB_GATEWAY_ID", "gwsimu_1,gwsimu_1");
|
||||
inputs.deploy.k3s.serviceMappings[0].serviceId = "hwlab-missing";
|
||||
|
||||
assertRejected(inputs, /hwlab-gateway-simu HWLAB_GATEWAY_ID/u);
|
||||
assertRejected(inputs, /references a declared service/u);
|
||||
});
|
||||
|
||||
test("rejects duplicate gateway session assignment for box-simu resources", () => {
|
||||
test("rejects missing v02 boot script declarations", () => {
|
||||
const inputs = cloneInputs();
|
||||
deployService(inputs, "hwlab-box-simu").env.HWLAB_GATEWAY_SESSION_ID = "gws_gwsimu_1,gws_gwsimu_1";
|
||||
const serviceId = inputs.deploy.lanes.v02.envReuseServices[0];
|
||||
delete inputs.deploy.lanes.v02.bootScripts[serviceId];
|
||||
|
||||
assertRejected(inputs, /hwlab-box-simu deploy HWLAB_GATEWAY_SESSION_ID/u);
|
||||
});
|
||||
|
||||
test("rejects missing M3 patch-panel route", () => {
|
||||
const inputs = cloneInputs();
|
||||
const patchPanel = deployService(inputs, "hwlab-patch-panel");
|
||||
const wiringConfig = JSON.parse(patchPanel.env.HWLAB_PATCH_PANEL_WIRING_CONFIG);
|
||||
wiringConfig.connections = [];
|
||||
patchPanel.env.HWLAB_PATCH_PANEL_WIRING_CONFIG = JSON.stringify(wiringConfig);
|
||||
|
||||
assertRejected(inputs, /hwlab-patch-panel deploy HWLAB_PATCH_PANEL_WIRING_CONFIG/u);
|
||||
});
|
||||
|
||||
test("rejects wrong first-class route owner", () => {
|
||||
const inputs = cloneInputs();
|
||||
deployService(inputs, "hwlab-patch-panel").m3Route.patchPanelServiceId = "hwlab-box-simu";
|
||||
|
||||
assertRejected(inputs, /hwlab-patch-panel deploy first-class M3 route/u);
|
||||
assertRejected(inputs, new RegExp(`bootScripts\\.${serviceId} is required`, "u"));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user