|
| 1 | +describe("TESTS: Configuration => Subsystem => Micrometer => Registry => OTLP", () => { |
| 2 | + const subsystemAddress = ["subsystem", "micrometer"]; |
| 3 | + const address = ["subsystem", "micrometer", "registry", "otlp"]; |
| 4 | + |
| 5 | + // HAL generates form IDs with triple-dash separators for child resources, |
| 6 | + // but collapses them to single dashes in some sub-elements (editing div, save button). |
| 7 | + const formIds = { |
| 8 | + configuration: "model-browser-model-browser-root---registry---otlp-form", |
| 9 | + configurationNoDash: "model-browser-model-browser-root-registry-otlp-form", |
| 10 | + addWizard: "model-browser-root-registry-singleton-add", |
| 11 | + childrenTable: "model-browser-children-table", |
| 12 | + }; |
| 13 | + |
| 14 | + const treeNodes = { |
| 15 | + registry: "#model-browser-root___registry", |
| 16 | + otlp: "#model-browser-root___registry___otlp", |
| 17 | + }; |
| 18 | + |
| 19 | + const endpointAttr = { |
| 20 | + name: "endpoint", |
| 21 | + customValue: "http://otel-collector:4318/v1/metrics", |
| 22 | + expressionProperty: "micrometer.otlp.endpoint", |
| 23 | + expressionPropertyValue: "http://expression-endpoint:4318/v1/metrics", |
| 24 | + expressionValue: "${micrometer.otlp.endpoint}", |
| 25 | + }; |
| 26 | + |
| 27 | + const stepAttr = { |
| 28 | + name: "step", |
| 29 | + customValue: 30, |
| 30 | + expressionProperty: "micrometer.otlp.step", |
| 31 | + expressionPropertyValue: "45", |
| 32 | + expressionValue: "${micrometer.otlp.step}", |
| 33 | + }; |
| 34 | + |
| 35 | + // Context value for prometheus registry (required field, avoids conflict with metrics subsystem) |
| 36 | + const prometheusContext = "/prometheus"; |
| 37 | + |
| 38 | + let managementEndpoint: string; |
| 39 | + |
| 40 | + function navigateToOtlpRegistry() { |
| 41 | + cy.navigateToGenericSubsystemPage(managementEndpoint, subsystemAddress); |
| 42 | + cy.get(`${treeNodes.registry} > .jstree-ocl`).click(); |
| 43 | + cy.get(treeNodes.otlp).should("be.visible").click(); |
| 44 | + cy.get('#model-browser-resource-tab-container a[href="#model-browser-resource-data-tab"]').click(); |
| 45 | + } |
| 46 | + |
| 47 | + // Workaround for JBEAP-28819 - child resource form IDs use triple-dash separators |
| 48 | + // for the container but single-dash for the editing div. |
| 49 | + function editForm() { |
| 50 | + const editButton = "#" + formIds.configuration + ' a.clickable[data-operation="edit"]'; |
| 51 | + cy.get(`#${formIds.configurationNoDash}-editing`).should("not.be.visible"); |
| 52 | + cy.get(editButton).click(); |
| 53 | + for (let reClickTry = 0; reClickTry < 5; reClickTry++) { |
| 54 | + cy.get(editButton).then(($button) => { |
| 55 | + if ($button.is(":visible")) { |
| 56 | + cy.get(editButton).click(); |
| 57 | + } |
| 58 | + }); |
| 59 | + } |
| 60 | + cy.get(`#${formIds.configurationNoDash}-editing`).should("be.visible"); |
| 61 | + } |
| 62 | + |
| 63 | + before(function () { |
| 64 | + cy.startWildflyContainer().then((result) => { |
| 65 | + managementEndpoint = result as string; |
| 66 | + cy.skipIf(cy.isEAP(managementEndpoint), this); |
| 67 | + // The micrometer extension is not part of the base configuration, so it must be added explicitly |
| 68 | + cy.addAddress(managementEndpoint, ["extension", "org.wildfly.extension.micrometer"], {}); |
| 69 | + // Register the micrometer subsystem as a parent for the registries |
| 70 | + cy.addAddress(managementEndpoint, subsystemAddress, {}); |
| 71 | + // System properties used as expression resolution targets in the expression tests |
| 72 | + cy.addAddress(managementEndpoint, ["system-property", endpointAttr.expressionProperty], { |
| 73 | + value: endpointAttr.expressionPropertyValue, |
| 74 | + }); |
| 75 | + cy.addAddress(managementEndpoint, ["system-property", stepAttr.expressionProperty], { |
| 76 | + value: stepAttr.expressionPropertyValue, |
| 77 | + }); |
| 78 | + }); |
| 79 | + }); |
| 80 | + |
| 81 | + after(() => { |
| 82 | + cy.task("stop:containers"); |
| 83 | + }); |
| 84 | + |
| 85 | + it("Add otlp registry", () => { |
| 86 | + cy.navigateToGenericSubsystemPage(managementEndpoint, subsystemAddress); |
| 87 | + cy.get(treeNodes.registry).should("be.visible").click(); |
| 88 | + cy.get(`#${formIds.childrenTable}_wrapper`).should("be.visible"); |
| 89 | + cy.addInTable(formIds.childrenTable); |
| 90 | + // First registry added: wizard shows radio button step, otlp has no required fields |
| 91 | + cy.get("input[type='radio'][value='otlp']").should("exist").check({ force: true }); |
| 92 | + cy.get("input[type='radio'][value='otlp']").should("be.checked"); |
| 93 | + cy.confirmNextInWizard(); |
| 94 | + cy.confirmFinishInWizard(); |
| 95 | + cy.verifySuccess(); |
| 96 | + }); |
| 97 | + |
| 98 | + it("Add prometheus registry", () => { |
| 99 | + cy.navigateToGenericSubsystemPage(managementEndpoint, subsystemAddress); |
| 100 | + cy.get(treeNodes.registry).should("be.visible").click(); |
| 101 | + cy.get(`#${formIds.childrenTable}_wrapper`).should("be.visible"); |
| 102 | + cy.addInTable(formIds.childrenTable); |
| 103 | + // Second registry added: wizard skips radio button step, prometheus requires context |
| 104 | + cy.text(formIds.addWizard, "context", prometheusContext); |
| 105 | + cy.confirmAddResourceWizard(); |
| 106 | + cy.verifySuccess(); |
| 107 | + }); |
| 108 | + |
| 109 | + it("Edit endpoint", () => { |
| 110 | + navigateToOtlpRegistry(); |
| 111 | + editForm(); |
| 112 | + cy.text(formIds.configurationNoDash, endpointAttr.name, endpointAttr.customValue); |
| 113 | + cy.saveForm(formIds.configurationNoDash); |
| 114 | + cy.verifySuccess(); |
| 115 | + cy.verifyAttribute(managementEndpoint, address, endpointAttr.name, endpointAttr.customValue); |
| 116 | + }); |
| 117 | + |
| 118 | + it("Edit step", () => { |
| 119 | + navigateToOtlpRegistry(); |
| 120 | + editForm(); |
| 121 | + cy.text(formIds.configurationNoDash, stepAttr.name, stepAttr.customValue.toString()); |
| 122 | + cy.saveForm(formIds.configurationNoDash); |
| 123 | + cy.verifySuccess(); |
| 124 | + cy.verifyAttribute(managementEndpoint, address, stepAttr.name, stepAttr.customValue); |
| 125 | + }); |
| 126 | + |
| 127 | + it("Edit endpoint with expression", () => { |
| 128 | + const selector = `input#${formIds.configurationNoDash}-${endpointAttr.name}-editing.form-control`; |
| 129 | + navigateToOtlpRegistry(); |
| 130 | + editForm(); |
| 131 | + cy.textExpression(formIds.configurationNoDash, endpointAttr.name, endpointAttr.expressionValue, { selector }); |
| 132 | + cy.saveForm(formIds.configurationNoDash); |
| 133 | + cy.get(".toast-notifications-list-pf .alert").should("be.visible"); |
| 134 | + cy.verifyAttributeAsExpression(managementEndpoint, address, endpointAttr.name, endpointAttr.expressionValue); |
| 135 | + }); |
| 136 | + |
| 137 | + it("Edit step with expression", () => { |
| 138 | + const selector = `input#${formIds.configurationNoDash}-${stepAttr.name}-editing.form-control`; |
| 139 | + navigateToOtlpRegistry(); |
| 140 | + editForm(); |
| 141 | + cy.textExpression(formIds.configurationNoDash, stepAttr.name, stepAttr.expressionValue, { selector }); |
| 142 | + cy.saveForm(formIds.configurationNoDash); |
| 143 | + cy.get(".toast-notifications-list-pf .alert").should("be.visible"); |
| 144 | + cy.verifyAttributeAsExpression(managementEndpoint, address, stepAttr.name, stepAttr.expressionValue); |
| 145 | + }); |
| 146 | + |
| 147 | + it("Reset configuration", () => { |
| 148 | + navigateToOtlpRegistry(); |
| 149 | + cy.resetForm(formIds.configuration, managementEndpoint, address); |
| 150 | + }); |
| 151 | +}); |
0 commit comments