Skip to content

Commit f24b4c7

Browse files
authored
clusterresolver: remove redundant tests (#6388)
1 parent a9c7942 commit f24b4c7

File tree

3 files changed

+0
-242
lines changed

3 files changed

+0
-242
lines changed

xds/internal/balancer/clusterresolver/clusterresolver_test.go

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -240,84 +240,6 @@ func (s) TestSubConnStateChange(t *testing.T) {
240240
}
241241
}
242242

243-
// Given a list of resource names, verifies that EDS requests for the same are
244-
// sent by the EDS balancer, through the fake xDS client.
245-
func verifyExpectedRequests(ctx context.Context, fc *fakeclient.Client, resourceNames ...string) error {
246-
for _, name := range resourceNames {
247-
if name == "" {
248-
// ResourceName empty string indicates a cancel.
249-
if _, err := fc.WaitForCancelEDSWatch(ctx); err != nil {
250-
return fmt.Errorf("timed out when expecting resource %q", name)
251-
}
252-
continue
253-
}
254-
255-
resName, err := fc.WaitForWatchEDS(ctx)
256-
if err != nil {
257-
return fmt.Errorf("timed out when expecting resource %q, %p", name, fc)
258-
}
259-
if resName != name {
260-
return fmt.Errorf("got EDS request for resource %q, expected: %q", resName, name)
261-
}
262-
}
263-
return nil
264-
}
265-
266-
// TestClientWatchEDS verifies that the xdsClient inside the top-level EDS LB
267-
// policy registers an EDS watch for expected resource upon receiving an update
268-
// from gRPC.
269-
func (s) TestClientWatchEDS(t *testing.T) {
270-
edsLBCh := testutils.NewChannel()
271-
xdsC, cleanup := setup(edsLBCh)
272-
defer cleanup()
273-
274-
builder := balancer.Get(Name)
275-
edsB := builder.Build(newNoopTestClientConn(), balancer.BuildOptions{})
276-
if edsB == nil {
277-
t.Fatalf("builder.Build(%s) failed and returned nil", Name)
278-
}
279-
defer edsB.Close()
280-
281-
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
282-
defer cancel()
283-
// If eds service name is not set, should watch for cluster name.
284-
if err := edsB.UpdateClientConnState(balancer.ClientConnState{
285-
ResolverState: xdsclient.SetClient(resolver.State{}, xdsC),
286-
BalancerConfig: newLBConfigWithOneEDS("cluster-1"),
287-
}); err != nil {
288-
t.Fatal(err)
289-
}
290-
if err := verifyExpectedRequests(ctx, xdsC, "cluster-1"); err != nil {
291-
t.Fatal(err)
292-
}
293-
294-
// Update with an non-empty edsServiceName should trigger an EDS watch for
295-
// the same.
296-
if err := edsB.UpdateClientConnState(balancer.ClientConnState{
297-
ResolverState: xdsclient.SetClient(resolver.State{}, xdsC),
298-
BalancerConfig: newLBConfigWithOneEDS("foobar-1"),
299-
}); err != nil {
300-
t.Fatal(err)
301-
}
302-
if err := verifyExpectedRequests(ctx, xdsC, "", "foobar-1"); err != nil {
303-
t.Fatal(err)
304-
}
305-
306-
// Also test the case where the edsServerName changes from one non-empty
307-
// name to another, and make sure a new watch is registered. The previously
308-
// registered watch will be cancelled, which will result in an EDS request
309-
// with no resource names being sent to the server.
310-
if err := edsB.UpdateClientConnState(balancer.ClientConnState{
311-
ResolverState: xdsclient.SetClient(resolver.State{}, xdsC),
312-
BalancerConfig: newLBConfigWithOneEDS("foobar-2"),
313-
}); err != nil {
314-
t.Fatal(err)
315-
}
316-
if err := verifyExpectedRequests(ctx, xdsC, "", "foobar-2"); err != nil {
317-
t.Fatal(err)
318-
}
319-
}
320-
321243
func newLBConfigWithOneEDS(edsServiceName string) *LBConfig {
322244
return &LBConfig{
323245
DiscoveryMechanisms: []DiscoveryMechanism{{

xds/internal/balancer/clusterresolver/priority_test.go

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -832,108 +832,3 @@ func (s) TestEDSPriority_FirstPriorityRemoved(t *testing.T) {
832832
t.Fatal(err)
833833
}
834834
}
835-
836-
// Watch resources from EDS and DNS, with EDS as the higher priority. Lower
837-
// priority is used when higher priority is not ready.
838-
func (s) TestFallbackToDNS(t *testing.T) {
839-
const testDNSEndpointAddr = "3.1.4.1:5"
840-
// dnsTargetCh, dnsCloseCh, resolveNowCh, dnsR, cleanup := setupDNS()
841-
dnsTargetCh, _, resolveNowCh, dnsR, cleanupDNS := setupDNS()
842-
defer cleanupDNS()
843-
edsb, cc, xdsC, cleanup := setupTestEDS(t, nil)
844-
defer cleanup()
845-
846-
if err := edsb.UpdateClientConnState(balancer.ClientConnState{
847-
BalancerConfig: &LBConfig{
848-
DiscoveryMechanisms: []DiscoveryMechanism{
849-
{
850-
Type: DiscoveryMechanismTypeEDS,
851-
Cluster: testClusterName,
852-
},
853-
{
854-
Type: DiscoveryMechanismTypeLogicalDNS,
855-
DNSHostname: testDNSTarget,
856-
},
857-
},
858-
xdsLBPolicy: *wrrLocalityLBConfig,
859-
},
860-
}); err != nil {
861-
t.Fatal(err)
862-
}
863-
864-
ctx, ctxCancel := context.WithTimeout(context.Background(), defaultTestTimeout)
865-
defer ctxCancel()
866-
select {
867-
case target := <-dnsTargetCh:
868-
if diff := cmp.Diff(target, resolver.Target{Scheme: "dns", URL: *testutils.MustParseURL("dns:///" + testDNSTarget)}); diff != "" {
869-
t.Fatalf("got unexpected DNS target to watch, diff (-got, +want): %v", diff)
870-
}
871-
case <-ctx.Done():
872-
t.Fatal("Timed out waiting for building DNS resolver")
873-
}
874-
875-
// One locality with one backend.
876-
clab1 := xdstestutils.NewClusterLoadAssignmentBuilder(testClusterNames[0], nil)
877-
clab1.AddLocality(testSubZones[0], 1, 0, testEndpointAddrs[:1], nil)
878-
xdsC.InvokeWatchEDSCallback("", parseEDSRespProtoForTesting(clab1.Build()), nil)
879-
880-
// Also send a DNS update, because the balancer needs both updates from all
881-
// resources to move on.
882-
dnsR.UpdateState(resolver.State{Addresses: []resolver.Address{{Addr: testDNSEndpointAddr}}})
883-
884-
addrs0 := <-cc.NewSubConnAddrsCh
885-
if got, want := addrs0[0].Addr, testEndpointAddrs[0]; got != want {
886-
t.Fatalf("sc is created with addr %v, want %v", got, want)
887-
}
888-
sc0 := <-cc.NewSubConnCh
889-
890-
// p0 is ready.
891-
edsb.UpdateSubConnState(sc0, balancer.SubConnState{ConnectivityState: connectivity.Connecting})
892-
edsb.UpdateSubConnState(sc0, balancer.SubConnState{ConnectivityState: connectivity.Ready})
893-
894-
// Test roundrobin with only p0 subconns.
895-
if err := cc.WaitForRoundRobinPicker(ctx, sc0); err != nil {
896-
t.Fatal(err)
897-
}
898-
899-
// Turn down 0, p1 (DNS) will be used.
900-
edsb.UpdateSubConnState(sc0, balancer.SubConnState{ConnectivityState: connectivity.TransientFailure})
901-
902-
// The transient failure above should not trigger a re-resolve to the DNS
903-
// resolver. Need to read to clear the channel, to avoid potential deadlock
904-
// writing to the channel later.
905-
shortCtx, shortCancel := context.WithTimeout(context.Background(), defaultTestShortTimeout)
906-
defer shortCancel()
907-
select {
908-
case <-resolveNowCh:
909-
t.Fatal("unexpected re-resolve trigger by transient failure from EDS endpoint")
910-
case <-shortCtx.Done():
911-
}
912-
913-
// The addresses used to create new SubConn should be the DNS endpoint.
914-
addrs1 := <-cc.NewSubConnAddrsCh
915-
if got, want := addrs1[0].Addr, testDNSEndpointAddr; got != want {
916-
t.Fatalf("sc is created with addr %v, want %v", got, want)
917-
}
918-
sc1 := <-cc.NewSubConnCh
919-
edsb.UpdateSubConnState(sc1, balancer.SubConnState{ConnectivityState: connectivity.Connecting})
920-
edsb.UpdateSubConnState(sc1, balancer.SubConnState{ConnectivityState: connectivity.Ready})
921-
922-
// Test pick with 1.
923-
if err := cc.WaitForRoundRobinPicker(ctx, sc1); err != nil {
924-
t.Fatal(err)
925-
}
926-
927-
// Turn down the DNS endpoint, this should trigger an re-resolve in the DNS
928-
// resolver.
929-
edsb.UpdateSubConnState(sc1, balancer.SubConnState{ConnectivityState: connectivity.TransientFailure})
930-
931-
// The transient failure above should trigger a re-resolve to the DNS
932-
// resolver. Need to read to clear the channel, to avoid potential deadlock
933-
// writing to the channel later.
934-
select {
935-
case <-resolveNowCh:
936-
case <-ctx.Done():
937-
t.Fatal("Timed out waiting for re-resolve")
938-
}
939-
}

xds/internal/balancer/clusterresolver/resource_resolver_test.go

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)