line / armeria

Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
https://armeria.dev
Apache License 2.0
4.79k stars 908 forks source link

Testing DnsEndpointGroup #2072

Open codefromthecrypt opened 5 years ago

codefromthecrypt commented 5 years ago

DnsEndpointGroup.endpoints() returns empty on unresolved addresses. This is a problem in testing because sometime you want to test code that blocks until DNS resolves. In Zipkin, this prevents a "first request" error users would otherwise see.

Lacking a MockDnsServer, we can only test usage of DnsEndpointGroup usage like this with resolvable hosts. However, in CI or offline laptops, this can lead to flakey tests.

It would be nice to be able to control the resolver of DnsEndpointGroup or have an alternative such as MockDnsServer

codefromthecrypt commented 5 years ago

@anuraaga PS this might be up your alley. In general it is a missing piece when folks do "mock web servers" as DNS is always punted.

anuraaga commented 5 years ago

I've used Netty's test DNS server before - https://github.com/netty/netty/blob/4.1/resolver-dns/src/test/java/io/netty/resolver/dns/TestDnsServer.java

It's a lot of code, I'm hoping I can find a way that doesn't require copying all of that in ;)