Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly handle returned error values in admission metrics_test #82105

Merged
merged 1 commit into from
Oct 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions staging/src/k8s.io/apiserver/pkg/admission/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ var (
func TestObserveAdmissionStep(t *testing.T) {
Metrics.reset()
handler := WithStepMetrics(&mutatingAndValidatingFakeHandler{admission.NewHandler(admission.Create), true, true})
handler.(admission.MutationInterface).Admit(context.TODO(), attr, nil)
handler.(admission.ValidationInterface).Validate(context.TODO(), attr, nil)
if err := handler.(admission.MutationInterface).Admit(context.TODO(), attr, nil); err != nil {
t.Errorf("Unexpected error in admit: %v", err)
}
if err := handler.(admission.ValidationInterface).Validate(context.TODO(), attr, nil); err != nil {
t.Errorf("Unexpected error in validate: %v", err)
}
wantLabels := map[string]string{
"operation": string(admission.Create),
"type": "admit",
Expand All @@ -55,8 +59,12 @@ func TestObserveAdmissionStep(t *testing.T) {
func TestObserveAdmissionController(t *testing.T) {
Metrics.reset()
handler := WithControllerMetrics(&mutatingAndValidatingFakeHandler{admission.NewHandler(admission.Create), true, true}, "a")
handler.(admission.MutationInterface).Admit(context.TODO(), attr, nil)
handler.(admission.ValidationInterface).Validate(context.TODO(), attr, nil)
if err := handler.(admission.MutationInterface).Admit(context.TODO(), attr, nil); err != nil {
t.Errorf("Unexpected error in admit: %v", err)
}
if err := handler.(admission.ValidationInterface).Validate(context.TODO(), attr, nil); err != nil {
t.Errorf("Unexpected error in validate: %v", err)
}
wantLabels := map[string]string{
"name": "a",
"operation": string(admission.Create),
Expand Down