mirror of https://github.com/k3s-io/k3s
Run roundtrip tests as subtests
parent
cc10bec674
commit
0c0caefd86
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
Loading…
Reference in New Issue