Simple JDK 11 fixes (#26038)
* TLSSpec fix for Java 11 #25739 * =act silence logging in AsyncDns specs * +act Add internal akka.util.JavaVersion for determining runtime Java version * =act #25733 run TcpIntegrationSpec peers on different ActorSystems * pro: add explicit dependency to activation when using dockerClient for JDK 11+ Otherwise, the log is spammed with lots of ClassNotFound exceptions when running AsyncDnsResolverIntegrationSpec
This commit is contained in:
parent
cb20b21d21
commit
c462ecb60f
8 changed files with 58 additions and 14 deletions
|
|
@ -17,7 +17,7 @@ class CapacityLimitSpec extends AkkaSpec("""
|
||||||
|
|
||||||
"The TCP transport implementation" should {
|
"The TCP transport implementation" should {
|
||||||
|
|
||||||
"reply with CommandFailed to a Bind or Connect command if max-channels capacity has been reached" in new TestSetup {
|
"reply with CommandFailed to a Bind or Connect command if max-channels capacity has been reached" in new TestSetup(runClientInExtraSystem = false) {
|
||||||
establishNewClientConnection()
|
establishNewClientConnection()
|
||||||
|
|
||||||
// we now have three channels registered: a listener, a server connection and a client connection
|
// we now have three channels registered: a listener, a server connection and a client connection
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,19 @@ import akka.actor.ActorRef
|
||||||
import akka.io.Inet.SocketOption
|
import akka.io.Inet.SocketOption
|
||||||
import akka.testkit.SocketUtil._
|
import akka.testkit.SocketUtil._
|
||||||
import Tcp._
|
import Tcp._
|
||||||
|
import akka.actor.ActorSystem
|
||||||
|
import akka.dispatch.ExecutionContexts
|
||||||
|
|
||||||
trait TcpIntegrationSpecSupport { _: AkkaSpec ⇒
|
trait TcpIntegrationSpecSupport { _: AkkaSpec ⇒
|
||||||
|
|
||||||
class TestSetup(shouldBindServer: Boolean = true) {
|
class TestSetup(shouldBindServer: Boolean = true, runClientInExtraSystem: Boolean = true) {
|
||||||
|
val clientSystem =
|
||||||
|
if (runClientInExtraSystem) {
|
||||||
|
val res = ActorSystem("TcpIntegrationSpec-client", system.settings.config)
|
||||||
|
// terminate clientSystem after server system
|
||||||
|
system.whenTerminated.onComplete { _ ⇒ res.terminate() }(ExecutionContexts.sameThreadExecutionContext)
|
||||||
|
res
|
||||||
|
} else system
|
||||||
val bindHandler = TestProbe()
|
val bindHandler = TestProbe()
|
||||||
val endpoint = temporaryServerAddress()
|
val endpoint = temporaryServerAddress()
|
||||||
|
|
||||||
|
|
@ -27,10 +36,10 @@ trait TcpIntegrationSpecSupport { _: AkkaSpec ⇒
|
||||||
}
|
}
|
||||||
|
|
||||||
def establishNewClientConnection(): (TestProbe, ActorRef, TestProbe, ActorRef) = {
|
def establishNewClientConnection(): (TestProbe, ActorRef, TestProbe, ActorRef) = {
|
||||||
val connectCommander = TestProbe()
|
val connectCommander = TestProbe()(clientSystem)
|
||||||
connectCommander.send(IO(Tcp), Connect(endpoint, options = connectOptions))
|
connectCommander.send(IO(Tcp)(clientSystem), Connect(endpoint, options = connectOptions))
|
||||||
val Connected(`endpoint`, localAddress) = connectCommander.expectMsgType[Connected]
|
val Connected(`endpoint`, localAddress) = connectCommander.expectMsgType[Connected]
|
||||||
val clientHandler = TestProbe()
|
val clientHandler = TestProbe()(clientSystem)
|
||||||
connectCommander.sender() ! Register(clientHandler.ref)
|
connectCommander.sender() ! Register(clientHandler.ref)
|
||||||
|
|
||||||
val Connected(`localAddress`, `endpoint`) = bindHandler.expectMsgType[Connected]
|
val Connected(`localAddress`, `endpoint`) = bindHandler.expectMsgType[Connected]
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import akka.io.dns.DnsProtocol.{ Ip, RequestType, Srv }
|
||||||
import akka.io.{ Dns, IO }
|
import akka.io.{ Dns, IO }
|
||||||
import CachePolicy.Ttl
|
import CachePolicy.Ttl
|
||||||
import akka.pattern.ask
|
import akka.pattern.ask
|
||||||
|
import akka.testkit.WithLogCapturing
|
||||||
import akka.testkit.{ AkkaSpec, SocketUtil }
|
import akka.testkit.{ AkkaSpec, SocketUtil }
|
||||||
import akka.util.Timeout
|
import akka.util.Timeout
|
||||||
|
|
||||||
|
|
@ -25,10 +26,11 @@ test starts and tear it down when it finishes.
|
||||||
class AsyncDnsResolverIntegrationSpec extends AkkaSpec(
|
class AsyncDnsResolverIntegrationSpec extends AkkaSpec(
|
||||||
s"""
|
s"""
|
||||||
akka.loglevel = DEBUG
|
akka.loglevel = DEBUG
|
||||||
|
akka.loggers = ["akka.testkit.SilenceAllTestEventListener"]
|
||||||
akka.io.dns.resolver = async-dns
|
akka.io.dns.resolver = async-dns
|
||||||
akka.io.dns.async-dns.nameservers = ["localhost:${AsyncDnsResolverIntegrationSpec.dockerDnsServerPort}"]
|
akka.io.dns.async-dns.nameservers = ["localhost:${AsyncDnsResolverIntegrationSpec.dockerDnsServerPort}"]
|
||||||
// akka.io.dns.async-dns.nameservers = default
|
// akka.io.dns.async-dns.nameservers = default
|
||||||
""") with DockerBindDnsService {
|
""") with DockerBindDnsService with WithLogCapturing {
|
||||||
val duration = 10.seconds
|
val duration = 10.seconds
|
||||||
implicit val timeout = Timeout(duration)
|
implicit val timeout = Timeout(duration)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import akka.io.Dns
|
||||||
import akka.io.dns.AAAARecord
|
import akka.io.dns.AAAARecord
|
||||||
import akka.io.dns.DnsProtocol.{ Resolve, Resolved }
|
import akka.io.dns.DnsProtocol.{ Resolve, Resolved }
|
||||||
import akka.io.dns.CachePolicy.Ttl
|
import akka.io.dns.CachePolicy.Ttl
|
||||||
|
import akka.testkit.WithLogCapturing
|
||||||
import akka.testkit.{ AkkaSpec, ImplicitSender }
|
import akka.testkit.{ AkkaSpec, ImplicitSender }
|
||||||
|
|
||||||
import scala.collection.immutable.Seq
|
import scala.collection.immutable.Seq
|
||||||
|
|
@ -17,9 +18,10 @@ import scala.collection.immutable.Seq
|
||||||
class AsyncDnsManagerSpec extends AkkaSpec(
|
class AsyncDnsManagerSpec extends AkkaSpec(
|
||||||
"""
|
"""
|
||||||
akka.loglevel = DEBUG
|
akka.loglevel = DEBUG
|
||||||
|
akka.loggers = ["akka.testkit.SilenceAllTestEventListener"]
|
||||||
akka.io.dns.resolver = async-dns
|
akka.io.dns.resolver = async-dns
|
||||||
akka.io.dns.async-dns.nameservers = default
|
akka.io.dns.async-dns.nameservers = default
|
||||||
""") with ImplicitSender {
|
""") with ImplicitSender with WithLogCapturing {
|
||||||
|
|
||||||
val dns = Dns(system).manager
|
val dns = Dns(system).manager
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,17 @@ import akka.io.dns.internal.DnsClient.{ Answer, Question4, Question6, SrvQuestio
|
||||||
import akka.io.dns.{ AAAARecord, ARecord, DnsSettings, SRVRecord }
|
import akka.io.dns.{ AAAARecord, ARecord, DnsSettings, SRVRecord }
|
||||||
import akka.testkit.{ AkkaSpec, ImplicitSender, TestProbe }
|
import akka.testkit.{ AkkaSpec, ImplicitSender, TestProbe }
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
|
import akka.testkit.WithLogCapturing
|
||||||
|
|
||||||
|
import scala.concurrent.duration._
|
||||||
import scala.collection.{ immutable ⇒ im }
|
import scala.collection.{ immutable ⇒ im }
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
class AsyncDnsResolverSpec extends AkkaSpec(
|
class AsyncDnsResolverSpec extends AkkaSpec(
|
||||||
"""
|
"""
|
||||||
akka.loglevel = INFO
|
akka.loglevel = DEBUG
|
||||||
""") with ImplicitSender {
|
akka.loggers = ["akka.testkit.SilenceAllTestEventListener"]
|
||||||
|
""") with ImplicitSender with WithLogCapturing {
|
||||||
|
|
||||||
"Async DNS Resolver" must {
|
"Async DNS Resolver" must {
|
||||||
|
|
||||||
|
|
|
||||||
26
akka-actor/src/main/scala/akka/util/JavaVersion.scala
Normal file
26
akka-actor/src/main/scala/akka/util/JavaVersion.scala
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
package akka.util
|
||||||
|
|
||||||
|
import akka.annotation.InternalApi
|
||||||
|
|
||||||
|
/**
|
||||||
|
* INTERNAL API
|
||||||
|
*/
|
||||||
|
@InternalApi private[akka] object JavaVersion {
|
||||||
|
|
||||||
|
val majorVersion: Int = {
|
||||||
|
// FIXME replace with Runtime.version() when we no longer support Java 8
|
||||||
|
// See Oracle section 1.5.3 at:
|
||||||
|
// https://docs.oracle.com/javase/8/docs/technotes/guides/versioning/spec/versioning2.html
|
||||||
|
val version = System.getProperty("java.specification.version").split('.')
|
||||||
|
|
||||||
|
val majorString =
|
||||||
|
if (version(0) == "1") version(1) // Java 8 will be 1.8
|
||||||
|
else version(0) // later will be 9, 10, 11 etc
|
||||||
|
|
||||||
|
majorString.toInt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -23,11 +23,9 @@ import akka.stream.TLSProtocol._
|
||||||
import akka.stream.scaladsl._
|
import akka.stream.scaladsl._
|
||||||
import akka.stream.stage._
|
import akka.stream.stage._
|
||||||
import akka.stream.testkit._
|
import akka.stream.testkit._
|
||||||
import akka.stream.testkit.Utils._
|
|
||||||
import akka.stream.testkit.scaladsl.StreamTestKit._
|
import akka.stream.testkit.scaladsl.StreamTestKit._
|
||||||
import akka.util.ByteString
|
import akka.util.{ ByteString, JavaVersion }
|
||||||
import javax.net.ssl._
|
import javax.net.ssl._
|
||||||
|
|
||||||
import akka.stream.impl.fusing.GraphStages.SimpleLinearGraphStage
|
import akka.stream.impl.fusing.GraphStages.SimpleLinearGraphStage
|
||||||
import akka.testkit.WithLogCapturing
|
import akka.testkit.WithLogCapturing
|
||||||
|
|
||||||
|
|
@ -410,7 +408,11 @@ class TlsSpec extends StreamSpec(TlsSpec.configOverrides) with WithLogCapturing
|
||||||
.join(Tcp().outgoingConnection(Await.result(server, 1.second).localAddress)).run()
|
.join(Tcp().outgoingConnection(Await.result(server, 1.second).localAddress)).run()
|
||||||
|
|
||||||
Await.result(serverErr, 1.second).getMessage should include("certificate_unknown")
|
Await.result(serverErr, 1.second).getMessage should include("certificate_unknown")
|
||||||
Await.result(clientErr, 1.second).getMessage should equal("General SSLEngine problem")
|
val clientErrText = Await.result(clientErr, 1.second).getMessage
|
||||||
|
if (JavaVersion.majorVersion >= 11)
|
||||||
|
clientErrText should include("unable to find valid certification path to requested target")
|
||||||
|
else
|
||||||
|
clientErrText should equal("General SSLEngine problem")
|
||||||
}
|
}
|
||||||
|
|
||||||
"reliably cancel subscriptions when TransportIn fails early" in assertAllStagesStopped {
|
"reliably cancel subscriptions when TransportIn fails early" in assertAllStagesStopped {
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ object Dependencies {
|
||||||
val actorTests = l ++= Seq(
|
val actorTests = l ++= Seq(
|
||||||
Test.junit, Test.scalatest.value, Test.commonsCodec, Test.commonsMath,
|
Test.junit, Test.scalatest.value, Test.commonsCodec, Test.commonsMath,
|
||||||
Test.mockito, Test.scalacheck.value, Test.jimfs,
|
Test.mockito, Test.scalacheck.value, Test.jimfs,
|
||||||
Test.dockerClient
|
Test.dockerClient, Provided.activation // dockerClient needs javax.activation.DataSource in JDK 11+
|
||||||
)
|
)
|
||||||
|
|
||||||
val actorTestkitTyped = l ++= Seq(Provided.junit, Provided.scalatest.value)
|
val actorTestkitTyped = l ++= Seq(Provided.junit, Provided.scalatest.value)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue