-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Verify that WrapPayloadWithEnvelope is exhaustive #11454
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
base: master
Are you sure you want to change the base?
Conversation
Make sure that it covers all types with reflection.
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.
Pull request overview
This PR adds a reflection-based unit test to verify that the WrapPayloadWithEnvelope function handles all possible ToDataplane payload types, addressing the risk that new payload types might be added without updating this critical function. The PR also updates logging utilities to support benchmarks.
- Adds comprehensive test coverage for
WrapPayloadWithEnvelopeusing protobuf reflection to enumerate all payload types - Changes logging utility parameters from
*testing.Ttotesting.TBinterface to support both tests and benchmarks - Includes a benchmark to measure performance of the wrapping function
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| libcalico-go/lib/logutils/logutils.go | Updated function signatures from *testing.T to testing.TB interface to support both tests and benchmarks |
| felix/dataplane/external/ext_dataplane_test.go | Added new test file with mainline test, exhaustive payload type test using reflection, and performance benchmark |
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description
The
WrapPayloadWithEnvelopefunction is supposed to cover allToDataplanepayload types, but it's easy to forget to update it when adding one (especially when merging code to enterprise, where there are more types).Add a reflection-based UT that checks that all possible types are covered. I also experimented with replacing the function with a reflection-based one, but that was 6x slower and this is close to the critical path in some cases.
Related issues/PRs
Todos
Release Note
Reminder for the reviewer
Make sure that this PR has the correct labels and milestone set.
Every PR needs one
docs-*label.docs-pr-required: This change requires a change to the documentation that has not been completed yet.docs-completed: This change has all necessary documentation completed.docs-not-required: This change has no user-facing impact and requires no docs.Every PR needs one
release-note-*label.release-note-required: This PR has user-facing changes. Most PRs should have this label.release-note-not-required: This PR has no user-facing changes.Other optional labels:
cherry-pick-candidate: This PR should be cherry-picked to an earlier release. For bug fixes only.needs-operator-pr: This PR is related to install and requires a corresponding change to the operator.