Skip to content

Commit

Permalink
Merge pull request #21905 from akka/wip-build-perf-patriknw
Browse files Browse the repository at this point in the history
reduce test time for PR validation
  • Loading branch information
patriknw committed Nov 30, 2016
2 parents 267f311 + e044445 commit 448c12d
Show file tree
Hide file tree
Showing 36 changed files with 168 additions and 114 deletions.
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,13 @@ In order to speed up PR validation times, the Akka build contains a special sbt
which is smart enough to figure out which projects should be built if a PR only has changes in some parts of the project.
For example, if your PR only touches `akka-persistence`, no `akka-remote` tests need to be run, however the task
will validate all projects that depend on `akka-persistence` (including samples).
Also, tests tagged as `PerformanceTest` and the likes of it are excluded from PR validation.
Also, tests tagged as `PerformanceTest`, `TimingTest`, `LongRunningTest` and all multi-node tests are excluded from PR validation.

You can exclude the same kind of tests in your local build by starting sbt with:

```
sbt -Dakka.test.tags.exclude=performance,timing,long-running -Dakka.test.multi-in-test=false
```

In order to force the `validatePullRequest` task to build the entire project, regardless of dependency analysis of a PRs
changes one can use the special `PLS BUILD ALL` command (typed in a comment on Github, on the Pull Request), which will cause
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,27 @@ import akka.testkit.metrics._
import org.scalatest.BeforeAndAfterAll
import akka.testkit.metrics.HeapMemoryUsage
import com.codahale.metrics.{ Histogram }
import com.typesafe.config.ConfigFactory

object ActorCreationPerfSpec {

val config = ConfigFactory.parseString("""
akka.test.actor.ActorPerfSpec {
warmUp = 5
numberOfActors = 10
numberOfRepeats = 1
force-gc = off
report-metrics = off
# For serious measurements use something like the following values
#warmUp = 50000
#numberOfActors = 100000
#numberOfRepeats = 3
#force-gc = on
#report-metrics = on
}
akka.actor.serialize-messages = off
""")

final case class Create(number: Int, props: () Props)
case object Created
case object IsAlive
Expand Down Expand Up @@ -98,7 +116,7 @@ object ActorCreationPerfSpec {
}
}

