44 Commits
Author SHA1 Message Date
Lucas KäldströmandJordan Liggitt 9327ba3797 Ignore validation errors from other API versions without specific fields
Co-authored-by: Jordan Liggitt <liggitt@google.com>
2026-10-08 19:54:21 +03:00
Yongrui Lin 7c3452f8d3 address comments: enum undefined-option check, options doc, test fallback
- enum: check every rule's option so an undefined option always errors, matching IfOption
- operation.Options: note an option can be enabled even when its feature gate is off
- api/testing: fall back to strategy options only when the caller supplied none
2026-07-14 16:43:29 +00:00
Yongrui Lin caf5bd0b70 declarative validation: declare strategy options as maps
HPA, workload, and PodGroup strategies declare their options as map[string]bool,
and the versioned validation-equivalence sweep is given each strategy's declared
options so referenced options are not treated as undeclared.
2026-07-14 16:43:29 +00:00
Lalit Chauhan 5160114ab7 apimachinery: Centralize declarative error helpers in errors.go
Add FilterCoveredHandwrittenErrors and FilterEnforcedDeclarativeErrors helpers to pkg/api/validate in a dedicated errors.go file for reuse across declarative validation pathways.
2026-07-08 20:23:15 +00:00
Yongrui Lin 4dabaebe45 api/testing: auto-discover declarative-validation GVKs in fuzz test
TestVersionedValidationByFuzzing swept a hand-maintained list of
group/versions that had a typo (network.k8s.io) and omitted several
groups (apps, policy, rbac, flowcontrol, scheduling). Replace it with a
sweep of the scheme for served GVKs that have declarative validation,
so new group/versions are covered automatically.

Skip extensions/v1beta1 centrally in VerifyVersionedValidationEquivalence
instead of via the per-call WithSkipGroupVersions option: it opts out of
declarative validation but shares an internal type with versions that do
not. Any other version missing declarative validation now fails the sweep
rather than being silently skipped.
2026-07-01 17:07:29 +00:00
Yongrui Lin ae16b61ccf Stop setting locked GA DeclarativeValidation gate in DV tests
The gate is GA and locked to true, so explicitly setting it in the
equivalence test harness only emits a 'setting GA feature gate' warning
without changing behavior. Rely on its locked default instead.
2026-06-26 21:17:13 +00:00
Lalit Chauhan ae2801a7bf Change DV test util accordingly 2026-06-24 16:29:48 +00:00
Lalit Chauhan 755ccb3dae Add objectMeta validation in the path of DV testing 2026-06-15 21:22:30 +00:00
Yongrui Lin e4cc8f8e9d testing: skip unserved extensions/v1beta1 in validation equivalence sweep
Add WithSkipGroupVersions and apply it to the NetworkPolicy and Scale tests,
whose internal types also register under the now-unvalidated extensions/v1beta1.
2026-06-11 06:35:35 +00:00
Yongrui Lin 44f6df54da Drop legacy hand-written validation subtest from pkg/api/testing
With DV always enforced, the "hand written validation" subtest (which
set DeclarativeValidation=off and emulated 1.35) now exercises the
same code path as "Beta disabled". Remove it along with the
MinEmulationVersion option, the WithMinEmulationVersion helper,
deDuplicateErrors, and the now-tautological imperative-vs-declarative
equivalence checks.
2026-05-20 18:54:07 +00:00
Yongrui Lin 16a17be014 pkg/api/testing: add VerifyUpdateValidationEquivalenceFunc
Variant of VerifyUpdateValidationEquivalence that accepts a validate
closure instead of a RESTUpdateStrategy, for callers that produce
handwritten and declarative validation errors directly.
2026-05-13 20:07:12 +00:00
Yongrui Lin 3577cbda2f pkg/api/testing: record observed rules during DV equivalence tests
VerifyValidationEquivalence's all-rules-enforced subtest now extracts
the GVK from the request context and forwards each error to
coverage.RecordObservedRules so AssertDeclarativeCoverage (in the
generated TestMain) can confirm every declared rule fired.
2026-05-09 18:59:16 +00:00
Lalit Chauhan a1a5b10127 Address comments 2026-05-02 00:09:59 +00:00
Lalit Chauhan 68ad19102c Fix testing utils 2026-05-02 00:09:59 +00:00
Joe Betz 1fafa91da4 Consolidate DeclarativeValidationStrategy interface 2026-04-27 19:26:25 -04:00
Joe Betz 30c76c1879 Make declarative validation part of strategies 2026-04-24 12:00:41 -04:00
yongruilin 9454a3069b Add WithMinEmulationVersion option to skip hand-written validation sub-test
When a test enables a feature gate introduced after 1.35, the "hand
written validation" sub-test fails because SetFeatureGateEmulationVersionDuringTest
cannot downgrade to 1.35 for features that did not exist at that version.
This adds a WithMinEmulationVersion option so callers can declare the
minimum supported emulation version and skip the sub-test when incompatible.
2026-02-26 21:36:40 +00:00
Your Name 3b5298f0a4 Fix resource claim DV 2026-02-24 18:36:47 +00:00
Your Name 12a6d300c6 Change strategy.go utils to mark handwritten validation errors properly 2026-02-24 18:33:14 +00:00
yongruilin 33dec2246f address feedback: refactor declarative validation migration checks
- Extract HV error filtering into filterHandwrittenErrors for readability.
- Simplify errOutputMatcherByStability initialization in testing helpers.
2026-02-13 00:54:18 +00:00
yongruilin 93b901d177 Enhance validation testing: add support for all declarative rules enforcement 2026-02-13 00:54:18 +00:00
yongruilin 4f56a298cc Enforce zero mismatches in validation equivalence testing 2026-02-13 00:54:18 +00:00
yongruilin 2ef358870a Update validation equivalence testing for lifecycle enforcement
- Test scenarios: Beta Enabled, Beta Disabled, and Legacy (emulated 1.35).
- Remove deprecated Takeover gate references and redundant coverage checks.
- Add TODO to remove legacy emulation in 1.39.
- Update documentation to match the new Validation Lifecycle strategy.
2026-02-13 00:54:18 +00:00
Kubernetes Prow Robot c8e45a3331 Merge pull request #136620 from yongruilin/master_vg-fix-fuzz
fix DeclarativeValidation fuzzing test panic and refactor subresource handlin
2026-01-30 03:08:04 +05:30
yongruilin 64140b8385 fuzz internal objects in versioned validation tests
Fuzzing must be performed on the internal version of objects because
custom fuzzing functions are typically registered for internal types.
This ensures that all fields are properly initialized with random values
before being converted to various API versions for validation.

