Skip to content

Commit db79b55

Browse files
ricardomaraschinitjungblu
authored andcommitted
UPSTREAM: <carry>: Fix tests after backport
When backporting some changes from upstream's master branch a unit test ended up being broken. The code covered by this test does not seem to exist upstream, neither the test file. The code this commit fixes was introduced by 57c60d8 and we should squash this one with it once the time for rebasing arrives. Even though 57c60d8 description reads "UPSTREAM: 115328: annotate early and late requests" the upstream PR 115328 was closed without merging.
1 parent 30f86a7 commit db79b55

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

staging/src/k8s.io/apiserver/pkg/server/filters/with_early_late_annotations_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,7 @@ func TestWithStartupEarlyAnnotation(t *testing.T) {
257257
if ac == nil {
258258
t.Fatalf("expected audit context inside the request context")
259259
}
260-
ac.Event = auditinternal.Event{
261-
Level: auditinternal.LevelMetadata,
262-
}
260+
ac.Init(audit.RequestAuditConfig{Level: auditinternal.LevelMetadata}, nil)
263261

264262
w := httptest.NewRecorder()
265263
w.Code = 0
@@ -275,11 +273,11 @@ func TestWithStartupEarlyAnnotation(t *testing.T) {
275273
key := "apiserver.k8s.io/startup"
276274
switch {
277275
case len(test.annotationExpected) == 0:
278-
if valueGot, ok := ac.Event.Annotations[key]; ok {
276+
if valueGot, ok := ac.GetEventAnnotation(key); ok {
279277
t.Errorf("did not expect annotation to be added, but got: %s", valueGot)
280278
}
281279
default:
282-
if valueGot, ok := ac.Event.Annotations[key]; !ok || test.annotationExpected != valueGot {
280+
if valueGot, ok := ac.GetEventAnnotation(key); !ok || test.annotationExpected != valueGot {
283281
t.Errorf("expected annotation: %s, but got: %s", test.annotationExpected, valueGot)
284282
}
285283
}

0 commit comments

Comments
 (0)