DNS Resovler tests should be more explicit about ndots

Motivation:
The DNS resolver may use default configuration inherited from the environment. This means the ndots value may change and result in test failure if the tests don't explicitly set the assumed value.

Modifications:
- Explicitly set ndots in resolver-dns unit tests so we don't fail if the environment overrides the search domain and ndots

Result:
Unit tests are less dependent upon the enviroment they run in.
Fixes https://github.com/netty/netty/issues/6966.
This commit is contained in:
Scott Mitchell 2017-07-12 13:54:57 -07:00
parent e5455d31b3
commit b249714a2d
3 changed files with 10 additions and 5 deletions

View File

@ -63,6 +63,7 @@ public class DnsNameResolverClientSubnetTest {
.nameServerProvider(
new SingletonDnsServerAddressStreamProvider(SocketUtils.socketAddress("8.8.8.8", 53)))
.maxQueriesPerResolve(1)
.optResourceEnabled(false);
.optResourceEnabled(false)
.ndots(1);
}
}

View File

@ -298,7 +298,8 @@ public class DnsNameResolverTest {
.channelType(NioDatagramChannel.class)
.maxQueriesPerResolve(1)
.decodeIdn(decodeToUnicode)
.optResourceEnabled(false);
.optResourceEnabled(false)
.ndots(1);
if (dnsServerAddressStreamProvider == null) {
builder.nameServerProvider(new SingletonDnsServerAddressStreamProvider(dnsServer.localAddress()));
@ -821,7 +822,8 @@ public class DnsNameResolverTest {
.resolvedAddressTypes(ResolvedAddressTypes.IPV4_ONLY)
.channelType(NioDatagramChannel.class)
.queryTimeoutMillis(1000) // We expect timeouts if startDnsServer1 is false
.optResourceEnabled(false);
.optResourceEnabled(false)
.ndots(1);
builder.nameServerProvider(new SequentialDnsServerAddressStreamProvider(dnsServer1Address,
dnsServer2.localAddress()));
@ -867,7 +869,8 @@ public class DnsNameResolverTest {
.resolvedAddressTypes(ResolvedAddressTypes.IPV6_PREFERRED)
.dnsQueryLifecycleObserverFactory(lifecycleObserverFactory)
.channelType(NioDatagramChannel.class)
.optResourceEnabled(false);
.optResourceEnabled(false)
.ndots(1);
builder.nameServerProvider(new SequentialDnsServerAddressStreamProvider(dnsServer1.localAddress(),
dnsServer2.localAddress()));

View File

@ -48,7 +48,8 @@ public class SearchDomainTest {
.channelType(NioDatagramChannel.class)
.nameServerProvider(new SingletonDnsServerAddressStreamProvider(dnsServer.localAddress()))
.maxQueriesPerResolve(1)
.optResourceEnabled(false);
.optResourceEnabled(false)
.ndots(1);
}
private TestDnsServer dnsServer;