Skip to content

Conversation

@arkodg
Copy link
Contributor

@arkodg arkodg commented Dec 14, 2025

What type of PR is this?
/kind test
/area conformance-test

What this PR does / why we need it:

add a conformance test for cookie based session persistence

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

Added a conformance test for cookie based session persistence

Copilot AI review requested due to automatic review settings December 14, 2025 05:02
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/test area/conformance-test Issues or PRs related to Conformance tests. labels Dec 14, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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 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 Dec 14, 2025
@arkodg
Copy link
Contributor Author

arkodg commented Dec 14, 2025

tested with Envoy Gateway and it successfully passes

Copy link

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 a conformance test for cookie-based session persistence in HTTPRoute, ensuring that requests with the same session cookie are consistently routed to the same backend pod. The implementation includes a new feature flag, test logic, YAML manifest, and documentation for running the test with Envoy Gateway.

Key Changes

  • Introduces SupportHTTPRouteSessionPersistenceCookie feature flag marked as experimental
  • Implements test logic that verifies cookie-based session stickiness across 10 consecutive requests
  • Adds example command for running the new test against Envoy Gateway

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
pkg/features/httproute.go Adds the SupportHTTPRouteSessionPersistenceCookie feature flag and metadata with experimental channel, integrates it into HTTPRouteExtendedFeatures
conformance/tests/httproute-session-persistence-cookie.go Implements the conformance test that verifies cookie-based session persistence by checking that subsequent requests with the same cookie route to the same pod
conformance/tests/httproute-session-persistence-cookie.yaml Defines the HTTPRoute manifest with session persistence configuration using Cookie type and Session lifetime
hack/implementations/envoy-gateway/README.md Updates documentation with example command for running the session persistence conformance test

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// This option indicates support for HTTPRoute additional redirect status code 303 (extended conformance)
SupportHTTPRoute307RedirectStatusCode FeatureName = "HTTPRoute307RedirectStatusCode"

// This option indicates support for HTTPRoute additional redirect status code 303 (extended conformance)
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

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

The comment for SupportHTTPRoute308RedirectStatusCode incorrectly states "redirect status code 303" when it should state "redirect status code 308". This appears to be a copy-paste error from line 107.

Suggested change
// This option indicates support for HTTPRoute additional redirect status code 303 (extended conformance)
// This option indicates support for HTTPRoute additional redirect status code 308 (extended conformance)

Copilot uses AI. Check for mistakes.
for i := 0; i < 10; i++ {
cReq, cRes, err := suite.RoundTripper.CaptureRoundTrip(req)
if err != nil {
t.Fatalf("request %d with cookie failed: %v", i+1, err)
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

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

The error message says "request %d with cookie failed" but on the first iteration (i=0), the cookie hasn't been set yet. The error message should be more accurate, perhaps "request %d failed" and only mention the cookie in subsequent iterations after i > 0.

Suggested change
t.Fatalf("request %d with cookie failed: %v", i+1, err)
if i == 0 {
t.Fatalf("request %d failed: %v", i+1, err)
} else {
t.Fatalf("request %d with cookie failed: %v", i+1, err)
}

Copilot uses AI. Check for mistakes.
t.Fatalf("request %d with cookie failed: %v", i+1, err)
}
if err := http.CompareRoundTrip(t, &req, cReq, cRes, expected); err != nil {
t.Fatalf("request %d with cookie failed expectations: %v", i+1, err)
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

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

The error message says "request %d with cookie failed expectations" but on the first iteration (i=0), the cookie hasn't been set yet. The error message should be more accurate, perhaps "request %d failed expectations" and only mention the cookie in subsequent iterations after i > 0.

Suggested change
t.Fatalf("request %d with cookie failed expectations: %v", i+1, err)
if i == 0 {
t.Fatalf("request %d failed expectations: %v", i+1, err)
} else {
t.Fatalf("request %d with cookie failed expectations: %v", i+1, err)
}

Copilot uses AI. Check for mistakes.

req := http.MakeRequest(t, &expected, gwAddr, "HTTP", "http")
initialPod := ""
for i := 0; i < 10; i++ {
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

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

The test uses a hardcoded value of 10 iterations to verify session persistence. Consider extracting this as a named constant at the package or function level (e.g., const numSessionPersistenceRequests = 10) to make it easier to understand the test's intent and allow for easier modification if needed.

Copilot uses AI. Check for mistakes.
Comment on lines +99 to +104
parser := &stdhttp.Response{Header: stdhttp.Header(headers)}
cookies := parser.Cookies()
if len(cookies) == 0 {
return nil, fmt.Errorf("cookie not found: headers: %v", headers)
}
return cookies[0], nil
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

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

The parseCookie function returns the first cookie from the response without verifying that it's the session persistence cookie. If the backend sets multiple cookies (e.g., tracking cookies, CSRF tokens, etc.), this function might return the wrong cookie. Consider either: 1) validating that the returned cookie has expected characteristics (e.g., specific name pattern), 2) iterating through cookies to find one that matches session persistence criteria, or 3) documenting the assumption that the first cookie is always the session persistence cookie.

Suggested change
parser := &stdhttp.Response{Header: stdhttp.Header(headers)}
cookies := parser.Cookies()
if len(cookies) == 0 {
return nil, fmt.Errorf("cookie not found: headers: %v", headers)
}
return cookies[0], nil
const sessionCookieName = "session-persistence"
parser := &stdhttp.Response{Header: stdhttp.Header(headers)}
cookies := parser.Cookies()
if len(cookies) == 0 {
return nil, fmt.Errorf("cookie not found: headers: %v", headers)
}
for _, cookie := range cookies {
if cookie.Name == sessionCookieName {
return cookie, nil
}
}
return nil, fmt.Errorf("session persistence cookie %q not found: headers: %v", sessionCookieName, headers)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/conformance-test Issues or PRs related to Conformance tests. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/test release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

2 participants