-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
add fieldmanager tests for stripFields #74207
add fieldmanager tests for stripFields #74207
Conversation
f12ffda
to
2f8e8fa
Compare
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/fieldmanager_test.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious what else we should test here? What's the important logic of fieldmanager in particular that we want to verify?
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/fieldmanager_test.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/fieldmanager_test.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/fieldmanager_test.go
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/fieldmanager_test.go
Outdated
Show resolved
Hide resolved
"metadata": { | ||
"name": "b", | ||
"namespace": "b", | ||
"creationTimestamp": "`+time.Now().UTC().Format(time.RFC3339)+`", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you don't have to build the test dynamically, which is an anti-pattern
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/fieldmanager_test.go
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/fieldmanager_test.go
Outdated
Show resolved
Hide resolved
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely happy with this yet, but I think we can merge it and improve later (it's already an improvement). I think it's very focused on "stripping the fields", which is clearly not the sole purpose of FieldManager as far as I can remember, but that's useful.
We still may want a smaller test just for testing that specific stripping functionality.
/lgtm
/approve
"apiVersion": "v1", | ||
"kind": "Deployment", | ||
"metadata": { | ||
"name": "b", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That really shouldn't happen though (applying with a different name/namespace), it might not matter in this test but that's confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, it's my only way of testing if the fields get stripped on changes. Or is there another one?
func TestApplyStripsFields(t *testing.T) { | ||
f := NewTestFieldManager(t) | ||
|
||
obj := &corev1.Pod{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if you keep this empty?
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: apelisse, kwiesmueller The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Sure, we would want even more. My goal was to get tests for strip fields first and at least create the first test setup for it. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Adds tests for FieldManager to check the stripFields functionality is working as expected.
Does this PR introduce a user-facing change?: