kmesh icon indicating copy to clipboard operation
kmesh copied to clipboard

Add E2E test for Locality Load Balancing

Open ravjot07 opened this issue 9 months ago • 5 comments

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 as region.zone1.subzone1.

  • Remote Instance: On node kmesh-testing-control-plane, labeled as region.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

  1. Resolution Check: Uses nslookup to resolve the FQDN of the service from within the client pod.

  2. Initial Routing: Makes curl requests to helloworld.sample.svc.cluster.local expecting responses from the local instance (region.zone1.subzone1).

  3. 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

ravjot07 avatar Mar 14 '25 23:03 ravjot07

[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.

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

kmesh-bot avatar Mar 14 '25 23:03 kmesh-bot

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 data Powered 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.

codecov[bot] avatar Mar 14 '25 23:03 codecov[bot]

/retest

hzxuzhonghu avatar Apr 07 '25 06:04 hzxuzhonghu

@ravjot07 Try to fix the comments and get this PR merged.

Get code merged is what really matters.

YaoZengzeng avatar Apr 18 '25 01:04 YaoZengzeng

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.

kmesh-bot avatar May 26 '25 11:05 kmesh-bot