[BBR] test: add request plugin header mutation tests#2544
[BBR] test: add request plugin header mutation tests#2544noalimoy wants to merge 1 commit intokubernetes-sigs:mainfrom
Conversation
|
@noalimoy: The label(s) DetailsIn response to this:
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. |
✅ Deploy Preview for gateway-api-inference-extension ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: noalimoy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @noalimoy. 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 Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
/ok-to-test |
test/integration/bbr/harness.go
Outdated
| require.NoError(t, err, "failed to create body-field-to-header plugin") | ||
| runner.RequestPlugins = []framework.RequestProcessor{modelToHeaderPlugin} | ||
|
|
||
| if requestPlugins == nil { |
There was a problem hiding this comment.
is there a case this is not nil?
I see the calls in hermetic_test are always called with nil.
There was a problem hiding this comment.
Yes — in plugins_hermetic_test.go#L247, each test case passes tc.plugins (custom fakeRequestPlugin pairs) to NewBBRHarness. When nil, it falls back to the default BodyFieldToHeaderPlugin, keeping existing hermetic_test.go calls untouched.
| ) | ||
|
|
||
| // fakeRequestPlugin implements framework.RequestProcessor for integration testing. | ||
| type fakeRequestPlugin struct { |
There was a problem hiding this comment.
where is this plugin used?
There was a problem hiding this comment.
It's used in every test case in this file (plugins_hermetic_test.go#L66-L242) as tc.plugins.
each scenario creates 1–2 fakeRequestPlugin instances with different inline mutation functions to test header set/remove combinations.
{
name: "set then remove same header - cancels out",
plugins: []framework.RequestProcessor{
&fakeRequestPlugin{
name: "setter",
mutateFn: func(_ context.Context, req *framework.InferenceRequest) error {
req.SetHeader("X-Custom", "value1")
return nil
},
},
&fakeRequestPlugin{
name: "remover",
mutateFn: func(_ context.Context, req *framework.InferenceRequest) error {
req.RemoveHeader("X-Custom")
return nil
},
},
},
wantSetHeaders: map[string]string{},
wantRemoved: []string{"X-Custom"},
},
There was a problem hiding this comment.
whoops. right.
can you have a look and check why test fails?
There was a problem hiding this comment.
Yep, already fixed. The test expectations were missing BodyMutation and Content-Length added by #2551, rebased on latest main..
4e0d1a0 to
abf9024
Compare
|
/retest |
abf9024 to
e087bfe
Compare
e087bfe to
56945ba
Compare
56945ba to
c8afde7
Compare
Add unit and integration tests to verify SetHeader/RemoveHeader interactions across multiple request plugins in all combinations. Changes: - Add request_plugins_test.go with 8 unit test scenarios: set→remove, remove→set, double-remove (idempotent), set same value (no-op optimization), last-writer-wins, and mixed header operations - Add plugins_hermetic_test.go with matching 8 integration test scenarios over a real gRPC ext_proc server - Extend NewBBRHarness to accept custom request plugins (nil = default BodyFieldToHeaderPlugin) - Update bbr_success_total metric assertion to account for shared global Prometheus counter across test files Signed-off-by: noalimoy <nlimoy@redhat.com>
c8afde7 to
3658eae
Compare
|
@noalimoy: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions 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. I understand the commands that are listed here. |
|
@noalimoy can you fix failing checks? |
|
|
||
| // TestRequestPluginHeaderMutations_Unary validates header set/remove interactions | ||
| // across multiple request plugins in non-streaming (unary) mode via a real gRPC server. | ||
| func TestRequestPluginHeaderMutations_Unary(t *testing.T) { |
There was a problem hiding this comment.
feels to me like this is repeating the exact same tests from request.
I think we can remove the tests from here and use the regular hermetic tests to test the built in plugins.
| # HELP bbr_success_total [ALPHA] Count of time the request was processed successfully. | ||
| # TYPE bbr_success_total counter | ||
| bbr_success_total{} 4 | ||
| bbr_success_total{} 12 |
There was a problem hiding this comment.
I understand this is changed because 8 new tests were added in a different file.
this is very much non maintainable (a maintainer cannot reasonable figure that out).
can we move the other tests to this file?
| // TestHandleRequestBody_MultiPluginHeaderMutations tests the end-to-end behavior of | ||
| // HandleRequestBody when multiple request plugins set and/or remove headers. | ||
| // Each sub-test verifies the HeaderMutation in the resulting ProcessingResponse. | ||
| func TestHandleRequestBody_MultiPluginHeaderMutations(t *testing.T) { |
There was a problem hiding this comment.
after seeing the impl - can we move this to request_test.go?
otherwise some things are fragmented, making it very hard to follow.
There was a problem hiding this comment.
the tests themselves are great :)
|
PR needs rebase. DetailsInstructions 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. |
What type of PR is this?
/kind test
What this PR does / why we need it:
Adds unit and integration tests to verify that
SetHeader/RemoveHeaderinteractions across multiple request plugins work correctly in all combinations.TestHandleRequestBody_MultiPluginHeaderMutations— 8 unit test scenarios callingHandleRequestBodydirectly withfakeRequestPluginpairs.TestRequestPluginHeaderMutations_Unary— 8 matching integration test scenarios over a real gRPC ext_proc server.Test scenarios (8 total, mirrored in unit + integration):
Set(A)→ Plugin2:Remove(A)Set(A)→ Plugin2:Remove(B)Remove(non-existing)Remove(A)→ Plugin2:Set(A, new)Set(A, v1)→ Plugin2:Set(A, v2)Set(A)+ Plugin2:Set(B)Remove(A)→ Plugin2:Remove(A)Set(A, same_value)Which issue(s) this PR fixes:
Fixes #2526
Does this PR introduce a user-facing change?:
None