class ActorCreationPerfSpec extends AkkaSpec("akka.actor.serialize-messages = off") with ImplicitSender
class ActorCreationPerfSpec extends AkkaSpec(ActorCreationPerfSpec.config) with ImplicitSender
with MetricsKit with BeforeAndAfterAll {

import ActorCreationPerfSpec._
Expand All @@ -108,9 +126,11 @@ class ActorCreationPerfSpec extends AkkaSpec("akka.actor.serialize-messages = of
val BlockingTimeKey = ActorCreationKey / "synchronous-part"
val TotalTimeKey = ActorCreationKey / "total"

val warmUp: Int = Integer.getInteger("akka.test.actor.ActorPerfSpec.warmUp", 50000)
val nrOfActors: Int = Integer.getInteger("akka.test.actor.ActorPerfSpec.numberOfActors", 100000)
val nrOfRepeats: Int = Integer.getInteger("akka.test.actor.ActorPerfSpec.numberOfRepeats", 3)
val warmUp = metricsConfig.getInt("akka.test.actor.ActorPerfSpec.warmUp")
val nrOfActors = metricsConfig.getInt("akka.test.actor.ActorPerfSpec.numberOfActors")
val nrOfRepeats = metricsConfig.getInt("akka.test.actor.ActorPerfSpec.numberOfRepeats")
override val reportMetricsEnabled = metricsConfig.getBoolean("akka.test.actor.ActorPerfSpec.report-metrics")
override val forceGcEnabled = metricsConfig.getBoolean("akka.test.actor.ActorPerfSpec.force-gc")

def runWithCounterInside(metricName: String, scenarioName: String, number: Int, propsCreator: () Props) {
val hist = histogram(BlockingTimeKey / metricName)
Expand Down
5 changes: 3 additions & 2 deletions akka-actor-tests/src/test/scala/akka/actor/ActorDSLSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import akka.event.Logging.Warning
import scala.concurrent.{ Await, Future }
import scala.concurrent.duration._
import java.util.concurrent.TimeoutException
import akka.testkit.TimingTest

class ActorDSLDummy {
//#import
Expand Down Expand Up @@ -79,7 +80,7 @@ class ActorDSLSpec extends AkkaSpec {
i.receive() should ===("hello")
}

"have a maximum queue size" in {
"have a maximum queue size" taggedAs TimingTest in {
val i = inbox()
system.eventStream.subscribe(testActor, classOf[Warning])
try {
Expand All @@ -101,7 +102,7 @@ class ActorDSLSpec extends AkkaSpec {
}
}

"have a default and custom timeouts" in {
"have a default and custom timeouts" taggedAs TimingTest in {
val i = inbox()
within(5 seconds, 6 seconds) {
intercept[TimeoutException](i.receive())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object ActorSelectionSpec {

}

class ActorSelectionSpec extends AkkaSpec("akka.loglevel=DEBUG") with DefaultTimeout {
class ActorSelectionSpec extends AkkaSpec with DefaultTimeout {
import ActorSelectionSpec._

val c1 = system.actorOf(p, "c1")
Expand Down Expand Up @@ -298,7 +298,7 @@ class ActorSelectionSpec extends AkkaSpec("akka.loglevel=DEBUG") with DefaultTim
case `c2` lastSender
}
actors should ===(Seq(c21))
expectNoMsg(1 second)
expectNoMsg(200.millis)
}

"resolve one actor with explicit timeout" in {
Expand Down
11 changes: 3 additions & 8 deletions akka-actor-tests/src/test/scala/akka/actor/ActorSystemSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,13 @@ class ActorSystemSpec extends AkkaSpec(ActorSystemSpec.config) with ImplicitSend
val system2 = ActorSystem(name = "default", config = Some(config), defaultExecutionContext = Some(ec))

try {
val ref = system2.actorOf(Props(new Actor {
def receive = {
case "ping" sender() ! "pong"
}
}))

val ref = system2.actorOf(TestActors.echoActorProps)
val probe = TestProbe()

ref.tell("ping", probe.ref)

ecProbe.expectNoMsg()
probe.expectMsg(1.second, "pong")
ecProbe.expectNoMsg(200.millis)
probe.expectMsg(1.second, "ping")
} finally {
shutdown(system2)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ConsistencySpec extends AkkaSpec(ConsistencySpec.config) {
val props = Props[ConsistencyCheckingActor].withDispatcher("consistency-dispatcher")
val actors = Vector.fill(noOfActors)(system.actorOf(props))

for (i 0L until 100000L) {
for (i 0L until 10000L) {
actors.foreach(_.tell(i, testActor))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" → true)) with I
expectMsg(Transition(fsmref, 0, 1))
}

"allow cancelling stateTimeout by issuing forMax(Duration.Inf)" in {
"allow cancelling stateTimeout by issuing forMax(Duration.Inf)" taggedAs TimingTest in {
val sys = ActorSystem("fsmEvent")
val p = TestProbe()(sys)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ReceiveTimeoutSpec extends AkkaSpec {

"An actor with receive timeout" must {

"get timeout" in {
"get timeout" taggedAs TimingTest in {
val timeoutLatch = TestLatch()

val timeoutActor = system.actorOf(Props(new Actor {
Expand All @@ -36,7 +36,7 @@ class ReceiveTimeoutSpec extends AkkaSpec {
system.stop(timeoutActor)
}

"reschedule timeout after regular receive" in {
"reschedule timeout after regular receive" taggedAs TimingTest in {
val timeoutLatch = TestLatch()

val timeoutActor = system.actorOf(Props(new Actor {
Expand All @@ -54,7 +54,7 @@ class ReceiveTimeoutSpec extends AkkaSpec {
system.stop(timeoutActor)
}

"be able to turn off timeout if desired" in {
"be able to turn off timeout if desired" taggedAs TimingTest in {
val count = new AtomicInteger(0)
val timeoutLatch = TestLatch()

Expand All @@ -77,7 +77,7 @@ class ReceiveTimeoutSpec extends AkkaSpec {
system.stop(timeoutActor)
}

"not receive timeout message when not specified" in {
"not receive timeout message when not specified" taggedAs TimingTest in {
val timeoutLatch = TestLatch()

val timeoutActor = system.actorOf(Props(new Actor {
Expand All @@ -90,7 +90,7 @@ class ReceiveTimeoutSpec extends AkkaSpec {
system.stop(timeoutActor)
}

"get timeout while receiving NotInfluenceReceiveTimeout messages" in {
"get timeout while receiving NotInfluenceReceiveTimeout messages" taggedAs TimingTest in {
val timeoutLatch = TestLatch()

val timeoutActor = system.actorOf(Props(new Actor {
Expand Down
24 changes: 12 additions & 12 deletions akka-actor-tests/src/test/scala/akka/actor/SchedulerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ trait SchedulerSpec extends BeforeAndAfterEach with DefaultTimeout with Implicit
ticks.get should ===(1)
}

"be canceled if cancel is performed before execution" in {
"be canceled if cancel is performed before execution" taggedAs TimingTest in {
val task = collectCancellable(system.scheduler.scheduleOnce(10 seconds)(()))
task.cancel() should ===(true)
task.isCancelled should ===(true)
task.cancel() should ===(false)
task.isCancelled should ===(true)
}

"not be canceled if cancel is performed after execution" in {
"not be canceled if cancel is performed after execution" taggedAs TimingTest in {
val latch = TestLatch(1)
val task = collectCancellable(system.scheduler.scheduleOnce(10 millis)(latch.countDown()))
Await.ready(latch, remainingOrDefault)
Expand Down Expand Up @@ -312,7 +312,7 @@ class LightArrayRevolverSchedulerSpec extends AkkaSpec(SchedulerSpec.testConfRev

"A LightArrayRevolverScheduler" must {

"reject tasks scheduled too far into the future" in {
"reject tasks scheduled too far into the future" taggedAs TimingTest in {
val maxDelay = tickDuration * Int.MaxValue
import system.dispatcher
system.scheduler.scheduleOnce(maxDelay, testActor, "OK")
Expand All @@ -321,7 +321,7 @@ class LightArrayRevolverSchedulerSpec extends AkkaSpec(SchedulerSpec.testConfRev
}
}

"reject periodic tasks scheduled too far into the future" in {
"reject periodic tasks scheduled too far into the future" taggedAs TimingTest in {
val maxDelay = tickDuration * Int.MaxValue
import system.dispatcher
system.scheduler.schedule(maxDelay, 1.second, testActor, "OK")
Expand All @@ -330,7 +330,7 @@ class LightArrayRevolverSchedulerSpec extends AkkaSpec(SchedulerSpec.testConfRev
}
}

"reject periodic tasks scheduled with too long interval" in {
"reject periodic tasks scheduled with too long interval" taggedAs TimingTest in {
val maxDelay = tickDuration * Int.MaxValue
import system.dispatcher
system.scheduler.schedule(100.millis, maxDelay, testActor, "OK")
Expand Down Expand Up @@ -373,7 +373,7 @@ class LightArrayRevolverSchedulerSpec extends AkkaSpec(SchedulerSpec.testConfRev
expectNoMsg(1.second)
}

"survive vicious enqueueing" in {
"survive vicious enqueueing" taggedAs TimingTest in {
withScheduler(config = ConfigFactory.parseString("akka.scheduler.ticks-per-wheel=2")) { (sched, driver)
import driver._
import system.dispatcher
Expand All @@ -396,7 +396,7 @@ class LightArrayRevolverSchedulerSpec extends AkkaSpec(SchedulerSpec.testConfRev
}
}

"execute multiple jobs at once when expiring multiple buckets" in {
"execute multiple jobs at once when expiring multiple buckets" taggedAs TimingTest in {
withScheduler() { (sched, driver)
implicit def ec = localEC
import driver._
Expand All @@ -411,7 +411,7 @@ class LightArrayRevolverSchedulerSpec extends AkkaSpec(SchedulerSpec.testConfRev
}
}

"properly defer jobs even when the timer thread oversleeps" in {
"properly defer jobs even when the timer thread oversleeps" taggedAs TimingTest in {
withScheduler() { (sched, driver)
implicit def ec = localEC
import driver._
Expand All @@ -426,7 +426,7 @@ class LightArrayRevolverSchedulerSpec extends AkkaSpec(SchedulerSpec.testConfRev
}
}

"correctly wrap around wheel rounds" in {
"correctly wrap around wheel rounds" taggedAs TimingTest in {
withScheduler(config = ConfigFactory.parseString("akka.scheduler.ticks-per-wheel=2")) { (sched, driver)
implicit def ec = localEC
import driver._
Expand All @@ -453,7 +453,7 @@ class LightArrayRevolverSchedulerSpec extends AkkaSpec(SchedulerSpec.testConfRev
}
}

"correctly execute jobs when clock wraps around" in {
"correctly execute jobs when clock wraps around" taggedAs TimingTest in {
withScheduler(Long.MaxValue - 200000000L) { (sched, driver)
implicit def ec = localEC
import driver._
Expand All @@ -480,7 +480,7 @@ class LightArrayRevolverSchedulerSpec extends AkkaSpec(SchedulerSpec.testConfRev
}
}

"correctly wrap around ticks" in {
"correctly wrap around ticks" taggedAs TimingTest in {
val numEvents = 40
val targetTicks = Int.MaxValue - numEvents + 20

Expand All @@ -507,7 +507,7 @@ class LightArrayRevolverSchedulerSpec extends AkkaSpec(SchedulerSpec.testConfRev
}
}

"reliably reject jobs when shutting down" in {
"reliably reject jobs when shutting down" taggedAs TimingTest in {
withScheduler() { (sched, driver)
import system.dispatcher
val counter = new AtomicInteger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import akka.event.Logging
import java.util.concurrent.atomic.AtomicInteger
import java.lang.System.identityHashCode
import akka.util.Helpers.ConfigOps
import akka.testkit.LongRunningTest

object SupervisorHierarchySpec {
import FSM.`→`
Expand Down Expand Up @@ -728,7 +729,7 @@ class SupervisorHierarchySpec extends AkkaSpec(SupervisorHierarchySpec.config) w

"A Supervisor Hierarchy" must {

"restart manager and workers in AllForOne" in {
"restart manager and workers in AllForOne" taggedAs LongRunningTest in {
val countDown = new CountDownLatch(4)

val boss = system.actorOf(Props(new Supervisor(OneForOneStrategy()(List(classOf[Exception])))))
Expand All @@ -749,7 +750,7 @@ class SupervisorHierarchySpec extends AkkaSpec(SupervisorHierarchySpec.config) w
}
}

"send notification to supervisor when permanent failure" in {
"send notification to supervisor when permanent failure" taggedAs LongRunningTest in {
val countDownMessages = new CountDownLatch(1)
val countDownMax = new CountDownLatch(1)
val boss = system.actorOf(Props(new Actor {
Expand All @@ -773,7 +774,7 @@ class SupervisorHierarchySpec extends AkkaSpec(SupervisorHierarchySpec.config) w
}
}

"resume children after Resume" in {
"resume children after Resume" taggedAs LongRunningTest in {
val boss = system.actorOf(Props[Resumer], "resumer")
boss ! "spawn"
val middle = expectMsgType[ActorRef]
Expand All @@ -790,7 +791,7 @@ class SupervisorHierarchySpec extends AkkaSpec(SupervisorHierarchySpec.config) w
expectMsg("pong")
}

"suspend children while failing" in {
"suspend children while failing" taggedAs LongRunningTest in {
val latch = TestLatch()
val slowResumer = system.actorOf(Props(new Actor {
override def supervisorStrategy = OneForOneStrategy() { case _ Await.ready(latch, 4.seconds.dilated); SupervisorStrategy.Resume }
Expand All @@ -816,7 +817,7 @@ class SupervisorHierarchySpec extends AkkaSpec(SupervisorHierarchySpec.config) w
expectMsg("pong")
}

"handle failure in creation when supervision startegy returns Resume and Restart" in {
"handle failure in creation when supervision startegy returns Resume and Restart" taggedAs LongRunningTest in {
val createAttempt = new AtomicInteger(0)
val preStartCalled = new AtomicInteger(0)
val postRestartCalled = new AtomicInteger(0)
Expand Down Expand Up @@ -866,7 +867,7 @@ class SupervisorHierarchySpec extends AkkaSpec(SupervisorHierarchySpec.config) w
postRestartCalled.get should ===(0)
}

"survive being stressed" in {
"survive being stressed" taggedAs LongRunningTest in {
system.eventStream.publish(Mute(
EventFilter[Failure](),
EventFilter.warning("Failure"),
Expand Down

0 comments on commit 448c12d

Please sign in to comment.