Documentation ¶
Index ¶
- Variables
- func CompatibilityTestFuzzer(scheme *runtime.Scheme, fuzzFuncs []interface{}) *fuzz.Fuzzer
- func CompatibilityTestObject(scheme *runtime.Scheme, gvk schema.GroupVersionKind, fuzzFuncs []interface{}) (runtime.Object, error)
- func GlobalNonRoundTrippableTypes() sets.String
- func RoundTripExternalTypes(t *testing.T, scheme *runtime.Scheme, ...)
- func RoundTripExternalTypesWithoutProtobuf(t *testing.T, scheme *runtime.Scheme, ...)
- func RoundTripProtobufTestForAPIGroup(t *testing.T, installFn InstallFunc, fuzzingFuncs fuzzer.FuzzerFuncs)
- func RoundTripProtobufTestForScheme(t *testing.T, scheme *runtime.Scheme, fuzzingFuncs fuzzer.FuzzerFuncs)
- func RoundTripSpecificKind(t *testing.T, gvk schema.GroupVersionKind, scheme *runtime.Scheme, ...)
- func RoundTripSpecificKindWithoutProtobuf(t *testing.T, gvk schema.GroupVersionKind, scheme *runtime.Scheme, ...)
- func RoundTripTestForAPIGroup(t *testing.T, installFn InstallFunc, fuzzingFuncs fuzzer.FuzzerFuncs)
- func RoundTripTestForScheme(t *testing.T, scheme *runtime.Scheme, fuzzingFuncs fuzzer.FuzzerFuncs)
- func RoundTripTypes(t *testing.T, scheme *runtime.Scheme, ...)
- func RoundTripTypesWithoutProtobuf(t *testing.T, scheme *runtime.Scheme, ...)
- type CompatibilityTestOptions
- type InstallFunc
Constants ¶
This section is empty.
Variables ¶
var FuzzIters = flag.Int("fuzz-iters", defaultFuzzIters, "How many fuzzing iterations to do.")
Functions ¶
func CompatibilityTestFuzzer ¶
CompatibilityTestFuzzer returns a fuzzer for the given scheme: - fixed seed (deterministic output that lets us generate the same fixtures on every run) - 0 nil chance (populate all fields) - 1 numelements (populate and bound all lists) - 20 max depth (don't recurse infinitely) - meta fuzzing functions added - custom fuzzing functions to make strings and managedFields more readable in fixtures
func CompatibilityTestObject ¶
func CompatibilityTestObject(scheme *runtime.Scheme, gvk schema.GroupVersionKind, fuzzFuncs []interface{}) (runtime.Object, error)
CompatibilityTestObject returns a deterministically fuzzed object for the specified GVK
func GlobalNonRoundTrippableTypes ¶
GlobalNonRoundTrippableTypes returns the kinds that are effectively reserved across all GroupVersions. They don't roundtrip and thus can be excluded in any custom/downstream roundtrip tests
kinds := scheme.AllKnownTypes() for gvk := range kinds { if roundtrip.GlobalNonRoundTrippableTypes().Has(gvk.Kind) { continue } t.Run(gvk.Group+"."+gvk.Version+"."+gvk.Kind, func(t *testing.T) { // roundtrip test }) }
func RoundTripExternalTypes ¶
func RoundTripExternalTypes(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool)
RoundTripExternalTypes applies the round-trip test to all external round-trippable Kinds in the scheme. It will skip all the GroupVersionKinds in the nonRoundTripExternalTypes list .
func RoundTripExternalTypesWithoutProtobuf ¶
func RoundTripExternalTypesWithoutProtobuf(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool)
RoundTripExternalTypesWithoutProtobuf applies the round-trip test to all external round-trippable Kinds in the scheme. It will skip all the GroupVersionKinds in the nonRoundTripExternalTypes list.
func RoundTripProtobufTestForAPIGroup ¶
func RoundTripProtobufTestForAPIGroup(t *testing.T, installFn InstallFunc, fuzzingFuncs fuzzer.FuzzerFuncs)
RoundTripProtobufTestForAPIGroup is convenient to call from your install package to make sure that a "bare" install of your group provides enough information to round trip
func RoundTripProtobufTestForScheme ¶
func RoundTripProtobufTestForScheme(t *testing.T, scheme *runtime.Scheme, fuzzingFuncs fuzzer.FuzzerFuncs)
RoundTripProtobufTestForScheme is convenient to call if you already have a scheme and want to make sure that its well-formed
func RoundTripSpecificKind ¶
func RoundTripSpecificKind(t *testing.T, gvk schema.GroupVersionKind, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool)
func RoundTripSpecificKindWithoutProtobuf ¶
func RoundTripSpecificKindWithoutProtobuf(t *testing.T, gvk schema.GroupVersionKind, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool)
func RoundTripTestForAPIGroup ¶
func RoundTripTestForAPIGroup(t *testing.T, installFn InstallFunc, fuzzingFuncs fuzzer.FuzzerFuncs)
RoundTripTestForAPIGroup is convenient to call from your install package to make sure that a "bare" install of your group provides enough information to round trip
func RoundTripTestForScheme ¶
RoundTripTestForScheme is convenient to call if you already have a scheme and want to make sure that its well-formed
func RoundTripTypes ¶
func RoundTripTypes(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool)
func RoundTripTypesWithoutProtobuf ¶
func RoundTripTypesWithoutProtobuf(t *testing.T, scheme *runtime.Scheme, codecFactory runtimeserializer.CodecFactory, fuzzer *fuzz.Fuzzer, nonRoundTrippableTypes map[schema.GroupVersionKind]bool)
RoundTripTypesWithoutProtobuf applies the round-trip test to all round-trippable Kinds in the scheme. It will skip all the GroupVersionKinds in the skip list.
Types ¶
type CompatibilityTestOptions ¶
type CompatibilityTestOptions struct { // Scheme is used to create new objects for fuzzing, decoding, and for constructing serializers. // Required. Scheme *runtime.Scheme // TestDataDir points to a directory containing compatibility test data. // Complete() populates this with "testdata" if unset. TestDataDir string // TestDataDirCurrentVersion points to a directory containing compatibility test data for the current version. // Complete() populates this with "<TestDataDir>/HEAD" if unset. // Within this directory, `<group>.<version>.<kind>.[json|yaml|pb]` files are required to exist, and are: // * verified to match serialized FuzzedObjects[GVK] // * verified to decode without error // * verified to round-trip byte-for-byte when re-encoded // * verified to be semantically equal when decoded into memory TestDataDirCurrentVersion string // TestDataDirsPreviousVersions is a list of directories containing compatibility test data for previous versions. // Complete() populates this with "<TestDataDir>/v*" directories if nil. // Within these directories, `<group>.<version>.<kind>.[json|yaml|pb]` files are optional. If present, they are: // * verified to decode without error // * verified to round-trip byte-for-byte when re-encoded (or to match a `<group>.<version>.<kind>.[json|yaml|pb].after_roundtrip.[json|yaml|pb]` file if it exists) // * verified to be semantically equal when decoded into memory TestDataDirsPreviousVersions []string // Kinds is a list of fully qualified kinds to test. // Complete() populates this with Scheme.AllKnownTypes() if unset. Kinds []schema.GroupVersionKind // FuzzedObjects is an optional set of fuzzed objects to use for verifying HEAD fixtures. // Complete() populates this with the result of CompatibilityTestObject(Kinds[*], Scheme, FuzzFuncs) for any missing kinds. // Objects must be deterministically fuzzed and identical on every invocation. FuzzedObjects map[schema.GroupVersionKind]runtime.Object // FuzzFuncs is an optional set of custom fuzzing functions to use to construct FuzzedObjects. // They *must* not use any random source other than the passed-in fuzzer. FuzzFuncs []interface{} JSON runtime.Serializer YAML runtime.Serializer Proto runtime.Serializer }
CompatibilityTestOptions holds configuration for running a compatibility test using in-memory objects and serialized files on disk representing the current code and serialized data from previous versions.
Example use: `NewCompatibilityTestOptions(scheme).Complete(t).Run(t)`
func NewCompatibilityTestOptions ¶
func NewCompatibilityTestOptions(scheme *runtime.Scheme) *CompatibilityTestOptions
func (*CompatibilityTestOptions) Complete ¶
func (c *CompatibilityTestOptions) Complete(t *testing.T) *CompatibilityTestOptions
func (*CompatibilityTestOptions) Run ¶
func (c *CompatibilityTestOptions) Run(t *testing.T)