@@ -26,7 +26,7 @@ import (
26
26
27
27
"github.com/davecgh/go-spew/spew"
28
28
"github.com/golang/protobuf/proto"
29
- "github.com/google/gofuzz"
29
+ fuzz "github.com/google/gofuzz"
30
30
flag "github.com/spf13/pflag"
31
31
32
32
apitesting "k8s.io/apimachinery/pkg/api/apitesting"
@@ -103,6 +103,23 @@ var globalNonRoundTrippableTypes = sets.NewString(
103
103
"DeleteOptions" ,
104
104
)
105
105
106
+ // GlobalNonRoundTrippableTypes returns the kinds that are effectively reserved across all GroupVersions.
107
+ // They don't roundtrip and thus can be excluded in any custom/downstream roundtrip tests
108
+ //
109
+ // kinds := scheme.AllKnownTypes()
110
+ // for gvk := range kinds {
111
+ // if roundtrip.GlobalNonRoundTrippableTypes().Has(gvk.Kind) {
112
+ // continue
113
+ // }
114
+ // t.Run(gvk.Group+"."+gvk.Version+"."+gvk.Kind, func(t *testing.T) {
115
+ // // roundtrip test
116
+ // })
117
+ // }
118
+ //
119
+ func GlobalNonRoundTrippableTypes () sets.String {
120
+ return sets .NewString (globalNonRoundTrippableTypes .List ()... )
121
+ }
122
+
106
123
// RoundTripTypesWithoutProtobuf applies the round-trip test to all round-trippable Kinds
107
124
// in the scheme. It will skip all the GroupVersionKinds in the skip list.
108
125
func RoundTripTypesWithoutProtobuf (t * testing.T , scheme * runtime.Scheme , codecFactory runtimeserializer.CodecFactory , fuzzer * fuzz.Fuzzer , nonRoundTrippableTypes map [schema.GroupVersionKind ]bool ) {
@@ -146,6 +163,20 @@ func RoundTripExternalTypes(t *testing.T, scheme *runtime.Scheme, codecFactory r
146
163
}
147
164
}
148
165
166
+ // RoundTripExternalTypesWithoutProtobuf applies the round-trip test to all external round-trippable Kinds
167
+ // in the scheme. It will skip all the GroupVersionKinds in the nonRoundTripExternalTypes list.
168
+ func RoundTripExternalTypesWithoutProtobuf (t * testing.T , scheme * runtime.Scheme , codecFactory runtimeserializer.CodecFactory , fuzzer * fuzz.Fuzzer , nonRoundTrippableTypes map [schema.GroupVersionKind ]bool ) {
169
+ kinds := scheme .AllKnownTypes ()
170
+ for gvk := range kinds {
171
+ if gvk .Version == runtime .APIVersionInternal || globalNonRoundTrippableTypes .Has (gvk .Kind ) {
172
+ continue
173
+ }
174
+ t .Run (gvk .Group + "." + gvk .Version + "." + gvk .Kind , func (t * testing.T ) {
175
+ roundTripSpecificKind (t , gvk , scheme , codecFactory , fuzzer , nonRoundTrippableTypes , true )
176
+ })
177
+ }
178
+ }
179
+
149
180
func RoundTripSpecificKindWithoutProtobuf (t * testing.T , gvk schema.GroupVersionKind , scheme * runtime.Scheme , codecFactory runtimeserializer.CodecFactory , fuzzer * fuzz.Fuzzer , nonRoundTrippableTypes map [schema.GroupVersionKind ]bool ) {
150
181
roundTripSpecificKind (t , gvk , scheme , codecFactory , fuzzer , nonRoundTrippableTypes , true )
151
182
}
0 commit comments