Skip to content

Commit

Permalink
e2e: eg controlplane metrics
Browse files Browse the repository at this point in the history
Signed-off-by: zirain <zirain2009@gmail.com>
  • Loading branch information
zirain committed Oct 29, 2023
1 parent 131178b commit 728ca38
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/e2e/testdata/prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: envoy-gateway-lb
namespace: envoy-gateway-system
labels:
control-plane: envoy-gateway
spec:
selector:
control-plane: envoy-gateway
ports:
- name: http-metrics
port: 19001
protocol: TCP
targetPort: 19001
type: LoadBalancer
46 changes: 46 additions & 0 deletions test/e2e/tests/prometheus.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

//go:build e2e
// +build e2e

package tests

import (
"context"
"testing"
"time"

"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
)

func init() {
ConformanceTests = append(ConformanceTests, PrometheusTest)
}

var PrometheusTest = suite.ConformanceTest{
ShortName: "Prometheus",
Description: "Make sure Prometheus endpoint is working",
Manifests: []string{"testdata/prometheus.yaml"},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
t.Run("MetricExists", func(t *testing.T) {
if err := wait.PollUntilContextTimeout(context.TODO(), time.Second, time.Minute, true,
func(_ context.Context) (done bool, err error) {
if err := ScrapeMetrics(t, suite.Client, types.NamespacedName{
Namespace: "envoy-gateway-system",
Name: "envoy-gateway-lb",
}, "/metrics"); err != nil {
t.Logf("failed to get metric: %v", err)
return false, nil
}
return true, nil
}); err != nil {
t.Errorf("failed to scrape metrics: %v", err)
}
})
},
}

0 comments on commit 728ca38

Please sign in to comment.