This is an automated email from the ASF dual-hosted git repository. pcongiusti pushed a commit to branch revert-3875-prometheus_trait_ocp4 in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit d791d8f0ffdba04897d1fad91654bc88e645ea1a Author: Pasquale Congiusti <[email protected]> AuthorDate: Wed Dec 7 08:31:44 2022 +0100 Revert "prometheus trait fully tested as in CI, the version of OCP is 4.x" This reverts commit 2a3757a0b8da643143c713fd826a567e3f37b9ee. --- e2e/global/common/traits/prometheus_test.go | 52 +++++++++-------------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/e2e/global/common/traits/prometheus_test.go b/e2e/global/common/traits/prometheus_test.go index 2ba205fd9..f4a9a1709 100644 --- a/e2e/global/common/traits/prometheus_test.go +++ b/e2e/global/common/traits/prometheus_test.go @@ -46,17 +46,20 @@ func TestPrometheusTrait(t *testing.T) { ocp, err := openshift.IsOpenShift(TestClient()) assert.Nil(t, err) + // Do not create PodMonitor for the time being as CI test runs on OCP 3.11 + createPodMonitor := false + operatorID := "camel-k-trait-prometheus" Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed()) - t.Run("Metrics endpoint works", func(t *testing.T) { - Expect(KamelRunWithID(operatorID, ns, "files/Java.java", - "-t", "prometheus.enabled=true", - "-t", "prometheus.pod-monitor=true").Execute()).To(Succeed()) - Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) - Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) - Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) + Expect(KamelRunWithID(operatorID, ns, "files/Java.java", + "-t", "prometheus.enabled=true", + "-t", fmt.Sprintf("prometheus.pod-monitor=%v", createPodMonitor)).Execute()).To(Succeed()) + Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) + Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) + Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) + t.Run("Metrics endpoint works", func(t *testing.T) { pod := IntegrationPod(ns, "java") response, err := TestClient().CoreV1().RESTClient().Get(). AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/proxy/q/metrics", ns, pod().Name)).DoRaw(TestContext) @@ -64,41 +67,16 @@ func TestPrometheusTrait(t *testing.T) { assert.Fail(t, err.Error()) } assert.Contains(t, string(response), "camel.route.exchanges.total") - - if ocp { - t.Run("PodMonitor is created", func(t *testing.T) { - sm := podMonitor(ns, "java") - Eventually(sm, TestTimeoutShort).ShouldNot(BeNil()) - - t.Run("PodMonitor has default label", func(t *testing.T) { - Expect(sm().GetLabels()["camel.apache.org/integration"]).To(Equal("java")) - }) - }) - } - Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) }) - if ocp { - t.Run("Pod monitor custom label is added", func(t *testing.T) { - Expect(KamelRunWithID(operatorID, ns, "files/Java.java", - "-t", "prometheus.enabled=true", - "-t", "prometheus.pod-monitor-labels=mylabelname=mylabelvalue").Execute()).To(Succeed()) - Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) - Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) - Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) - - t.Run("PodMonitor is created", func(t *testing.T) { - sm := podMonitor(ns, "java") - Eventually(sm, TestTimeoutShort).ShouldNot(BeNil()) - t.Run("PodMonitor has custom label", func(t *testing.T) { - Expect(sm().GetLabels()["mylabelname"]).To(Equal("mylabelvalue")) - }) - }) - - Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) + if ocp && createPodMonitor { + t.Run("PodMonitor is created", func(t *testing.T) { + sm := podMonitor(ns, "java") + Eventually(sm, TestTimeoutShort).ShouldNot(BeNil()) }) } + Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) }) }
