Add E2E test for Locality Load Balancing
Overview
This PR adds an end-to-end integration test (TestLocalityLoadBalancing) for the Locality Load Balancing feature in Kmesh. The goal is to validate the PreferClose traffic distribution policy by simulating a real-world scenario with services deployed in different zones. The test ensures that:
-
Traffic from a local client is served by the closest available service instance (based on node locality).
-
When the closest instance becomes unavailable, traffic is gracefully routed to a remote instance.
Test Flow
Namespace Creation
A new namespace sample is created for the test resources.
Service Deployment
The helloworld service is deployed with:
trafficDistribution: PreferClose
Backend Deployments
Two deployments of the helloworld app are launched:
-
Local Instance: On node
kmesh-testing-worker, labeled asregion.zone1.subzone1. -
Remote Instance: On node
kmesh-testing-control-plane, labeled asregion.zone1.subzone2.
Each instance responds with its own SERVICE_VERSION.
Sleep Client Deployment
A curl-based client (sleep) is deployed on kmesh-testing-worker to simulate client-side traffic origin.
Verification
-
Resolution Check: Uses
nslookupto resolve the FQDN of the service from within the client pod. -
Initial Routing: Makes curl requests to
helloworld.sample.svc.cluster.localexpecting responses from the local instance (region.zone1.subzone1). -
Failover Simulation: Deletes the local deployment and retries the curl until a response is returned from the remote instance (
region.zone1.subzone2).
Cleanup
The test framework handles namespace and deployment cleanup automatically after test execution.
Contributes toward #1146
[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 lec-bit for approval. For more information see the Kubernetes Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 45.48%. Comparing base (
e5ead63) to head (7035aaa). Report is 6 commits behind head on main.
see 2 files with indirect coverage changes
Continue to review full report in Codecov by Sentry.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 7fc5794...7035aaa. Read the comment docs.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
/retest
@ravjot07 Try to fix the comments and get this PR merged.
Get code merged is what really matters.
Adding label do-not-merge/contains-merge-commits because PR contains merge commits, which are not allowed in this repository.
Use git rebase to reapply your commits on top of the target branch. Detailed instructions for doing so can be found here.
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/test-infra repository.