diff --git a/xds/internal/balancer/clusterresolver/e2e_test/balancer_test.go b/xds/internal/balancer/clusterresolver/e2e_test/balancer_test.go index 29928be21086..82145c737d46 100644 --- a/xds/internal/balancer/clusterresolver/e2e_test/balancer_test.go +++ b/xds/internal/balancer/clusterresolver/e2e_test/balancer_test.go @@ -276,9 +276,11 @@ func (s) TestErrorFromParentLB_ResourceNotFound(t *testing.T) { t.Fatalf("RPCs did not fail after removal of Cluster resource") } - // Ensure that the ClientConn is in TransientFailure. - if state := cc.GetState(); state != connectivity.TransientFailure { - t.Fatalf("Unexpected connectivity state for ClientConn, got: %s, want %s", state, connectivity.TransientFailure) + // Ensure that the ClientConn moves to TransientFailure. + for state := cc.GetState(); state != connectivity.TransientFailure; state = cc.GetState() { + if !cc.WaitForStateChange(ctx, state) { + t.Fatalf("Timed out waiting for state change. got %v; want %v", state, connectivity.TransientFailure) + } } // Configure cluster and endpoints resources in the management server.