Tests the scenario where a name resolves to a list of addresses, possibly some grpclb addresses as well, and a service config. The test verifies that the expected update is pushed to the channel.
(t *testing.T)
| 425 | // some grpclb addresses as well, and a service config. The test verifies that |
| 426 | // the expected update is pushed to the channel. |
| 427 | func (s) TestDNSResolver_Basic(t *testing.T) { |
| 428 | tests := []struct { |
| 429 | name string |
| 430 | target string |
| 431 | hostLookupTable map[string][]string |
| 432 | srvLookupTable map[string][]*net.SRV |
| 433 | txtLookupTable map[string][]string |
| 434 | want resolverUpdate |
| 435 | }{ |
| 436 | { |
| 437 | name: "default_port", |
| 438 | target: "foo.bar.com", |
| 439 | hostLookupTable: map[string][]string{ |
| 440 | "foo.bar.com": {"1.2.3.4", "5.6.7.8"}, |
| 441 | }, |
| 442 | txtLookupTable: map[string][]string{ |
| 443 | "_grpc_config.foo.bar.com": txtRecordServiceConfig(txtRecordGood), |
| 444 | }, |
| 445 | want: resolverUpdate{ |
| 446 | addrs: []resolver.Address{{Addr: "1.2.3.4" + colonDefaultPort}, {Addr: "5.6.7.8" + colonDefaultPort}}, |
| 447 | endpoints: []resolver.Endpoint{ |
| 448 | {Addresses: []resolver.Address{{Addr: "1.2.3.4" + colonDefaultPort}}}, |
| 449 | {Addresses: []resolver.Address{{Addr: "5.6.7.8" + colonDefaultPort}}}, |
| 450 | }, |
| 451 | serviceConfig: mustParseServiceConfig(t, scJSON), |
| 452 | }, |
| 453 | }, |
| 454 | { |
| 455 | name: "specified_port", |
| 456 | target: "foo.bar.com:1234", |
| 457 | hostLookupTable: map[string][]string{ |
| 458 | "foo.bar.com": {"1.2.3.4", "5.6.7.8"}, |
| 459 | }, |
| 460 | txtLookupTable: map[string][]string{ |
| 461 | "_grpc_config.foo.bar.com": txtRecordServiceConfig(txtRecordGood), |
| 462 | }, |
| 463 | want: resolverUpdate{ |
| 464 | addrs: []resolver.Address{{Addr: "1.2.3.4:1234"}, {Addr: "5.6.7.8:1234"}}, |
| 465 | endpoints: []resolver.Endpoint{ |
| 466 | {Addresses: []resolver.Address{{Addr: "1.2.3.4:1234"}}}, |
| 467 | {Addresses: []resolver.Address{{Addr: "5.6.7.8:1234"}}}, |
| 468 | }, |
| 469 | serviceConfig: mustParseServiceConfig(t, scJSON), |
| 470 | }, |
| 471 | }, |
| 472 | { |
| 473 | name: "ipv4_with_SRV_and_single_grpclb_address", |
| 474 | target: "srv.ipv4.single.fake", |
| 475 | hostLookupTable: map[string][]string{ |
| 476 | "srv.ipv4.single.fake": {"2.4.6.8"}, |
| 477 | "ipv4.single.fake": {"1.2.3.4"}, |
| 478 | }, |
| 479 | srvLookupTable: map[string][]*net.SRV{ |
| 480 | "_grpclb._tcp.srv.ipv4.single.fake": {&net.SRV{Target: "ipv4.single.fake", Port: 1234}}, |
| 481 | }, |
| 482 | txtLookupTable: map[string][]string{ |
| 483 | "_grpc_config.srv.ipv4.single.fake": txtRecordServiceConfig(txtRecordGood), |
| 484 | }, |
nothing calls this directly
no test coverage detected