You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/12/15 10:50:52 UTC

[camel-k] 02/02: fix(e2e): More robust first readiness metric assertion

This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 22ed86f11f5722b06c61e5beecaa403010ed8678
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Wed Dec 15 08:38:19 2021 +0100

    fix(e2e): More robust first readiness metric assertion
---
 e2e/common/operator_metrics_test.go | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/e2e/common/operator_metrics_test.go b/e2e/common/operator_metrics_test.go
index 855b280..62b181b 100644
--- a/e2e/common/operator_metrics_test.go
+++ b/e2e/common/operator_metrics_test.go
@@ -435,7 +435,18 @@ func TestMetrics(t *testing.T) {
 			durationFromLogs := ts2.Sub(ts1)
 
 			// Check both durations match
-			Expect(math.Abs((durationFromLogs - duration).Seconds())).To(BeNumerically("<", 1))
+			Expect(math.Abs((durationFromLogs - duration).Seconds())).To(BeNumerically("<=", 1))
+
+			// Retrieve the first readiness duration from the metric
+			Expect(metrics).To(HaveKey("camel_k_integration_first_readiness_seconds"))
+			metric := metrics["camel_k_integration_first_readiness_seconds"].Metric
+			Expect(metric).To(HaveLen(1))
+			histogram := metric[0].Histogram
+			Expect(histogram).NotTo(BeNil())
+
+			// Check both durations match
+			d := duration.Seconds()
+			Expect(math.Abs(*histogram.SampleSum - d)).To(BeNumerically("<=", 1))
 
 			// Check the duration is correctly observed in the corresponding metric
 			Expect(metrics).To(HaveKey("camel_k_integration_first_readiness_seconds"))
@@ -448,7 +459,7 @@ func TestMetrics(t *testing.T) {
 						{
 							Histogram: &prometheus.Histogram{
 								SampleCount: uint64P(1),
-								SampleSum:   float64P(duration.Seconds()),
+								SampleSum:   histogram.SampleSum,
 								Bucket:      buckets(duration.Seconds(), []float64{5, 10, 30, 60, 120, math.Inf(1)}),
 							},
 						},