Skip to content

WIP: Add e2e test for manual GatewayAPI service#1384

Open
rikatz wants to merge 4 commits intoopenshift:masterfrom
rikatz:manual-svc-deployment
Open

WIP: Add e2e test for manual GatewayAPI service#1384
rikatz wants to merge 4 commits intoopenshift:masterfrom
rikatz:manual-svc-deployment

Conversation

@rikatz
Copy link
Copy Markdown
Member

@rikatz rikatz commented Mar 12, 2026

This PR adds an e2e test for manual service deployment on Gateway API

TODO:

  • Add a test for ClusterIP (no connection attempt, just getting the gateway programmed with the right hostname)
  • Add connectivity test for externalTrafficPolicy=local

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 12, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 12, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Review skipped — only excluded labels are configured. (1)
  • do-not-merge/work-in-progress

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: b170b394-4a6d-4c1e-a4bb-fbe0c543ab43

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new end-to-end test testGatewayAPIManualLBService() in test/e2e/gateway_api_test.go that deploys a user-managed LoadBalancer Service with externalTrafficPolicy=Local before creating a Gateway, waits for Gateway acceptance, and verifies the Service retains ExternalTrafficPolicy=Local. Registers the test in TestGatewayAPI. Adds helper createGatewayService() in test/e2e/util_gatewayapi_test.go to create or ensure the Service with retry logic and imports k8s.io/apimachinery/pkg/util/intstr for TargetPort support.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Test Structure And Quality ❓ Inconclusive Unable to access test/e2e/gateway_api_test.go file content to verify testGatewayAPIManualLBService implementation and TestGatewayAPI invocation context adherence to quality requirements. Provide the actual test file content or repository access to evaluate code quality adherence.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change—adding an e2e test for manual GatewayAPI service deployment.
Description check ✅ Passed The description is related to the changeset and explains the purpose of adding an e2e test for manual service deployment on Gateway API.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
Stable And Deterministic Test Names ✅ Passed Test name 'testGatewayAPIManualLBService' is stable and deterministic with no dynamic values, random suffixes, timestamps, or UUIDs.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.

Change the reviews.profile setting to assertive to make CodeRabbit's nitpick more issues in your PRs.

@openshift-ci openshift-ci Bot requested review from candita and rfredette March 12, 2026 22:51
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Mar 12, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign frobware for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/e2e/util_gatewayapi_test.go (1)

320-321: Fix helper docstring to match the function purpose.

The comment mentions createGatewayClass, but this helper creates a Service. Please update it to avoid confusion during maintenance.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/util_gatewayapi_test.go` around lines 320 - 321, The docstring
currently references createGatewayClass but the helper actually creates and
returns a Service; update the comment to correctly describe the helper (e.g.,
"createService" or "createTestService") and state that it creates and returns a
Service (or returns an error on failure), replacing any mentions of
createGatewayClass so the comment matches the actual function behavior and the
Service return value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/e2e/util_gatewayapi_test.go`:
- Around line 322-328: The helper createGatewayService currently omits the
Service namespace; update the function signature createGatewayService to accept
a namespace string, set svcDefinition.ObjectMeta.Namespace = namespace when
building the corev1.Service, and ensure any construction of svckey (or use of
svckey.Namespace) uses that provided namespace; also update callers of
createGatewayService to pass the intended namespace so Service creation and logs
reference the correct namespace.

---

Nitpick comments:
In `@test/e2e/util_gatewayapi_test.go`:
- Around line 320-321: The docstring currently references createGatewayClass but
the helper actually creates and returns a Service; update the comment to
correctly describe the helper (e.g., "createService" or "createTestService") and
state that it creates and returns a Service (or returns an error on failure),
replacing any mentions of createGatewayClass so the comment matches the actual
function behavior and the Service return value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 4aa055c1-29f2-4d50-83bb-ac5154786c13

📥 Commits

Reviewing files that changed from the base of the PR and between c2eae34 and 2e81523.

📒 Files selected for processing (2)
  • test/e2e/gateway_api_test.go
  • test/e2e/util_gatewayapi_test.go

Comment thread test/e2e/util_gatewayapi_test.go Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
test/e2e/gateway_api_test.go (1)

1044-1046: Acknowledged: Connection test is pending.

The TODO aligns with the WIP status and PR description which mentions adding a connectivity test for externalTrafficPolicy=Local.

