Fix remaining akka-testkit warnings (#26752)
* Fix remaining akka-testkit warnings Mostly in tests and 2.13 * Add issue link * MiMa exclude for multi-node-testkit We don't promise bincompat there anyway, but perhaps good to keep mima there so at least we don't break things accidentally
This commit is contained in:
parent
eed1638361
commit
7372d2b735
14 changed files with 27 additions and 18 deletions
|
|
@ -0,0 +1,2 @@
|
|||
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.remote.testkit.PerfFlamesSupport.*")
|
||||
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.remote.testkit.PerfFlamesSupport.runPerfFlames")
|
||||
|
|
@ -6,10 +6,13 @@ package akka.testkit
|
|||
|
||||
import akka.actor._
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
import akka.dispatch._
|
||||
|
||||
import scala.concurrent.Await
|
||||
import scala.reflect.ClassTag
|
||||
import akka.pattern.ask
|
||||
import com.github.ghik.silencer.silent
|
||||
|
||||
/**
|
||||
* This special ActorRef is exclusively for use during unit testing in a single-threaded environment. Therefore, it
|
||||
|
|
@ -18,6 +21,7 @@ import akka.pattern.ask
|
|||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
@silent // 'early initializers' are deprecated on 2.13 and will be replaced with trait parameters on 2.14. https://github.com/akka/akka/issues/26753
|
||||
class TestActorRef[T <: Actor](_system: ActorSystem, _props: Props, _supervisor: ActorRef, name: String) extends {
|
||||
val props =
|
||||
_props.withDispatcher(
|
||||
|
|
|
|||
|
|
@ -540,6 +540,7 @@ final case class DeadLettersFilter(val messageClass: Class[_])(occurrences: Int)
|
|||
* }
|
||||
* </code></pre>
|
||||
*/
|
||||
@ccompatUsedUntil213
|
||||
class TestEventListener extends Logging.DefaultLogger {
|
||||
import TestEvent._
|
||||
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ import scala.concurrent.Await
|
|||
import scala.concurrent.duration._
|
||||
import scala.reflect.ClassTag
|
||||
import scala.util.control.NonFatal
|
||||
|
||||
import akka.actor._
|
||||
import akka.util.{ BoxedType, Timeout }
|
||||
import akka.actor.IllegalActorStateException
|
||||
import akka.actor.DeadLetter
|
||||
import akka.actor.Terminated
|
||||
import com.github.ghik.silencer.silent
|
||||
|
||||
object TestActor {
|
||||
type Ignore = Option[PartialFunction[Any, Boolean]]
|
||||
|
|
@ -919,6 +919,7 @@ trait TestKitBase {
|
|||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
@silent // 'early initializers' are deprecated on 2.13 and will be replaced with trait parameters on 2.14. https://github.com/akka/akka/issues/26753
|
||||
class TestKit(_system: ActorSystem) extends { implicit val system = _system } with TestKitBase
|
||||
|
||||
object TestKit {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import scala.collection.immutable
|
|||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
|
||||
package object testkit {
|
||||
@ccompatUsedUntil213
|
||||
def filterEvents[T](eventFilters: Iterable[EventFilter])(block: => T)(implicit system: ActorSystem): T = {
|
||||
def now = System.currentTimeMillis
|
||||
|
||||
|
|
|
|||
|
|
@ -5,16 +5,18 @@
|
|||
package akka.testkit
|
||||
|
||||
import language.postfixOps
|
||||
|
||||
import org.scalatest.WordSpec
|
||||
import org.scalatest.Matchers
|
||||
import akka.actor._
|
||||
import com.typesafe.config.ConfigFactory
|
||||
|
||||
import scala.concurrent.Await
|
||||
import scala.concurrent.duration._
|
||||
import akka.actor.DeadLetter
|
||||
import akka.pattern.ask
|
||||
import com.github.ghik.silencer.silent
|
||||
|
||||
@silent
|
||||
class AkkaSpecSpec extends WordSpec with Matchers {
|
||||
|
||||
"An AkkaSpec" must {
|
||||
|
|
|
|||
|
|
@ -143,9 +143,8 @@ object Coroner {
|
|||
#Heap usage: ${memMx.getHeapMemoryUsage()}
|
||||
#Non-heap usage: ${memMx.getNonHeapMemoryUsage()}""".stripMargin('#'))
|
||||
|
||||
def dumpAllThreads: Seq[ThreadInfo] = {
|
||||
threadMx.dumpAllThreads(threadMx.isObjectMonitorUsageSupported, threadMx.isSynchronizerUsageSupported)
|
||||
}
|
||||
def dumpAllThreads: Seq[ThreadInfo] =
|
||||
threadMx.dumpAllThreads(threadMx.isObjectMonitorUsageSupported, threadMx.isSynchronizerUsageSupported).toSeq
|
||||
|
||||
def findDeadlockedThreads: (Seq[ThreadInfo], String) = {
|
||||
val (ids, desc) = if (threadMx.isSynchronizerUsageSupported()) {
|
||||
|
|
@ -157,7 +156,7 @@ object Coroner {
|
|||
(Seq.empty, desc)
|
||||
} else {
|
||||
val maxTraceDepth = 1000 // Seems deep enough
|
||||
(threadMx.getThreadInfo(ids, maxTraceDepth), desc)
|
||||
(threadMx.getThreadInfo(ids, maxTraceDepth).toSeq, desc)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@
|
|||
package akka.testkit
|
||||
|
||||
import language.postfixOps
|
||||
|
||||
import akka.actor._
|
||||
import com.github.ghik.silencer.silent
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
@silent
|
||||
class JavaTestKitSpec extends AkkaSpec with DefaultTimeout {
|
||||
|
||||
"JavaTestKit" must {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class TestFSMRefSpec extends AkkaSpec {
|
|||
val fsm = TestFSMRef(new Actor with FSM[Int, Null] {
|
||||
startWith(1, null)
|
||||
when(1) {
|
||||
case x => stay
|
||||
case _ => stay
|
||||
}
|
||||
}, "test-fsm-ref-2")
|
||||
fsm.isTimerActive("test") should ===(false)
|
||||
|
|
@ -65,7 +65,7 @@ class TestFSMRefSpec extends AkkaSpec {
|
|||
class TestFSMActor extends Actor with FSM[Int, Null] {
|
||||
startWith(1, null)
|
||||
when(1) {
|
||||
case x => stay
|
||||
case _ => stay
|
||||
}
|
||||
val supervisor = context.parent
|
||||
val name = context.self.path.name
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ private[akka] trait MemoryUsageSnapshotting extends MetricsPrefix {
|
|||
metrics.get(key("non-heap-usage")).asInstanceOf[RatioGauge].getValue)
|
||||
}
|
||||
|
||||
private def key(k: String) = prefix + "." + k
|
||||
private def key(k: String) = prefix.toString + "." + k
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ private[akka] trait MetricsKit extends MetricsKitOps {
|
|||
import collection.JavaConverters._
|
||||
registry.getMetrics.asScala.find(_._1 == key).map(_._2) match {
|
||||
case Some(existing: M) => existing
|
||||
case Some(existing) =>
|
||||
case Some(_) =>
|
||||
throw new IllegalArgumentException(
|
||||
"Key: [%s] is already for different kind of metric! Was [%s], expected [%s]"
|
||||
.format(key, metric.getClass.getSimpleName, tag.runtimeClass.getSimpleName))
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class MetricsKitSpec extends WordSpec with Matchers with BeforeAndAfter with Bef
|
|||
val hist = hdrHistogram(KitKey / "hist", highestTrackableValue = maxMillis, 4, "ns")
|
||||
|
||||
for {
|
||||
n <- 1 to 11
|
||||
_ <- 1 to 11
|
||||
i <- 0L to 1579331
|
||||
} hist.update(i)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import java.util
|
|||
import java.util.concurrent.TimeUnit
|
||||
import com.codahale.metrics._
|
||||
import akka.testkit.metrics._
|
||||
import scala.reflect.ClassTag
|
||||
|
||||
/**
|
||||
* Used to report `akka.testkit.metric.Metric` types that the original `com.codahale.metrics.ConsoleReporter` is unaware of (cannot re-use directly because of private constructor).
|
||||
|
|
@ -48,9 +47,8 @@ class AkkaConsoleReporter(registry: AkkaMetricRegistry, verbose: Boolean, output
|
|||
output.flush()
|
||||
}
|
||||
|
||||
def printMetrics[T <: Metric](metrics: Iterable[(String, T)], printer: T => Unit)(
|
||||
implicit clazz: ClassTag[T]): Unit = {
|
||||
if (!metrics.isEmpty) {
|
||||
def printMetrics[T <: Metric](metrics: Iterable[(String, T)], printer: T => Unit): Unit = {
|
||||
if (metrics.nonEmpty) {
|
||||
printWithBanner(s"-- ${simpleName(metrics.head._2.getClass)}", '-')
|
||||
for ((key, metric) <- metrics) {
|
||||
output.println(" " + key)
|
||||
|
|
|
|||
|
|
@ -33,8 +33,7 @@ object AkkaDisciplinePlugin extends AutoPlugin with ScalafixSupport {
|
|||
"akka-persistence-tck",
|
||||
"akka-remote",
|
||||
"akka-stream-tests",
|
||||
"akka-stream-tests-tck",
|
||||
"akka-testkit")
|
||||
"akka-stream-tests-tck")
|
||||
|
||||
val strictProjects = Set("akka-discovery", "akka-protobuf", "akka-coordination")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue