diff --git a/staging/src/k8s.io/api/roundtrip_test.go b/staging/src/k8s.io/api/roundtrip_test.go index c333d71e976..ad36f411279 100644 --- a/staging/src/k8s.io/api/roundtrip_test.go +++ b/staging/src/k8s.io/api/roundtrip_test.go @@ -95,16 +95,15 @@ var groups = []runtime.SchemeBuilder{ } func TestRoundTripExternalTypes(t *testing.T) { + scheme := runtime.NewScheme() + codecs := serializer.NewCodecFactory(scheme) for _, builder := range groups { - scheme := runtime.NewScheme() - codecs := serializer.NewCodecFactory(scheme) - require.NoError(t, builder.AddToScheme(scheme)) - seed := rand.Int63() - // I'm only using the generic fuzzer funcs, but at some point in time we might need to - // switch to specialized. For now we're happy with the current serialization test. - fuzzer := fuzzer.FuzzerFor(genericfuzzer.Funcs, rand.NewSource(seed), codecs) - - roundtrip.RoundTripExternalTypes(t, scheme, codecs, fuzzer, nil) } + seed := rand.Int63() + // I'm only using the generic fuzzer funcs, but at some point in time we might need to + // switch to specialized. For now we're happy with the current serialization test. + fuzzer := fuzzer.FuzzerFor(genericfuzzer.Funcs, rand.NewSource(seed), codecs) + + roundtrip.RoundTripExternalTypes(t, scheme, codecs, fuzzer, nil) } diff --git a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go index c3d6c7cb9e8..7aec3a8cf52 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/roundtrip.go @@ -140,13 +140,14 @@ func RoundTripExternalTypes(t *testing.T, scheme *runtime.Scheme, codecFactory r if gvk.Version == runtime.APIVersionInternal || globalNonRoundTrippableTypes.Has(gvk.Kind) { continue } - - // FIXME: this is explicitly testing w/o protobuf which was failing if enabled - // the reason for that is that protobuf is not setting Kind and APIVersion fields - // during obj2 decode, the same then applies to DecodeInto obj3. My guess is we - // should be setting these two fields accordingly when protobuf is passed as codec - // to roundTrip method. - roundTripSpecificKind(t, gvk, scheme, codecFactory, fuzzer, nonRoundTrippableTypes, true) + t.Run(gvk.Group+"."+gvk.Version+"."+gvk.Kind, func(t *testing.T) { + // FIXME: this is explicitly testing w/o protobuf which was failing if enabled + // the reason for that is that protobuf is not setting Kind and APIVersion fields + // during obj2 decode, the same then applies to DecodeInto obj3. My guess is we + // should be setting these two fields accordingly when protobuf is passed as codec + // to roundTrip method. + roundTripSpecificKind(t, gvk, scheme, codecFactory, fuzzer, nonRoundTrippableTypes, true) + }) } } @@ -163,7 +164,6 @@ func roundTripSpecificKind(t *testing.T, gvk schema.GroupVersionKind, scheme *ru t.Logf("skipping %v", gvk) return } - t.Logf("round tripping %v", gvk) // Try a few times, since runTest uses random values. for i := 0; i < *FuzzIters; i++ { @@ -250,9 +250,6 @@ func roundTripOfExternalType(t *testing.T, scheme *runtime.Scheme, codecFactory fuzzInternalObject(t, fuzzer, object) - externalGoType := reflect.TypeOf(object).PkgPath() - t.Logf("\tround tripping external type %v %v", externalGVK, externalGoType) - typeAcc.SetKind(externalGVK.Kind) typeAcc.SetAPIVersion(externalGVK.GroupVersion().String())