Would you like me to help draft a connection test that verifies client source IP preservation with externalTrafficPolicy=Local?

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/gateway_api_test.go` around lines 1044 - 1046, Add a connection test
that verifies client source IP preservation when externalTrafficPolicy is set to
Local: create a test case (near where gatewayName and externalTrafficPolicy are
referenced) that deploys a backend pod which logs remote client IP, exposes it
via the Gateway/LoadBalancer with externalTrafficPolicy=Local, then from a
client pod send an HTTP request to the gateway address and fetch the backend's
observed source IP; assert that the observed IP matches the client pod's IP (or
falls within the node's external IP range) and fail the test if NAT is observed.
Ensure the test creates/uses gatewayName, sets externalTrafficPolicy=Local on
the Service/Gateway, polls/waits for readiness, collects backend logs or
response containing the remote IP, and performs proper cleanup.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/e2e/gateway_api_test.go`:
- Around line 958-960: The error message in the t.Fatalf call is misleading
because it prints "%s/%s" with gatewayName and gatewayClass.Name while the real
service name is constructed as "{gatewayName}-{gatewayClass}" by
createGatewayService; update the t.Fatalf invocation in the test (the line that
calls t.Fatalf("Failed to create service ...", gatewayName, gatewayClass.Name,
err)) to either compute serviceName := createGatewayService(gatewayName,
gatewayClass.Name) and log that single string (e.g. "Failed to create service
%s: %v", serviceName, err) or format the two values into the actual
"{gatewayName}-{gatewayClass}" form before passing to t.Fatalf so the message
accurately reflects the created service name.
- Around line 1007-1042: The test is polling services by metadata label but
createGatewayService only sets the gateway name in Spec.Selector; update
createGatewayService to add the gateway.networking.k8s.io/gateway-name label
into the Service.ObjectMeta.Labels (use the same gatewayName value) so
client.MatchingLabels in the polling loop and the gateway-service-dns controller
(which checks service.Labels[gatewayNameLabelKey]) will find the Service; ensure
any existing ObjectMeta.Labels map is initialized before assignment.

---

Nitpick comments:
In `@test/e2e/gateway_api_test.go`:
- Around line 1044-1046: Add a connection test that verifies client source IP
preservation when externalTrafficPolicy is set to Local: create a test case
(near where gatewayName and externalTrafficPolicy are referenced) that deploys a
backend pod which logs remote client IP, exposes it via the Gateway/LoadBalancer
with externalTrafficPolicy=Local, then from a client pod send an HTTP request to
the gateway address and fetch the backend's observed source IP; assert that the
observed IP matches the client pod's IP (or falls within the node's external IP
range) and fail the test if NAT is observed. Ensure the test creates/uses
gatewayName, sets externalTrafficPolicy=Local on the Service/Gateway,
polls/waits for readiness, collects backend logs or response containing the
remote IP, and performs proper cleanup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro

Run ID: f1ec3ee5-364b-4fb3-93f5-0d14679e14cc

📥 Commits

Reviewing files that changed from the base of the PR and between 2e81523 and 3e04ba9.

📒 Files selected for processing (2)
  • test/e2e/gateway_api_test.go
  • test/e2e/util_gatewayapi_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/e2e/util_gatewayapi_test.go

Comment on lines +958 to +960
if err != nil {
t.Fatalf("Failed to create service %s/%s: %v", gatewayName, gatewayClass.Name, err)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Misleading error message format.

The %s/%s format suggests namespace/name, but the values passed are gatewayName and gatewayClass.Name. The actual service name is {gatewayName}-{gatewayClass} per the createGatewayService helper.

Suggested fix
 	if err != nil {
-		t.Fatalf("Failed to create service %s/%s: %v", gatewayName, gatewayClass.Name, err)
+		t.Fatalf("Failed to create service %s-%s: %v", gatewayName, gatewayClass.Name, err)
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if err != nil {
t.Fatalf("Failed to create service %s/%s: %v", gatewayName, gatewayClass.Name, err)
}
if err != nil {
t.Fatalf("Failed to create service %s-%s: %v", gatewayName, gatewayClass.Name, err)
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/gateway_api_test.go` around lines 958 - 960, The error message in
the t.Fatalf call is misleading because it prints "%s/%s" with gatewayName and
gatewayClass.Name while the real service name is constructed as
"{gatewayName}-{gatewayClass}" by createGatewayService; update the t.Fatalf
invocation in the test (the line that calls t.Fatalf("Failed to create service
...", gatewayName, gatewayClass.Name, err)) to either compute serviceName :=
createGatewayService(gatewayName, gatewayClass.Name) and log that single string
(e.g. "Failed to create service %s: %v", serviceName, err) or format the two
values into the actual "{gatewayName}-{gatewayClass}" form before passing to
t.Fatalf so the message accurately reflects the created service name.

Comment thread test/e2e/gateway_api_test.go
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 17, 2026
@openshift-merge-robot
Copy link
Copy Markdown
Contributor

PR needs rebase.

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.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Mar 17, 2026

@rikatz: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-hypershift a62a251 link true /test e2e-hypershift
ci/prow/e2e-aws-ovn a62a251 link true /test e2e-aws-ovn
ci/prow/images a62a251 link true /test images
ci/prow/okd-scos-images a62a251 link true /test okd-scos-images
ci/prow/e2e-aws-ovn-upgrade a62a251 link true /test e2e-aws-ovn-upgrade
ci/prow/e2e-azure-operator a62a251 link true /test e2e-azure-operator
ci/prow/e2e-vsphere-static-metallb-operator-gwapi a62a251 link false /test e2e-vsphere-static-metallb-operator-gwapi
ci/prow/e2e-aws-ovn-hypershift-conformance a62a251 link true /test e2e-aws-ovn-hypershift-conformance
ci/prow/e2e-gcp-operator a62a251 link true /test e2e-gcp-operator
ci/prow/verify-deps a62a251 link true /test verify-deps
ci/prow/hypershift-e2e-aks a62a251 link true /test hypershift-e2e-aks
ci/prow/e2e-aws-operator a62a251 link true /test e2e-aws-operator
ci/prow/verify a62a251 link true /test verify
ci/prow/e2e-aws-ovn-serial-1of2 a62a251 link true /test e2e-aws-ovn-serial-1of2
ci/prow/e2e-aws-ovn-serial-2of2 a62a251 link true /test e2e-aws-ovn-serial-2of2

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

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

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants