-
Notifications
You must be signed in to change notification settings - Fork 44
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 ValidatingAdmissionPolicy tests for RayClusters and AppWrappers #300
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
vapb.Spec.PolicyName = "none" | ||
_, err = test.Client().Core().AdmissionregistrationV1().ValidatingAdmissionPolicyBindings().Update(test.Ctx(), vapb, metav1.UpdateOptions{}) | ||
test.Expect(err).ToNot(HaveOccurred()) | ||
time.Sleep(2 * time.Second) // Wait for the ValidatingAdmissionPolicyBinding to be updated |
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.
You should be able to use test.Eventually
here and get the VAP and check for an expected updated value
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've given this a try just now, with the debugger I can see it does find the resource to be updated with the updated value, but the tests that follow fail as if the resource had not yet been updated. Perhaps, k8s needs time to propagate these changes somewhere else too? - It seems to need an initial couple of seconds after updating the resource.
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've tried implementing:
test.Eventually(func() bool {
vapb, _ = test.Client().Core().AdmissionregistrationV1().ValidatingAdmissionPolicyBindings().Get(test.Ctx(), vapb.Name, metav1.GetOptions{})
return vapb.Spec.PolicyName == "none"
}, 5*time.Second, 2*time.Second).Should(BeTrue())
The issue found is that the 'retry' never gets executed as the updated value is found immediately to be true:
}, 5*time.Second, 2*time.Second).Should(BeTrue())
Using a sleep
is providing consistent results. - Given it's a test, perhaps this is okay.
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.
Additionally, @Bobbins228 and I looked for a status in both resources in case there was any other indicative of propagation readiness. - No indication found.
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 exactly needs to propagated?
e00f261
to
3d97c3d
Compare
3d97c3d
to
73029a8
Compare
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.
Tried out these tests a couple of times and the testing examples look sound.
I am not too sure how we can confirm that the VAP updates correctly rather than using sleep but on the testing side /lgtm
_, err = test.Client().Core().AdmissionregistrationV1().ValidatingAdmissionPolicyBindings().Update(test.Ctx(), vapb, metav1.UpdateOptions{}) | ||
test.Expect(err).ToNot(HaveOccurred()) |
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.
@Bobbins228 thanks for taking the time to test Mark!
Tried out these tests a couple of times and the testing examples look sound.
I am not too sure how we can confirm that the VAP updates correctly rather than using sleep but on the testing side /lgtm
These lines ensure that the update happens without errors. Eventhough we ensure the update does happen, the test runs so quickly that subsequent tests fail unless we allow a couple of seconds for it to 'settle'.
Description
Part of: https://issues.redhat.com/browse/RHOAIENG-14731
How Has This Been Tested?
For context, the VAP-B resources will be applied by the RHOAI Operator based on the OCP version it is installed on.
In the meantime, this can be tested by manually applying the resources:
>=v4.17
oc apply
both resources from this directorygo test -timeout 1m ./tests/odh/validating_admission_policy_test.go ./tests/odh/support.go
.Additional Thoughts:
sleeps
in the tests when updating the VAP resource to allow sufficient time for changes to take effect. Thinking of a better way.Merge criteria: