Skip to content

Conversation

@fasaxc
Copy link
Member

@fasaxc fasaxc commented Nov 27, 2025

Description

The WrapPayloadWithEnvelope function is supposed to cover all ToDataplane payload 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

  • Tests
  • Documentation
  • Release note

Release Note

TBD

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.

Copilot AI review requested due to automatic review settings November 27, 2025 11:39
@fasaxc fasaxc requested a review from a team as a code owner November 27, 2025 11:39
@marvin-tigera marvin-tigera added this to the Calico v3.32.0 milestone Nov 27, 2025
@marvin-tigera marvin-tigera added release-note-required Change has user-facing impact (no matter how small) docs-pr-required Change is not yet documented labels Nov 27, 2025
@fasaxc fasaxc added docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact and removed release-note-required Change has user-facing impact (no matter how small) docs-pr-required Change is not yet documented labels Nov 27, 2025
@marvin-tigera marvin-tigera added release-note-required Change has user-facing impact (no matter how small) docs-pr-required Change is not yet documented and removed docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact labels Nov 27, 2025
Copy link
Contributor

Copilot AI left a 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 WrapPayloadWithEnvelope using protobuf reflection to enumerate all payload types
  • Changes logging utility parameters from *testing.T to testing.TB interface 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

Copy link
Contributor

Copilot AI left a 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>
@fasaxc fasaxc added docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact and removed release-note-required Change has user-facing impact (no matter how small) docs-pr-required Change is not yet documented labels Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants