Skip to content

test(envoy): add missing unit tests for envoy util functions#2529

Merged
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
yehuditkerido:tests/add-missing-envoy-util-functions-tests
Mar 12, 2026
Merged

test(envoy): add missing unit tests for envoy util functions#2529
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
yehuditkerido:tests/add-missing-envoy-util-functions-tests

Conversation

@yehuditkerido
Copy link
Copy Markdown
Contributor

@yehuditkerido yehuditkerido commented Mar 9, 2026

What type of PR is this?

/kind test

What this PR does / why we need it:

Add missing unit tests for GenerateHeadersMutation and SortSetHeadersInResponses — two envoy util functions that were recently added without test coverage.

  • TestGenerateHeadersMutation — 4 cases covering empty map, single header, multiple headers (with sort for map non-determinism), and empty value.
  • TestSortSetHeadersInResponses — 9 cases covering nil safety, RequestHeaders/RequestBody sorting, single header skip, unknown response type skip, nil HeaderMutation, and mixed response types.

Which issue(s) this PR fixes:

Fixes #2528

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@yehuditkerido: The label(s) kind/test cannot be applied, because the repository doesn't have them.

Details

In response to this:

What type of PR is this?

/kind test

What this PR does / why we need it:

Add missing unit tests for GenerateHeadersMutation and SortSetHeadersInResponses — two envoy util functions that were recently added without test coverage.

  • TestGenerateHeadersMutation — 4 cases covering empty map, single header, multiple headers (with sort for map non-determinism), and empty value.
  • TestSortSetHeadersInResponses — 9 cases covering nil safety, RequestHeaders/RequestBody sorting, single header skip, unknown response type skip, nil HeaderMutation, and mixed response types.

Which issue(s) this PR fixes:

Fixes #2528

Does this PR introduce a user-facing change?:

NONE

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Mar 9, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 9, 2026

Deploy Preview for gateway-api-inference-extension ready!

Name Link
🔨 Latest commit 5e15ff5
🔍 Latest deploy log https://app.netlify.com/projects/gateway-api-inference-extension/deploys/69b2b896983a6c0008f4cc27
😎 Deploy Preview https://deploy-preview-2529--gateway-api-inference-extension.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot requested review from robscott and shmuelk March 9, 2026 13:39
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 9, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @yehuditkerido. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 9, 2026
@nirrozenbaum
Copy link
Copy Markdown
Contributor

@yehuditkerido can you please fix the invalid commit?
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 9, 2026
@yehuditkerido yehuditkerido force-pushed the tests/add-missing-envoy-util-functions-tests branch from ef6d255 to 1ffdcca Compare March 10, 2026 06:34
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. labels Mar 10, 2026
Copy link
Copy Markdown
Contributor

@nirrozenbaum nirrozenbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yehuditkerido thanks, overall looks good.
left few minor comments, also needs to rebase :)

@@ -82,6 +85,89 @@ func TestExtractHeaderValue(t *testing.T) {
}
}

func TestGenerateHeadersMutation(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is great

Comment thread pkg/common/envoy/test/utils_test.go
Comment thread pkg/common/envoy/test/utils_test.go Outdated
},
},
{
name: "RequestBody response with unsorted headers gets sorted",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this test needed considering the previous one? isn't it testing the same?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each one tests a different case branch in the type switch — RequestHeaders vs RequestBody — so they cover different code paths. But since the "multiple response objects" test already uses both, I will remove this one.

Comment thread pkg/common/envoy/test/utils_test.go Outdated
},
},
{
name: "unknown response type is skipped",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an is an unknown response?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a response type that the function doesn't handle in its type switch. Renamed the test to make it clearer.

Comment thread pkg/common/envoy/test/utils_test.go Outdated
},
},
{
name: "mixed response types sorted independently",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't say this is response types, maybe response objects?

Suggested change
name: "mixed response types sorted independently",
name: "multiple response objects are sorted independently",

@yehuditkerido yehuditkerido force-pushed the tests/add-missing-envoy-util-functions-tests branch 2 times, most recently from a63cbc4 to 47c251a Compare March 12, 2026 11:52
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 12, 2026
Comment thread pkg/common/envoy/test/utils_test.go Outdated
Comment on lines +133 to +136
name: "unhandled response type is skipped",
responses: []*extProcPb.ProcessingResponse{
{
Response: &extProcPb.ProcessingResponse_ResponseHeaders{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhhh now got it. it's a ResponseHeaders.
thanks for clarifying.
I actually think we should update the test util function to cover that as well. how do we compare responses today in the tests for response pugins?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today tests are working since ResponseHeader is with single header so no sorting needed. Added ResponseHeaders and ResponseBody cases to the type switch, with tests for both. The "unhandled" test now uses ResponseTrailers instead.

…adersInResponses

These envoy util functions lacked test coverage. Add 13 table-driven
test cases covering edge cases like nil safety, empty inputs, map
iteration non-determinism, and mixed response types.

Signed-off-by: Yehudit Kerido <yehudit1987@gmail.com>
@yehuditkerido yehuditkerido force-pushed the tests/add-missing-envoy-util-functions-tests branch from 47c251a to 5e15ff5 Compare March 12, 2026 12:58
Copy link
Copy Markdown
Contributor

@nirrozenbaum nirrozenbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

Thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 12, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nirrozenbaum, yehuditkerido

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 12, 2026
@k8s-ci-robot k8s-ci-robot merged commit 1839e85 into kubernetes-sigs:main Mar 12, 2026
11 checks passed
@yehuditkerido yehuditkerido deleted the tests/add-missing-envoy-util-functions-tests branch March 12, 2026 14:04
BizerNotNull pushed a commit to BizerNotNull/gateway-api-inference-extension that referenced this pull request Mar 15, 2026
…adersInResponses (kubernetes-sigs#2529)

These envoy util functions lacked test coverage. Add 13 table-driven
test cases covering edge cases like nil safety, empty inputs, map
iteration non-determinism, and mixed response types.

Signed-off-by: Yehudit Kerido <yehudit1987@gmail.com>
elevran pushed a commit to llm-d/llm-d-inference-scheduler that referenced this pull request Apr 23, 2026
…adersInResponses (kubernetes-sigs/gateway-api-inference-extension#2529)

These envoy util functions lacked test coverage. Add 13 table-driven
test cases covering edge cases like nil safety, empty inputs, map
iteration non-determinism, and mixed response types.

Signed-off-by: Yehudit Kerido <yehudit1987@gmail.com>
nirrozenbaum pushed a commit to llm-d/llm-d-inference-payload-processor that referenced this pull request Apr 28, 2026
…adersInResponses (kubernetes-sigs/gateway-api-inference-extension#2529)

These envoy util functions lacked test coverage. Add 13 table-driven
test cases covering edge cases like nil safety, empty inputs, map
iteration non-determinism, and mixed response types.

Signed-off-by: Yehudit Kerido <yehudit1987@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add missing unit-tests in envoy util functions

3 participants