diff --git a/akka-actor-tests/src/test/scala/akka/io/dns/AsyncDnsResolverIntegrationSpec.scala b/akka-actor-tests/src/test/scala/akka/io/dns/AsyncDnsResolverIntegrationSpec.scala index 6f00dae860..7d92076cd4 100644 --- a/akka-actor-tests/src/test/scala/akka/io/dns/AsyncDnsResolverIntegrationSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/io/dns/AsyncDnsResolverIntegrationSpec.scala @@ -21,27 +21,36 @@ import akka.testkit.SocketUtil.Both import akka.testkit.WithLogCapturing import akka.util.Timeout -/* -These tests rely on a DNS server with 2 zones configured, foo.test and bar.example. - -The configuration to start a bind DNS server in Docker with this configuration -is included, and the test will automatically start this container when the -test starts and tear it down when it finishes. +/** + * These tests rely on a DNS server with 2 zones configured, foo.test and bar.example. + * + * The configuration to start a bind DNS server in Docker with this configuration + * is included, and the test will automatically start this container when the + * test starts and tear it down when it finishes. */ -class AsyncDnsResolverIntegrationSpec extends DockerBindDnsService(ConfigFactory.parseString(s""" +object AsyncDnsResolverIntegrationSpec { + lazy val dockerDnsServerPort: Int = SocketUtil.temporaryLocalPort(Both) + implicit val defaultTimeout: Timeout = Timeout(10.seconds) + def conf = ConfigFactory.parseString(s""" akka.loglevel = DEBUG akka.loggers = ["akka.testkit.SilenceAllTestEventListener"] akka.io.dns.resolver = async-dns - akka.io.dns.async-dns.nameservers = ["localhost:${AsyncDnsResolverIntegrationSpec.dockerDnsServerPort}"] + akka.io.dns.async-dns.nameservers = ["localhost:${dockerDnsServerPort}"] akka.io.dns.async-dns.search-domains = ["foo.test", "test"] akka.io.dns.async-dns.ndots = 2 - """)) with WithLogCapturing { + akka.io.dns.async-dns.resolve-timeout = ${defaultTimeout.duration.toSeconds}s + """) +} + +class AsyncDnsResolverIntegrationSpec + extends DockerBindDnsService(AsyncDnsResolverIntegrationSpec.conf) + with WithLogCapturing { + import AsyncDnsResolverIntegrationSpec._ - implicit val timeout: Timeout = Timeout(10.seconds) override implicit val patience: PatienceConfig = - PatienceConfig(timeout.duration + 1.second, Span(100, Millis)) + PatienceConfig(defaultTimeout.duration + 1.second, Span(100, Millis)) - val hostPort = AsyncDnsResolverIntegrationSpec.dockerDnsServerPort + override val hostPort = dockerDnsServerPort "Resolver" must { if (!dockerAvailable()) { @@ -198,7 +207,3 @@ class AsyncDnsResolverIntegrationSpec extends DockerBindDnsService(ConfigFactory } } - -object AsyncDnsResolverIntegrationSpec { - lazy val dockerDnsServerPort: Int = SocketUtil.temporaryLocalPort(Both) -}