Skip to content

Commit

Permalink
Make endpointslice fuzzing work (istio#41186)
Browse files Browse the repository at this point in the history
  • Loading branch information
howardjohn authored Oct 13, 2022
1 parent a541bb1 commit a9e7c85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pilot/pkg/serviceregistry/kube/controller/endpointslice.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ func wrapEndpointSlice(slice any) *endpointSliceWrapper {
return &endpointSliceWrapper{ObjectMeta: es.ObjectMeta, v1: es}
case *v1beta1.EndpointSlice:
return &endpointSliceWrapper{ObjectMeta: es.ObjectMeta, v1beta1: es}
default:
log.Fatalf("unknown type %T", es)
}
return nil
}
Expand Down
10 changes: 8 additions & 2 deletions pilot/pkg/serviceregistry/kube/controller/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"testing"

corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/discovery/v1"

"istio.io/istio/pilot/pkg/model"
"istio.io/istio/pkg/fuzz"
Expand All @@ -36,7 +37,12 @@ func FuzzKubeController(f *testing.F) {
controller.pods.onEvent(p, model.EventAdd)
s := fuzz.Struct[*corev1.Service](fg)
controller.onServiceEvent(s, model.EventAdd)
e := fuzz.Struct[*corev1.Endpoints](fg)
controller.endpoints.onEvent(e, model.EventAdd)
if fco.Mode == EndpointsOnly {
e := fuzz.Struct[*corev1.Endpoints](fg)
controller.endpoints.onEvent(e, model.EventAdd)
} else {
e := fuzz.Struct[*v1.EndpointSlice](fg)
controller.endpoints.onEvent(e, model.EventAdd)
}
})
}

0 comments on commit a9e7c85

Please sign in to comment.