Skip to content

Commit

Permalink
add tests for new metric
Browse files Browse the repository at this point in the history
  • Loading branch information
ltagliamonte-dd committed Dec 29, 2021
1 parent 6542f4b commit 0844891
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions staging/src/k8s.io/apiserver/pkg/admission/metrics/metrics_test.go
Expand Up @@ -159,6 +159,23 @@ func TestObserveWebhookRejection(t *testing.T) {
expectCounterValue(t, "apiserver_admission_webhook_rejection_count", wantLabelsAPIServerInternalError, 1)
}

func TestObserveWebhookFailOpen(t *testing.T) {
defer Metrics.reset()
defer legacyregistry.Reset()
Metrics.ObserveWebhookFailOpen(context.TODO(), "x", stepAdmit)
Metrics.ObserveWebhookFailOpen(context.TODO(), "x", stepValidate)
wantLabelsCounterAdmit := map[string]string{
"name": "x",
"type": "admit",
}
wantLabelsCounterValidate := map[string]string{
"name": "x",
"type": "validate",
}
expectCounterValue(t, "apiserver_admission_webhook_fail_open_count", wantLabelsCounterAdmit, 1)
expectCounterValue(t, "apiserver_admission_webhook_fail_open_count", wantLabelsCounterValidate, 1)
}

func TestWithMetrics(t *testing.T) {
defer Metrics.reset()
defer legacyregistry.Reset()
Expand Down

0 comments on commit 0844891

Please sign in to comment.