(t *testing.T)
| 474 | } |
| 475 | |
| 476 | func (s) TestDefaultUniverseDomain(t *testing.T) { |
| 477 | replaceResolvers(t) |
| 478 | simulateRunningOnGCE(t, true) |
| 479 | useCleanUniverseDomain(t) |
| 480 | builder := resolver.Get(c2pScheme) |
| 481 | |
| 482 | // Override the zone returned by the metadata server. |
| 483 | oldGetZone := getZone |
| 484 | getZone = func(time.Duration) string { return "test-zone" } |
| 485 | defer func() { getZone = oldGetZone }() |
| 486 | |
| 487 | // Override IPv6 capability returned by the metadata server. |
| 488 | oldGetIPv6Capability := getIPv6Capable |
| 489 | getIPv6Capable = func(time.Duration) bool { return false } |
| 490 | defer func() { getIPv6Capable = oldGetIPv6Capability }() |
| 491 | |
| 492 | // Override the random func used in the node ID. |
| 493 | origRandInd := randInt |
| 494 | randInt = func() int { return 666 } |
| 495 | defer func() { randInt = origRandInd }() |
| 496 | |
| 497 | // Override xDS client pool. |
| 498 | oldXdsClientPool := xdsClientPool |
| 499 | xdsClientPool = xdsclient.NewPool(nil) |
| 500 | defer func() { xdsClientPool = oldXdsClientPool }() |
| 501 | |
| 502 | // Build the google-c2p resolver. |
| 503 | target := resolver.Target{URL: url.URL{Scheme: c2pScheme, Path: "test-path"}} |
| 504 | r, err := builder.Build(target, nil, resolver.BuildOptions{}) |
| 505 | if err != nil { |
| 506 | t.Fatalf("failed to build resolver: %v", err) |
| 507 | } |
| 508 | defer r.Close() |
| 509 | |
| 510 | // Build should return xDS, not DNS. |
| 511 | if r, ok := r.(*c2pResolverWrapper); !ok || r.Resolver != testXDSResolver { |
| 512 | t.Fatalf("Build() returned %#v, want c2pResolverWrapper", r) |
| 513 | } |
| 514 | |
| 515 | // Check that we use directpath-pa.googleapis.com in the bootstrap config |
| 516 | wantBootstrapConfig := bootstrapConfig(t, bootstrap.ConfigOptionsForTesting{ |
| 517 | Servers: []byte(`[{ |
| 518 | "server_uri": "dns:///directpath-pa.googleapis.com", |
| 519 | "channel_creds": [{"type": "google_default"}], |
| 520 | "server_features": ["ignore_resource_deletion"] |
| 521 | }]`), |
| 522 | Authorities: map[string]json.RawMessage{ |
| 523 | "traffic-director-c2p.xds.googleapis.com": []byte(`{ |
| 524 | "xds_servers": [ |
| 525 | { |
| 526 | "server_uri": "dns:///directpath-pa.googleapis.com", |
| 527 | "channel_creds": [{"type": "google_default"}], |
| 528 | "server_features": ["ignore_resource_deletion"] |
| 529 | } |
| 530 | ] |
| 531 | }`), |
| 532 | }, |
| 533 | Node: []byte(`{ |
nothing calls this directly
no test coverage detected