mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
Run roundtrip tests as subtests
This commit is contained in:
parent
cc10bec674
commit
0c0caefd86
@ -95,16 +95,15 @@ var groups = []runtime.SchemeBuilder{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRoundTripExternalTypes(t *testing.T) {
|
func TestRoundTripExternalTypes(t *testing.T) {
|
||||||
|
scheme := runtime.NewScheme()
|
||||||
|
codecs := serializer.NewCodecFactory(scheme)
|
||||||
for _, builder := range groups {
|
for _, builder := range groups {
|
||||||
scheme := runtime.NewScheme()
|
|
||||||
codecs := serializer.NewCodecFactory(scheme)
|
|
||||||
|
|
||||||
require.NoError(t, builder.AddToScheme(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)
|
||||||
}
|
}
|
||||||
|
@ -140,13 +140,14 @@ func RoundTripExternalTypes(t *testing.T, scheme *runtime.Scheme, codecFactory r
|
|||||||
if gvk.Version == runtime.APIVersionInternal || globalNonRoundTrippableTypes.Has(gvk.Kind) {
|
if gvk.Version == runtime.APIVersionInternal || globalNonRoundTrippableTypes.Has(gvk.Kind) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
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
|
// 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
|
// 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
|
// 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
|
// should be setting these two fields accordingly when protobuf is passed as codec
|
||||||
// to roundTrip method.
|
// to roundTrip method.
|
||||||
roundTripSpecificKind(t, gvk, scheme, codecFactory, fuzzer, nonRoundTrippableTypes, true)
|
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)
|
t.Logf("skipping %v", gvk)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
t.Logf("round tripping %v", gvk)
|
|
||||||
|
|
||||||
// Try a few times, since runTest uses random values.
|
// Try a few times, since runTest uses random values.
|
||||||
for i := 0; i < *FuzzIters; i++ {
|
for i := 0; i < *FuzzIters; i++ {
|
||||||
@ -250,9 +250,6 @@ func roundTripOfExternalType(t *testing.T, scheme *runtime.Scheme, codecFactory
|
|||||||
|
|
||||||
fuzzInternalObject(t, fuzzer, object)
|
fuzzInternalObject(t, fuzzer, object)
|
||||||
|
|
||||||
externalGoType := reflect.TypeOf(object).PkgPath()
|
|
||||||
t.Logf("\tround tripping external type %v %v", externalGVK, externalGoType)
|
|
||||||
|
|
||||||
typeAcc.SetKind(externalGVK.Kind)
|
typeAcc.SetKind(externalGVK.Kind)
|
||||||
typeAcc.SetAPIVersion(externalGVK.GroupVersion().String())
|
typeAcc.SetAPIVersion(externalGVK.GroupVersion().String())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user