Move fuzzing logic into VerifyVersionedValidationEquivalence via a new
WithFuzzer option. This also fixes a panic that occurred when attempting
to fuzz types without an internal version (e.g., APIGroupList) by adding
a nil check after internal conversion.
2026-01-29 10:29:55 +00:00
Aaron Prindle 0cab277183 Graduate DeclarativeValidation feature gate to GA
This change graduates the 'DeclarativeValidation' feature gate to GA in v1.36.
The feature gate is now locked to 'true' by default.

Changes:
- Updated 'DeclarativeValidation' feature gate to GA in 'pkg/features/kube_features.go' and 'staging/src/k8s.io/apiserver/pkg/features/kube_features.go'.
- Updated feature gate documentation and versioned lists via 'hack/update-featuregates.sh'.
- Added feature gate emulation versioning to tests that explicitly disable 'DeclarativeValidation' to prevent panics now that the gate is locked to default.
2026-01-29 05:38:20 +00:00
Lalit Chauhan c3fecccd3e Make sure errors present in declarative validation test files are DV errors 2026-01-15 17:42:02 +00:00
Lalit Chauhan 4e6aafb9b3 Address feedbacks 2026-01-06 18:38:35 +00:00
Lalit Chauhan e83723ce2c Add ignoreConversionErrors option to validation testing
This commit adds an 'IgnoreObjectConversionErrors' option to the
validation testing framework in 'k8s.io/apimachinery' and exposes it
via 'pkg/api/testing'.

This is useful for fuzzing tests where we might want to skip object
versions that cannot be converted from the internal version (e.g. due to
missing fields or incompatible types in older versions) but still want
to test validation for the versions that *can* be converted.

The 'autoscaling' group versions are added to 'TestVersionedValidationByFuzzing'
with this option enabled.
2026-01-06 18:23:26 +00:00
Lalit Chauhan ee481b97e0 fix sorting logic after after normalizing errors 2025-11-06 06:17:49 +00:00
Aaron Prindle 9d83f71cde fix validation_test.go to use path normalization 2025-10-16 17:40:19 +00:00
Kubernetes Prow Robot db63a581ca Merge pull request #134366 from tallclair/feature-gates-test
Set multiple feature gates simultaneously in test
2025-10-13 13:11:33 -07:00
yongruilin 6965075ebd Address feedback: simpliy errormatcher instantiation 2025-10-06 17:54:03 +00:00
yongruilin ae8ea8994e feat(validation): Enhance validation tests with normalization rules support 2025-10-04 03:28:52 +00:00
Tim Allclair 4986abe0b8 Automated refactoring to use SetFeatureGatesDuringTest 2025-10-01 21:10:53 -07:00
yongruilin 96349a4608 chore: Move declarative validation featuregates to staging apiserver 2025-09-26 22:30:16 +00:00
Lalit Chauhan 3015e58e40 Improve tests devex for DV tests. 2025-09-25 17:29:30 +00:00
Lalit Chauhan f5cd1a1664 Address tests grouping comment 2025-09-16 17:20:17 +00:00
Lalit Chauhan 92dcd02459 Add helpers for declarative validation tests
Introduces new testing helpers to simplify testing of declarative validation rules. The new `VerifyValidationEquivalence` and `VerifyUpdateValidationEquivalence` functions reduce boilerplate by encapsulating the logic for:

- Toggling the `DeclarativeValidation` and `DeclarativeValidationTakeover` feature gates.
- Comparing the validation output from the imperative and declarative paths.

The declarative validation tests for CertificateSigningRequest and ReplicationController are updated to use these new, simpler helpers.
2025-09-16 16:57:21 +00:00
yongruilin a55318fe14 fix: versioned validation test avoid incorrect conversion 2025-06-30 23:11:49 +00:00
Joe Betz 5013938100 Change option to a slice 2025-06-05 18:24:06 -04:00
Joe Betz 9715c90b31 Clarify errors and improve tests 2025-05-23 21:47:09 -04:00
Joe Betz 7dc8660d03 Update testing to fully track subresources 2025-05-23 21:47:08 -04:00
Tim Hockin 1d365762a5 Introduce versioned validation test utilitizes and add fuzz tester
This makes a bold assumption: that the errors (count and basic content)
will be the same across versions.  If this turns out to be untrue, this
may need to get more sophisticated.  It should fail obviously when we
hit that edge.
2025-03-11 20:37:21 -04:00