Skip to content

Commit

Permalink
add prometheus server test
Browse files Browse the repository at this point in the history
  • Loading branch information
matmerr committed Jan 23, 2024
1 parent c1a5560 commit f574d15
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/e2e/scenarios/hubble/amametrics_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//go:build e2e
// +build e2e

package hubble

import (
"context"
"testing"

"github.com/prometheus/client_golang/api"
promv1 "github.com/prometheus/client_golang/api/prometheus/v1"
"github.com/stretchr/testify/require"
)

const (
promHubbleJob = "hubble-pods"
)

func TestPrometheusQuery(t *testing.T) {
client, err := api.NewClient(api.Config{
Address: "http://localhost:9090",
})

require.NoError(t, err)
promapi := promv1.NewAPI(client)
ctx := context.Background()
targets, err := promapi.Targets(ctx)
require.NoError(t, err)
require.NotNil(t, targets)

hubbleActiveTarget := &promv1.ActiveTarget{
ScrapePool: promHubbleJob,
Health: "up",
}

for _, target := range targets.Active {
if target.ScrapePool == hubbleActiveTarget.ScrapePool {
require.Equal(t, hubbleActiveTarget.Health, hubbleActiveTarget.Health)
break
}
}
}

0 comments on commit f574d15

Please sign in to comment.