Documentation
¶
Overview ¶
Package testing contains - all generic API tests which depend on Kubernetes API types - all cross-Kubernetes-API tests.
Index ¶
- Variables
- func TestSelectableFieldLabelConversionsOfKind(t *testing.T, apiVersion string, kind string, fields fields.Set, ...)
- func VerifyUpdateValidationEquivalence(t *testing.T, ctx context.Context, obj, old runtime.Object, ...)
- func VerifyValidationEquivalence(t *testing.T, ctx context.Context, obj runtime.Object, validateFn ValidateFunc, ...)
- func VerifyVersionedValidationEquivalence(t *testing.T, obj, old runtime.Object, testConfigs ...ValidationTestConfig)
- type ValidateFunc
- type ValidateUpdateFunc
- type ValidationTestConfig
Constants ¶
This section is empty.
Variables ¶
var FuzzerFuncs = fuzzer.MergeFuzzerFuncs( overrideGenericFuncs, corefuzzer.Funcs, extensionsfuzzer.Funcs, appsfuzzer.Funcs, batchfuzzer.Funcs, autoscalingfuzzer.Funcs, rbacfuzzer.Funcs, policyfuzzer.Funcs, resourcefuzzer.Funcs, certificatesfuzzer.Funcs, admissionregistrationfuzzer.Funcs, storagefuzzer.Funcs, networkingfuzzer.Funcs, metafuzzer.Funcs, schedulingfuzzer.Funcs, discoveryfuzzer.Funcs, flowcontrolfuzzer.Funcs, )
FuzzerFuncs is a list of fuzzer functions
Functions ¶
func TestSelectableFieldLabelConversionsOfKind ¶ added in v1.2.0
func TestSelectableFieldLabelConversionsOfKind(t *testing.T, apiVersion string, kind string, fields fields.Set, labelMap map[string]string)
TestSelectableFieldLabelConversionsOfKind verifies that given resource have field label conversion defined for each its selectable field. fields contains selectable fields of the resource. labelMap maps deprecated labels to their canonical names.
func VerifyUpdateValidationEquivalence ¶
func VerifyUpdateValidationEquivalence(t *testing.T, ctx context.Context, obj, old runtime.Object, validateUpdateFn ValidateUpdateFunc, expectedErrs field.ErrorList, testConfigs ...ValidationTestConfig)
VerifyUpdateValidationEquivalence provides a helper for testing the migration from hand-written imperative validation to declarative validation for update operations. It ensures that the validation logic remains consistent before and after the feature is enabled.
The function operates by running the provided validation function under two scenarios:
- With DeclarativeValidation and DeclarativeValidationTakeover feature gates disabled, simulating the legacy hand-written validation.
- With both feature gates enabled, using the new declarative validation rules.
It then asserts that the validation errors produced in both scenarios are equivalent, guaranteeing a safe migration. It also checks the errors against an expected set. It compares errors by field, origin and type; all three should match to be called equivalent. It also make sure all versions of the given API returns equivalent errors.
func VerifyValidationEquivalence ¶
func VerifyValidationEquivalence(t *testing.T, ctx context.Context, obj runtime.Object, validateFn ValidateFunc, expectedErrs field.ErrorList, testConfigs ...ValidationTestConfig)
VerifyValidationEquivalence provides a helper for testing the migration from hand-written imperative validation to declarative validation. It ensures that the validation logic remains consistent before and after the feature is enabled.
The function operates by running the provided validation function under two scenarios:
- With DeclarativeValidation and DeclarativeValidationTakeover feature gates disabled, simulating the legacy hand-written validation.
- With both feature gates enabled, using the new declarative validation rules.
It then asserts that the validation errors produced in both scenarios are equivalent, guaranteeing a safe migration. It also checks the errors against an expected set. It compares errors by field, origin and type; all three should match to be called equivalent. It also make sure all versions of the given API returns equivalent errors.
func VerifyVersionedValidationEquivalence ¶ added in v1.33.0
func VerifyVersionedValidationEquivalence(t *testing.T, obj, old runtime.Object, testConfigs ...ValidationTestConfig)
VerifyVersionedValidationEquivalence tests that all versions of an API return equivalent validation errors. It accepts optional configuration to handle path normalization across API versions where structures differ.
Types ¶
type ValidateFunc ¶
ValidateFunc is a function that runs validation.
type ValidateUpdateFunc ¶
ValidateUpdateFunc is a function that runs update validation.
type ValidationTestConfig ¶
type ValidationTestConfig func(*validationOption)
func WithNormalizationRules ¶
func WithNormalizationRules(rules ...field.NormalizationRule) ValidationTestConfig
func WithSubResources ¶
func WithSubResources(subResources ...string) ValidationTestConfig