Skip to content

Commit

Permalink
fixed observers test
Browse files Browse the repository at this point in the history
Signed-off-by: Keerthan Ekbote <[email protected]>
  • Loading branch information
saiskee committed May 5, 2021
1 parent 99b3775 commit fdc8dd8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/metrics/observers/gloo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
)

func TestGlooObserver_GetRequestSuccessRate(t *testing.T) {
expected := ` sum( rate( envoy_cluster_upstream_rq{ envoy_cluster_name=~"default-podinfo-canary-[0-9a-zA-Z-]+_[0-9a-zA-Z-]+", envoy_response_code!~"5.*" }[1m] ) ) / sum( rate( envoy_cluster_upstream_rq{ envoy_cluster_name=~"default-podinfo-canary-[0-9a-zA-Z-]+_[0-9a-zA-Z-]+", }[1m] ) ) * 100`
expected := ` sum( rate( envoy_cluster_upstream_rq{ envoy_cluster_name=~"default-podinfo-canaryupstream-[0-9a-zA-Z-]+_[0-9a-zA-Z-]+", envoy_response_code!~"5.*" }[1m] ) ) / sum( rate( envoy_cluster_upstream_rq{ envoy_cluster_name=~"default-podinfo-canaryupstream-[0-9a-zA-Z-]+_[0-9a-zA-Z-]+", }[1m] ) ) * 100`

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
promql := r.URL.Query()["query"][0]
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestGlooObserver_GetRequestSuccessRate(t *testing.T) {
}

func TestGlooObserver_GetRequestDuration(t *testing.T) {
expected := ` histogram_quantile( 0.99, sum( rate( envoy_cluster_upstream_rq_time_bucket{ envoy_cluster_name=~"default-podinfo-canary-[0-9a-zA-Z-]+_[0-9a-zA-Z-]+", }[1m] ) ) by (le) )`
expected := ` histogram_quantile( 0.99, sum( rate( envoy_cluster_upstream_rq_time_bucket{ envoy_cluster_name=~"default-podinfo-canaryupstream-[0-9a-zA-Z-]+_[0-9a-zA-Z-]+", }[1m] ) ) by (le) )`

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
promql := r.URL.Query()["query"][0]
Expand Down
22 changes: 20 additions & 2 deletions pkg/router/gloo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,17 @@ func TestGlooRouter_SetRoutes(t *testing.T) {
glooClient: mocks.meshClient,
kubeClient: mocks.kubeClient,
}
svcRouter := &KubernetesDefaultRouter{
kubeClient: mocks.kubeClient,
flaggerClient: mocks.flaggerClient,
logger: mocks.logger,
}
err := svcRouter.Initialize(mocks.canary)
require.NoError(t, err)
err = svcRouter.Reconcile(mocks.canary)
require.NoError(t, err)

err := router.Reconcile(mocks.canary)
err = router.Reconcile(mocks.canary)
require.NoError(t, err)

_, _, _, err = router.GetRoutes(mocks.canary)
Expand Down Expand Up @@ -147,8 +156,17 @@ func TestGlooRouter_GetRoutes(t *testing.T) {
glooClient: mocks.meshClient,
kubeClient: mocks.kubeClient,
}
svcRouter := &KubernetesDefaultRouter{
kubeClient: mocks.kubeClient,
flaggerClient: mocks.flaggerClient,
logger: mocks.logger,
}
err := svcRouter.Initialize(mocks.canary)
require.NoError(t, err)
err = svcRouter.Reconcile(mocks.canary)
require.NoError(t, err)

err := router.Reconcile(mocks.canary)
err = router.Reconcile(mocks.canary)
require.NoError(t, err)

p, c, m, err := router.GetRoutes(mocks.canary)
Expand Down

0 comments on commit fdc8dd8

Please sign in to comment.