Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use test-only API types for tests that depend on API graduations #129311

Open
jpbetz opened this issue Dec 19, 2024 · 2 comments
Open

Use test-only API types for tests that depend on API graduations #129311

jpbetz opened this issue Dec 19, 2024 · 2 comments
Labels
sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@jpbetz
Copy link
Contributor

jpbetz commented Dec 19, 2024

#128279 (comment) and https://github.com/kubernetes/kubernetes/pull/128279/files?diff=unified&w=1#r1882520074 broke when bumping the master branch to 1.33 due to tests that depend on buildin APIs that meet specific graduation criteria of what is being tested, and stop working once the minor version of kubernetes increased to the point that the criteria falls out of our support/emulation windows.

We should instead modify these tests to depend on a test-only API that will stay valid forever, and don't depend on the k8s minor version.

This should be feasible to do. Here's an existing test that has some test-only APIs that we could crib from:

testAPI := func(gv schema.GroupVersion) APIGroupInfo {
getter, noVerbs := testGetterStorage{}, testNoVerbsStorage{}
scheme := runtime.NewScheme()
scheme.AddKnownTypeWithName(gv.WithKind("Getter"), getter.New())
scheme.AddKnownTypeWithName(gv.WithKind("NoVerb"), noVerbs.New())
scheme.AddKnownTypes(v1GroupVersion, &metav1.Status{})
metav1.AddToGroupVersion(scheme, v1GroupVersion)
return APIGroupInfo{
PrioritizedVersions: []schema.GroupVersion{gv},
VersionedResourcesStorageMap: map[string]map[string]rest.Storage{
gv.Version: {
"getter": &testGetterStorage{Version: gv.Version},
"noverbs": &testNoVerbsStorage{Version: gv.Version},
},
},
OptionsExternalVersion: &schema.GroupVersion{Version: "v1"},
ParameterCodec: parameterCodec,
NegotiatedSerializer: codecs,
Scheme: scheme,
}
}
apis := []APIGroupInfo{
testAPI(schema.GroupVersion{Group: "", Version: "v1"}),
testAPI(schema.GroupVersion{Group: extensionsGroupName, Version: "v1"}),
testAPI(schema.GroupVersion{Group: "batch", Version: "v1"}),
}

/sig api-machinery
/cc @Jefftree @siyuanfoundation @liggitt

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 19, 2024
@jpbetz
Copy link
Contributor Author

jpbetz commented Dec 19, 2024

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 19, 2024
@jpbetz
Copy link
Contributor Author

jpbetz commented Dec 19, 2024

c @BenTheElder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

2 participants