-
Notifications
You must be signed in to change notification settings - Fork 596
test: add unit tests for AgentgatewayPolicy frontend field #12829
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: main
Are you sure you want to change the base?
Conversation
Add basic test coverage for AgentgatewayPolicy frontend field focusing on TCP keepalive and TLS handshake timeout configurations. This establishes the test pattern for frontend field validation. Tests verify proper translation of connection-level settings. Related to kgateway-dev#12816 Signed-off-by: thc1006 <[email protected]> Co-authored-by: SteveYi <[email protected]>
Add test coverage for HTTP protocol settings and access logging configuration in AgentgatewayPolicy frontend field. HTTP test covers both HTTP/1.1 and HTTP/2 settings including buffer sizes, header limits, window sizes, and keepalive intervals. AccessLog test validates CEL expression filtering and attribute manipulation including field removal and addition. Related to kgateway-dev#12816 Signed-off-by: thc1006 <[email protected]> Co-authored-by: SteveYi <[email protected]>
Add integration test combining multiple frontend fields and negative test for tracing field validation. Combined test verifies that TCP, TLS, and HTTP settings can be configured together on the same Gateway. This tests field-level merging behavior when multiple settings are applied. Invalid tracing test ensures CEL validation properly rejects tracing configuration as it is not yet implemented. Related to kgateway-dev#12816 Signed-off-by: thc1006 <[email protected]> Co-authored-by: SteveYi <[email protected]>
Add six unit test cases to agentgateway_translator_test.go covering all frontend policy configurations. Test cases verify translation of TCP keepalive, TLS handshake timeout, HTTP protocol settings, access log filtering, combined configurations, and invalid tracing rejection. These tests will generate golden output files when run, establishing baseline expectations for frontend policy translation behavior. This implements Task 1 (unit tests) of issue kgateway-dev#12816. Task 2 (E2E tests) will follow in a separate PR. Related to kgateway-dev#12816 Signed-off-by: thc1006 <[email protected]> Co-authored-by: SteveYi <[email protected]>
Add baseline golden output files for frontend policy unit test cases. These files establish expected translation outputs for TCP, TLS, HTTP, AccessLog configurations and combinations. Generated using REFRESH_GOLDEN=true test execution. This completes Task 1 (unit tests) of issue kgateway-dev#12816. Task 2 (E2E tests) will be addressed in a follow-up PR to maintain small, focused pull requests following the Small CL principle. Partial: kgateway-dev#12816 Signed-off-by: thc1006 <[email protected]> Co-authored-by: SteveYi <[email protected]>
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 comprehensive test coverage for frontend configuration features in the agent gateway syncer. The changes introduce six new test scenarios covering TCP keepalive, TLS handshake timeout, HTTP configuration, access log filtering, combined configurations, and invalid tracing handling.
- Adds test data files for frontend policy configurations including TCP, TLS, HTTP, and access log settings
- Adds expected output validation files for each test scenario
- Adds six new test cases to verify frontend policy translation behavior
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/kgateway/agentgatewaysyncer/testdata/inputs/frontend/tls-handshake.yaml | Input test data for TLS handshake timeout configuration |
| internal/kgateway/agentgatewaysyncer/testdata/inputs/frontend/tcp-keepalive.yaml | Input test data for TCP keepalive configuration |
| internal/kgateway/agentgatewaysyncer/testdata/inputs/frontend/invalid-tracing.yaml | Input test data for invalid tracing configuration validation |
| internal/kgateway/agentgatewaysyncer/testdata/inputs/frontend/http-config.yaml | Input test data for HTTP protocol configuration |
| internal/kgateway/agentgatewaysyncer/testdata/inputs/frontend/combined-tcp-tls-http.yaml | Input test data for combined TCP, TLS, and HTTP configurations |
| internal/kgateway/agentgatewaysyncer/testdata/inputs/frontend/accesslog-filter.yaml | Input test data for access log filter configuration |
| internal/kgateway/agentgatewaysyncer/testdata/outputs/frontend/tls-handshake.yaml | Expected output for TLS handshake test |
| internal/kgateway/agentgatewaysyncer/testdata/outputs/frontend/tls-handshake.status.yaml | Expected status output for TLS handshake test |
| internal/kgateway/agentgatewaysyncer/testdata/outputs/frontend/tcp-keepalive.yaml | Expected output for TCP keepalive test |
| internal/kgateway/agentgatewaysyncer/testdata/outputs/frontend/tcp-keepalive.status.yaml | Expected status output for TCP keepalive test |
| internal/kgateway/agentgatewaysyncer/testdata/outputs/frontend/invalid-tracing.yaml | Expected output for invalid tracing test |
| internal/kgateway/agentgatewaysyncer/testdata/outputs/frontend/invalid-tracing.status.yaml | Expected status output for invalid tracing test |
| internal/kgateway/agentgatewaysyncer/testdata/outputs/frontend/http-config.yaml | Expected output for HTTP config test |
| internal/kgateway/agentgatewaysyncer/testdata/outputs/frontend/http-config.status.yaml | Expected status output for HTTP config test |
| internal/kgateway/agentgatewaysyncer/testdata/outputs/frontend/combined-tcp-tls-http.yaml | Expected output for combined config test |
| internal/kgateway/agentgatewaysyncer/testdata/outputs/frontend/combined-tcp-tls-http.status.yaml | Expected status output for combined config test |
| internal/kgateway/agentgatewaysyncer/testdata/outputs/frontend/accesslog-filter.yaml | Expected output for access log filter test |
| internal/kgateway/agentgatewaysyncer/testdata/outputs/frontend/accesslog-filter.status.yaml | Expected status output for access log filter test |
| internal/kgateway/agentgatewaysyncer/agentgateway_translator_test.go | Adds six new test cases for frontend policy configurations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Let's change the example to test a valid tracing config to check the output xds config looks correct.
| @@ -0,0 +1,30 @@ | |||
| Addresses: | |||
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.
Missing the Policies field. Looks like the input is incorrect. (See
as an example)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.
Thanks for the contribution! The tests have right idea, but the outputs are missing the fields we want to confirm are present after translation.
Please refer to the code of conduct on AI generated code https://github.com/kgateway-dev/community/blob/main/CODE-OF-CONDUCT.md It's totally okay to use AI to help you write code, but it's important to understand what the tests are actually checking for.
Description
This PR implements Task 1 (unit tests) of issue #12816, adding comprehensive unit test coverage for the
frontendfield inAgentgatewayPolicyCRD.Task 2 (E2E tests) will be addressed in a follow-up PR to maintain small, focused pull requests following the Small CL principle.
Changes
Unit Tests Added
Test Input Files (
testdata/inputs/frontend/):tcp-keepalive.yaml- TCP keepalive configurationtls-handshake.yaml- TLS handshake timeouthttp-config.yaml- HTTP/1.1 and HTTP/2 settingsaccesslog-filter.yaml- Access log filtering with CEL expressionscombined-tcp-tls-http.yaml- Multiple frontend fields togetherinvalid-tracing.yaml- Negative test for unimplemented tracing fieldTest Cases (
agentgateway_translator_test.go):Coverage
Tests validate:
Testing
All tests pass successfully:
Related Issues
Next Steps
A follow-up PR will add E2E tests (Task 2 of #12816) following the pattern established in
test/e2e/features/backendconfigpolicy/.Change Type
/kind cleanup
Changelog
Checklist
make unit)make analyze)make verify)Note to reviewers: This PR intentionally includes only unit tests to keep the changeset small and focused. E2E tests will follow in a separate PR.