Skip to content

Commit

Permalink
clusterresolver/e2e_test: Avoid making real DNS requests in TestAggre…
Browse files Browse the repository at this point in the history
…gateCluster_BadEDS_BadDNS (#7669)
  • Loading branch information
arjan-bal authored Sep 25, 2024
1 parent e7a8097 commit a9ff62d
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,7 @@ func (s) TestAggregateCluster_BadDNS_GoodEDS(t *testing.T) {
// error, the test verifies that RPCs fail with the error triggered by the DNS
// Discovery Mechanism (from sending an empty address list down).
func (s) TestAggregateCluster_BadEDS_BadDNS(t *testing.T) {
dnsTargetCh, dnsR := setupDNS(t)
// Start an xDS management server.
managementServer := e2e.StartManagementServer(t, e2e.ManagementServerOptions{AllowResourceSubset: true})

Expand All @@ -929,14 +930,16 @@ func (s) TestAggregateCluster_BadEDS_BadDNS(t *testing.T) {
const (
edsClusterName = clusterName + "-eds"
dnsClusterName = clusterName + "-dns"
dnsHostName = "bad.ip.v4.address"
dnsPort = 8080
)
emptyEndpointResource := e2e.DefaultEndpoint(edsServiceName, "localhost", nil)
resources := e2e.UpdateOptions{
NodeID: nodeID,
Clusters: []*v3clusterpb.Cluster{
makeAggregateClusterResource(clusterName, []string{edsClusterName, dnsClusterName}),
e2e.DefaultCluster(edsClusterName, edsServiceName, e2e.SecurityLevelNone),
makeLogicalDNSClusterResource(dnsClusterName, "bad.ip.v4.address", 8080),
makeLogicalDNSClusterResource(dnsClusterName, dnsHostName, dnsPort),
},
Endpoints: []*v3endpointpb.ClusterLoadAssignment{emptyEndpointResource},
SkipValidation: true,
Expand All @@ -952,6 +955,20 @@ func (s) TestAggregateCluster_BadEDS_BadDNS(t *testing.T) {
cc, cleanup := setupAndDial(t, bootstrapContents)
defer cleanup()

// Ensure that the DNS resolver is started for the expected target.
select {
case <-ctx.Done():
t.Fatal("Timeout when waiting for DNS resolver to be started")
case target := <-dnsTargetCh:
got, want := target.Endpoint(), fmt.Sprintf("%s:%d", dnsHostName, dnsPort)
if got != want {
t.Fatalf("DNS resolution started for target %q, want %q", got, want)
}
}

// Produce a bad resolver update from the DNS resolver.
dnsR.ReportError(fmt.Errorf("DNS error"))

// Ensure that the error from the DNS Resolver leads to an empty address
// update for both priorities.
client := testgrpc.NewTestServiceClient(cc)
Expand Down

0 comments on commit a9ff62d

Please sign in to comment.