setupDNS unregisters the DNS resolver and registers a manual resolver for the same scheme. This allows the test to fake the DNS resolution by supplying the addresses of the test backends. Returns the following: - a channel onto which the DNS target being resolved is written to by the fake DNS resol
(t *testing.T)
| 173 | // fake DNS resolver |
| 174 | // - a manual resolver which is used to fake the actual DNS resolution |
| 175 | func setupDNS(t *testing.T) (chan resolver.Target, *manual.Resolver) { |
| 176 | targetCh := make(chan resolver.Target, 1) |
| 177 | |
| 178 | mr := manual.NewBuilderWithScheme("dns") |
| 179 | mr.BuildCallback = func(target resolver.Target, _ resolver.ClientConn, _ resolver.BuildOptions) { targetCh <- target } |
| 180 | |
| 181 | dnsResolverBuilder := resolver.Get("dns") |
| 182 | resolver.Register(mr) |
| 183 | |
| 184 | t.Cleanup(func() { resolver.Register(dnsResolverBuilder) }) |
| 185 | return targetCh, mr |
| 186 | } |
| 187 | |
| 188 | // Performs the following setup required for tests: |
| 189 | // - Spins up an xDS management server and the provided onStreamRequest |
no test coverage detected