From 41ed21a2f95b4846cb9c27c03f8ea833ccd58dcd Mon Sep 17 00:00:00 2001 From: Raul Sevilla Date: Wed, 21 Feb 2024 10:45:05 +0100 Subject: [PATCH 1/2] Update verify connection API call Signed-off-by: Raul Sevilla --- prometheus/prometheus.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/prometheus/prometheus.go b/prometheus/prometheus.go index 1768e7a..2101cf6 100644 --- a/prometheus/prometheus.go +++ b/prometheus/prometheus.go @@ -88,9 +88,6 @@ func (p *Prometheus) QueryRange(query string, start, end time.Time, step time.Du // Verifies prometheus connection func (p *Prometheus) verifyConnection() error { - _, err := p.api.Runtimeinfo(context.TODO()) - if err != nil { - return err - } - return nil + _, err := p.Query("up{}", time.Now().UTC().UTC()) + return err } From d8519066ef1fd6557c0cec5b08b42d4fd4bb23f7 Mon Sep 17 00:00:00 2001 From: Raul Sevilla Date: Wed, 21 Feb 2024 10:49:43 +0100 Subject: [PATCH 2/2] Update testcase Signed-off-by: Raul Sevilla --- prometheus/prometheus_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prometheus/prometheus_test.go b/prometheus/prometheus_test.go index 69f2c36..cd32c6b 100644 --- a/prometheus/prometheus_test.go +++ b/prometheus/prometheus_test.go @@ -101,7 +101,7 @@ var _ = Describe("Tests for Prometheus", func() { _, err := NewClient(url, token, username, password, tlsSkipVerify) //Asserting no of times mocks are called Expect(count).To(BeEquivalentTo(0)) - Expect(err.Error()).To(ContainSubstring("Get \"/api/v1/status/runtimeinfo\": unsupported protocol scheme \"\"")) + Expect(err.Error()).To(ContainSubstring("Post \"/api/v1/query\": unsupported protocol scheme \"\"")) }) It("Test2 passing not valid url", func() {