Skip to content

Conversation

Pranjali-2501
Copy link
Contributor

Partially addresses: #6113

Added TestChildPolicyChangeOnConfigUpdate and TestFailedToParseChildPolicyConfig end2end Tests in xds/clusterimpl/tests Mirroring Existing Unit Test and delete them.

RELEASE NOTES: None

Copy link

codecov bot commented Sep 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.11%. Comparing base (c4f881c) to head (2c6c732).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8616      +/-   ##
==========================================
+ Coverage   82.05%   82.11%   +0.05%     
==========================================
  Files         415      415              
  Lines       40694    40697       +3     
==========================================
+ Hits        33393    33418      +25     
+ Misses       5910     5893      -17     
+ Partials     1391     1386       -5     

see 22 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +708 to +711
Listeners: []*v3listenerpb.Listener{e2e.DefaultClientListener(serviceName, routeName)},
Routes: []*v3routepb.RouteConfiguration{e2e.DefaultRouteConfig(routeName, serviceName, clusterName)},
Clusters: []*v3clusterpb.Cluster{e2e.DefaultCluster(clusterName, endpointsName, e2e.SecurityLevelNone)},
Endpoints: []*v3endpointpb.ClusterLoadAssignment{e2e.DefaultEndpoint(endpointsName, "localhost", []uint32{testutils.ParsePort(t, server.Address)})},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to use e2e.DefaultClientResources instead?

Comment on lines +724 to +725
updatedChildPolicy := ""
var mu sync.Mutex
Copy link
Contributor

Choose a reason for hiding this comment

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

Please consider using atomic.Pointer[string] instead. You can see lot of examples of atomic.Pointer used in our codebase.

Comment on lines +734 to +737
select {
case lbCfgCh <- ccs.BalancerConfig:
default:
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please avoid non-blocking writes to channels in test. This can lead to non-determinism which can lead to flakes. Instead of the default case, use a case where you block on <-ctx.Done()

t.Fatalf("Failed to update xDS resources: %v", err)
}

// Register stub pickfirst LB policy so that we can catch config changes.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would make sense to move this definition of the stub policy to be after creation of the gRPC channel and the first RPC.

t.Fatalf("client.EmptyCall() failed: %v", err)
}

// Now update the cluster to use "pick_first" as the endpoint picking policy.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be worth documenting somewhere that the e2e.DefaultCluster configures weighted target as the load balancing policy, which results in round_robin being used.

Copy link
Contributor

Choose a reason for hiding this comment

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

But round_robin also delegates to pick_first. So, wouldn't your wrapped pick_first be used even before this update?

Comment on lines +811 to +813
// Start a server backend exposing the test service.
server := stubserver.StartTestService(t, nil)
defer server.Stop()
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to spin up a backend for this test since you don't expect the RPC to ever succeed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm ... maybe its fine to spin up the backend and include it in the endpoint resource like you do. Since you actually perform an RPC and verify that it does not succeed.

Comment on lines +815 to +830
const (
serviceName = "test-child-policy"
routeName = "route-" + serviceName
clusterName = "cluster-" + serviceName
endpointsName = "endpoints-" + serviceName
)

// Configure the xDS management server with default resources. Override the
// default cluster to include pickfirst as an LbPolicy.
resources := e2e.UpdateOptions{
NodeID: nodeID,
Listeners: []*v3listenerpb.Listener{e2e.DefaultClientListener(serviceName, routeName)},
Routes: []*v3routepb.RouteConfiguration{e2e.DefaultRouteConfig(routeName, serviceName, clusterName)},
Clusters: []*v3clusterpb.Cluster{e2e.DefaultCluster(clusterName, endpointsName, e2e.SecurityLevelNone)},
Endpoints: []*v3endpointpb.ClusterLoadAssignment{e2e.DefaultEndpoint(endpointsName, "localhost", []uint32{testutils.ParsePort(t, server.Address)})},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Can we use e2e.DefaultClientResources and save some lines of code.


client := testgrpc.NewTestServiceClient(cc)
if _, err := client.EmptyCall(ctx, &testpb.Empty{}); err == nil {
t.Fatalf("Unexpected error, got <nil> want %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

This error message is going to very confusing because err is also nil. So, something like
"EmptyCall RPC succeeded when expected to fail" would be more meaningful.

@easwars easwars assigned Pranjali-2501 and unassigned easwars Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants