Skip to content

Conversation

@thc1006
Copy link

@thc1006 thc1006 commented Nov 4, 2025

Description

This PR implements Task 1 (unit tests) of issue #12816, adding comprehensive unit test coverage for the frontend field in AgentgatewayPolicy CRD.

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 configuration
  • tls-handshake.yaml - TLS handshake timeout
  • http-config.yaml - HTTP/1.1 and HTTP/2 settings
  • accesslog-filter.yaml - Access log filtering with CEL expressions
  • combined-tcp-tls-http.yaml - Multiple frontend fields together
  • invalid-tracing.yaml - Negative test for unimplemented tracing field

Test Cases (agentgateway_translator_test.go):

  • 6 new test cases covering all frontend subfields
  • Tests verify proper translation to AgentGateway IR
  • Golden files establish baseline expectations

Coverage

Tests validate:

  • TCP keepalive settings (retries, time, interval)
  • TLS handshake timeout configuration
  • HTTP protocol settings (buffer sizes, headers, window sizes, keepalive)
  • Access log filtering and attribute manipulation
  • Combined configurations (TCP + TLS + HTTP)
  • CEL validation (invalid tracing field rejection)

Testing

All tests pass successfully:

# Unit tests
go test -v ./internal/kgateway/agentgatewaysyncer -run "TestBasic/Frontend"
# Result: PASS (all 6 tests)

# Linting
make analyze
# Result: 0 issues

# Code generation
make verify
# Result: PASS

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

NONE

Checklist

  • Tests pass locally (make unit)
  • Linting passes (make analyze)
  • Code generation verified (make verify)
  • Golden files committed
  • Follows existing test patterns
  • DCO sign-off on all commits
  • Co-author credited

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.

thc1006 and others added 5 commits November 4, 2025 21:55
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]>
Copilot AI review requested due to automatic review settings November 4, 2025 22:34
@github-actions github-actions bot added do-not-merge/description-invalid do-not-merge/kind-invalid Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/release-note-invalid Indicates that a PR should not merge because it's missing one of the release note labels. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none and removed do-not-merge/description-invalid do-not-merge/kind-invalid Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/release-note-invalid Indicates that a PR should not merge because it's missing one of the release note labels. labels Nov 4, 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 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.

Copy link
Contributor

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:
Copy link
Contributor

@npolshakova npolshakova Nov 5, 2025

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)

Copy link
Contributor

@npolshakova npolshakova left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants