Some more quietening of tests

This commit is contained in:
Peter Vlugter 2011-08-05 18:41:29 +12:00
parent 562ebd9490
commit 0057acdd81
6 changed files with 121 additions and 40 deletions

View file

@ -0,0 +1,58 @@
# Define some default values that can be overridden by system properties
zookeeper.root.logger=INFO, CONSOLE
zookeeper.console.threshold=OFF
zookeeper.log.dir=.
zookeeper.log.file=zookeeper.log
zookeeper.log.threshold=DEBUG
zookeeper.tracelog.dir=.
zookeeper.tracelog.file=zookeeper_trace.log
#
# ZooKeeper Logging Configuration
#
# Format is "<default threshold> (, <appender>)+
# DEFAULT: console appender only
log4j.rootLogger=${zookeeper.root.logger}
# Example with rolling log file
#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE
# Example with rolling log file and tracing
#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE
#
# Log INFO level and above messages to the console
#
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=${zookeeper.console.threshold}
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n
#
# Add ROLLINGFILE to rootLogger to get log file output
# Log DEBUG level and above messages to a log file
log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold}
log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file}
# Max log file size of 10MB
log4j.appender.ROLLINGFILE.MaxFileSize=10MB
# uncomment the next line to limit number of backup files
#log4j.appender.ROLLINGFILE.MaxBackupIndex=10
log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n
#
# Add TRACEFILE to rootLogger to get log file output
# Log DEBUG level and above messages to a log file
log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
log4j.appender.TRACEFILE.Threshold=TRACE
log4j.appender.TRACEFILE.File=${zookeeper.tracelog.dir}/${zookeeper.tracelog.file}
log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
### Notice we are including log4j's NDC here (%x)
log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L][%x] - %m%n

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="false" debug="false">
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[%4p] [%d{ISO8601}] [%t] %c{1}: %m%n</pattern>
</encoder>
</appender>
<root level="OFF">
<appender-ref ref="stdout"/>
</root>
</configuration>

View file

@ -5,9 +5,10 @@ import org.scalatest.matchers.MustMatchers
import org.scalatest.BeforeAndAfterAll
import akka.transactor.Coordinated
import akka.actor.{ Actor, ActorRef }
import akka.actor.{ Actor, ActorRef, ActorTimeoutException }
import akka.stm.{ Ref, TransactionFactory }
import akka.util.duration._
import akka.event.EventHandler
import akka.transactor.CoordinatedTransactionException
import akka.testkit._
@ -80,19 +81,21 @@ class CoordinatedIncrementSpec extends WordSpec with MustMatchers with BeforeAnd
}
"increment no counters with a failing transaction" in {
filterException[ExpectedFailureException] {
filterException[CoordinatedTransactionException] {
val (counters, failer) = createActors
val coordinated = Coordinated()
counters(0) ! Coordinated(Increment(counters.tail :+ failer))
coordinated.await
for (counter counters) {
(counter ? GetCount).as[Int].get must be === 0
}
counters foreach (_.stop())
failer.stop()
}
val ignoreExceptions = Seq(
EventFilter[ExpectedFailureException],
EventFilter[CoordinatedTransactionException],
EventFilter[ActorTimeoutException])
EventHandler.notify(TestEvent.Mute(ignoreExceptions))
val (counters, failer) = createActors
val coordinated = Coordinated()
counters(0) ! Coordinated(Increment(counters.tail :+ failer))
coordinated.await
for (counter counters) {
(counter ? GetCount).as[Int].get must be === 0
}
counters foreach (_.stop())
failer.stop()
EventHandler.notify(TestEvent.UnMute(ignoreExceptions))
}
}
}

View file

