Tests scenarios where fetching of service config is enabled or disabled, and verifies that the expected update is pushed by the DNS resolver.
(t *testing.T)
| 964 | // Tests scenarios where fetching of service config is enabled or disabled, and |
| 965 | // verifies that the expected update is pushed by the DNS resolver. |
| 966 | func (s) TestDisableServiceConfig(t *testing.T) { |
| 967 | tests := []struct { |
| 968 | name string |
| 969 | target string |
| 970 | hostLookupTable map[string][]string |
| 971 | txtLookupTable map[string][]string |
| 972 | txtLookupsEnabled bool |
| 973 | disableServiceConfig bool |
| 974 | want resolverUpdate |
| 975 | }{ |
| 976 | { |
| 977 | name: "not disabled in BuildOptions; enabled globally", |
| 978 | target: "foo.bar.com", |
| 979 | hostLookupTable: map[string][]string{"foo.bar.com": {"1.2.3.4", "5.6.7.8"}}, |
| 980 | txtLookupTable: map[string][]string{ |
| 981 | "_grpc_config.foo.bar.com": txtRecordServiceConfig(txtRecordGood), |
| 982 | }, |
| 983 | txtLookupsEnabled: true, |
| 984 | disableServiceConfig: false, |
| 985 | want: resolverUpdate{ |
| 986 | addrs: []resolver.Address{{Addr: "1.2.3.4" + colonDefaultPort}, {Addr: "5.6.7.8" + colonDefaultPort}}, |
| 987 | endpoints: []resolver.Endpoint{ |
| 988 | {Addresses: []resolver.Address{{Addr: "1.2.3.4" + colonDefaultPort}}}, |
| 989 | {Addresses: []resolver.Address{{Addr: "5.6.7.8" + colonDefaultPort}}}, |
| 990 | }, |
| 991 | serviceConfig: mustParseServiceConfig(t, scJSON), |
| 992 | }, |
| 993 | }, |
| 994 | { |
| 995 | name: "disabled in BuildOptions; enabled globally", |
| 996 | target: "foo.bar.com", |
| 997 | hostLookupTable: map[string][]string{"foo.bar.com": {"1.2.3.4", "5.6.7.8"}}, |
| 998 | txtLookupTable: map[string][]string{ |
| 999 | "_grpc_config.foo.bar.com": txtRecordServiceConfig(txtRecordGood), |
| 1000 | }, |
| 1001 | txtLookupsEnabled: true, |
| 1002 | disableServiceConfig: true, |
| 1003 | want: resolverUpdate{ |
| 1004 | addrs: []resolver.Address{{Addr: "1.2.3.4" + colonDefaultPort}, {Addr: "5.6.7.8" + colonDefaultPort}}, |
| 1005 | endpoints: []resolver.Endpoint{ |
| 1006 | {Addresses: []resolver.Address{{Addr: "1.2.3.4" + colonDefaultPort}}}, |
| 1007 | {Addresses: []resolver.Address{{Addr: "5.6.7.8" + colonDefaultPort}}}, |
| 1008 | }, |
| 1009 | }, |
| 1010 | }, |
| 1011 | { |
| 1012 | name: "not disabled in BuildOptions; disabled globally", |
| 1013 | target: "foo.bar.com", |
| 1014 | hostLookupTable: map[string][]string{"foo.bar.com": {"1.2.3.4", "5.6.7.8"}}, |
| 1015 | txtLookupTable: map[string][]string{ |
| 1016 | "_grpc_config.foo.bar.com": txtRecordServiceConfig(txtRecordGood), |
| 1017 | }, |
| 1018 | txtLookupsEnabled: false, |
| 1019 | disableServiceConfig: false, |
| 1020 | want: resolverUpdate{ |
| 1021 | addrs: []resolver.Address{{Addr: "1.2.3.4" + colonDefaultPort}, {Addr: "5.6.7.8" + colonDefaultPort}}, |
| 1022 | endpoints: []resolver.Endpoint{ |
| 1023 | {Addresses: []resolver.Address{{Addr: "1.2.3.4" + colonDefaultPort}}}, |
nothing calls this directly
no test coverage detected