@ -5,9 +5,10 @@ import org.scalatest.matchers.MustMatchers
import org.scalatest.BeforeAndAfterAll
import akka.transactor.Coordinated
import akka.actor.{ Actor, ActorRef }
import akka.actor.{ Actor, ActorRef, ActorTimeoutException }
import akka.stm._
import akka.util.duration._
import akka.event.EventHandler
import akka.transactor.CoordinatedTransactionException
import akka.testkit._
@ -110,20 +111,22 @@ class FickleFriendsSpec extends WordSpec with MustMatchers with BeforeAndAfterAl
"Coordinated fickle friends" should {
"eventually succeed to increment all counters by one" in {
filterException[ExpectedFailureException] {
filterException[CoordinatedTransactionException] {
val (counters, coordinator) = createActors
val latch = new CountDownLatch(1)
coordinator ! FriendlyIncrement(counters, latch)
latch.await // this could take a while
(coordinator ? GetCount).as[Int].get must be === 1
for (counter counters) {
(counter ? GetCount).as[Int].get must be === 1
}
counters foreach (_.stop())
coordinator.stop()
}
val ignoreExceptions = Seq(
EventFilter[ExpectedFailureException],
EventFilter[CoordinatedTransactionException],
EventFilter[ActorTimeoutException])
EventHandler.notify(TestEvent.Mute(ignoreExceptions))
val (counters, coordinator) = createActors
val latch = new CountDownLatch(1)
coordinator ! FriendlyIncrement(counters, latch)
latch.await // this could take a while
(coordinator ? GetCount).as[Int].get must be === 1
for (counter counters) {
(counter ? GetCount).as[Int].get must be === 1
}
counters foreach (_.stop())
coordinator.stop()
EventHandler.notify(TestEvent.UnMute(ignoreExceptions))
}
}
}

View file

@ -4,9 +4,10 @@ import org.scalatest.WordSpec
import org.scalatest.matchers.MustMatchers
import akka.transactor.Transactor
import akka.actor.{ Actor, ActorRef }
import akka.actor.{ Actor, ActorRef, ActorTimeoutException }
import akka.stm._
import akka.util.duration._
import akka.event.EventHandler
import akka.transactor.CoordinatedTransactionException
import akka.testkit._
@ -103,19 +104,21 @@ class TransactorSpec extends WordSpec with MustMatchers {
}
"increment no counters with a failing transaction" in {
filterException[ExpectedFailureException] {
filterException[CoordinatedTransactionException] {
val (counters, failer) = createTransactors
val failLatch = new CountDownLatch(numCounters + 1)
counters(0) ! Increment(counters.tail :+ failer, failLatch)
failLatch.await(timeout.length, timeout.unit)
for (counter counters) {
(counter ? GetCount).as[Int].get must be === 0
}
counters foreach (_.stop())
failer.stop()
}
val ignoreExceptions = Seq(
EventFilter[ExpectedFailureException],
EventFilter[CoordinatedTransactionException],
EventFilter[ActorTimeoutException])
EventHandler.notify(TestEvent.Mute(ignoreExceptions))
val (counters, failer) = createTransactors
val failLatch = new CountDownLatch(numCounters + 1)
counters(0) ! Increment(counters.tail :+ failer, failLatch)
failLatch.await(timeout.length, timeout.unit)
for (counter counters) {
(counter ? GetCount).as[Int].get must be === 0
}
counters foreach (_.stop())
failer.stop()
EventHandler.notify(TestEvent.UnMute(ignoreExceptions))
}
}

View file

@ -229,6 +229,8 @@ class TestActorRefSpec extends WordSpec with MustMatchers with BeforeAndAfterEac
val boss = Actor.actorOf(new Actor { def receive = { case _ } }).start()
val ref = TestActorRef[WorkerActor].start()
val filter = EventFilter.custom(_ true)
EventHandler.notify(TestEvent.Mute(filter))
val log = TestActorRef[Logger]
EventHandler.addListener(log)
boss link ref
@ -236,6 +238,7 @@ class TestActorRefSpec extends WordSpec with MustMatchers with BeforeAndAfterEac
la.count must be(1)
la.msg must (include("supervisor") and include("CallingThreadDispatcher"))
EventHandler.removeListener(log)
EventHandler.notify(TestEvent.UnMute(filter))
}
"proxy apply for the underlying actor" in {