Stab at fixing more tests with timeout issues on Jenkins
This commit is contained in:
parent
386506727f
commit
8bca635279
3 changed files with 21 additions and 23 deletions
|
|
@ -20,21 +20,16 @@ class ActivationIntegrationTest extends WordSpec with MustMatchers with SharedCa
|
||||||
implicit val timeout = Timeout(10 seconds)
|
implicit val timeout = Timeout(10 seconds)
|
||||||
def template: ProducerTemplate = camel.template
|
def template: ProducerTemplate = camel.template
|
||||||
|
|
||||||
def testActorWithEndpoint(uri: String): ActorRef = { system.actorOf(Props(new TestConsumer(uri))) }
|
|
||||||
|
|
||||||
"ActivationAware must be notified when endpoint is activated" in {
|
"ActivationAware must be notified when endpoint is activated" in {
|
||||||
val actor = testActorWithEndpoint("direct:actor-1")
|
val latch = new TestLatch(0)
|
||||||
try {
|
val actor = system.actorOf(Props(new TestConsumer("direct:actor-1", latch)))
|
||||||
camel.awaitActivation(actor, 1 second)
|
camel.awaitActivation(actor, 10 second) must be === actor
|
||||||
} catch {
|
|
||||||
case e: ActivationTimeoutException ⇒ fail("Failed to get notification within 1 second")
|
|
||||||
}
|
|
||||||
|
|
||||||
template.requestBody("direct:actor-1", "test") must be("received test")
|
template.requestBody("direct:actor-1", "test") must be("received test")
|
||||||
}
|
}
|
||||||
|
|
||||||
"ActivationAware must be notified when endpoint is de-activated" in {
|
"ActivationAware must be notified when endpoint is de-activated" in {
|
||||||
val latch = TestLatch()
|
val latch = TestLatch(1)
|
||||||
val actor = start(new Consumer {
|
val actor = start(new Consumer {
|
||||||
def endpointUri = "direct:a3"
|
def endpointUri = "direct:a3"
|
||||||
def receive = { case _ ⇒ {} }
|
def receive = { case _ ⇒ {} }
|
||||||
|
|
@ -44,30 +39,33 @@ class ActivationIntegrationTest extends WordSpec with MustMatchers with SharedCa
|
||||||
latch.countDown()
|
latch.countDown()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
camel.awaitActivation(actor, 1 second)
|
camel.awaitActivation(actor, 10 second)
|
||||||
|
|
||||||
system.stop(actor)
|
system.stop(actor)
|
||||||
camel.awaitDeactivation(actor, 1 second)
|
camel.awaitDeactivation(actor, 10 second)
|
||||||
Await.ready(latch, 1 second)
|
Await.ready(latch, 10 second)
|
||||||
}
|
}
|
||||||
|
|
||||||
"ActivationAware must time out when waiting for endpoint de-activation for too long" in {
|
"ActivationAware must time out when waiting for endpoint de-activation for too long" in {
|
||||||
val actor = start(new TestConsumer("direct:a5"))
|
val latch = new TestLatch(0)
|
||||||
camel.awaitActivation(actor, 1 second)
|
val actor = start(new TestConsumer("direct:a5", latch))
|
||||||
|
camel.awaitActivation(actor, 10 second)
|
||||||
intercept[DeActivationTimeoutException] {
|
intercept[DeActivationTimeoutException] {
|
||||||
camel.awaitDeactivation(actor, 1 millis)
|
camel.awaitDeactivation(actor, 1 millis)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"awaitActivation must fail if notification timeout is too short and activation is not complete yet" in {
|
"awaitActivation must fail if notification timeout is too short and activation is not complete yet" in {
|
||||||
val actor = testActorWithEndpoint("direct:actor-4")
|
val latch = new TestLatch(1)
|
||||||
intercept[ActivationTimeoutException] {
|
try {
|
||||||
camel.awaitActivation(actor, 1 millis)
|
val actor = system.actorOf(Props(new TestConsumer("direct:actor-4", latch)))
|
||||||
}
|
intercept[ActivationTimeoutException] { camel.awaitActivation(actor, 1 millis) }
|
||||||
|
} finally latch.countDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestConsumer(uri: String) extends Consumer {
|
class TestConsumer(uri: String, latch: TestLatch) extends Consumer {
|
||||||
def endpointUri = uri
|
def endpointUri = uri
|
||||||
|
Await.ready(latch, 60 seconds)
|
||||||
override def receive = {
|
override def receive = {
|
||||||
case msg: CamelMessage ⇒ sender ! "received " + msg.body
|
case msg: CamelMessage ⇒ sender ! "received " + msg.body
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,19 +7,19 @@ package akka.camel
|
||||||
import language.postfixOps
|
import language.postfixOps
|
||||||
import language.implicitConversions
|
import language.implicitConversions
|
||||||
|
|
||||||
import akka.actor.{ Props, ActorSystem, Actor }
|
|
||||||
import scala.concurrent.util.duration._
|
import scala.concurrent.util.duration._
|
||||||
import java.util.concurrent.{ TimeoutException, ExecutionException, TimeUnit }
|
import java.util.concurrent.{ TimeoutException, ExecutionException, TimeUnit }
|
||||||
import org.scalatest.{ BeforeAndAfterEach, BeforeAndAfterAll, Suite }
|
import org.scalatest.{ BeforeAndAfterEach, BeforeAndAfterAll, Suite }
|
||||||
import org.scalatest.matchers.{ BePropertyMatcher, BePropertyMatchResult }
|
import org.scalatest.matchers.{ BePropertyMatcher, BePropertyMatchResult }
|
||||||
import scala.concurrent.util.{ FiniteDuration, Duration }
|
import scala.concurrent.util.{ FiniteDuration, Duration }
|
||||||
import scala.reflect.ClassTag
|
import scala.reflect.ClassTag
|
||||||
|
import akka.actor.{ ActorRef, Props, ActorSystem, Actor }
|
||||||
|
|
||||||
private[camel] object TestSupport {
|
private[camel] object TestSupport {
|
||||||
|
|
||||||
def start(actor: ⇒ Actor)(implicit system: ActorSystem) = {
|
def start(actor: ⇒ Actor)(implicit system: ActorSystem): ActorRef = {
|
||||||
val actorRef = system.actorOf(Props(actor))
|
val actorRef = system.actorOf(Props(actor))
|
||||||
CamelExtension(system).awaitActivation(actorRef, 1 second)
|
CamelExtension(system).awaitActivation(actorRef, 10 seconds)
|
||||||
actorRef
|
actorRef
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ public class FaultHandlingTestBase {
|
||||||
|
|
||||||
//#escalate-restart
|
//#escalate-restart
|
||||||
superprops = new Props(Supervisor2.class);
|
superprops = new Props(Supervisor2.class);
|
||||||
supervisor = system.actorOf(superprops, "supervisor2");
|
supervisor = system.actorOf(superprops);
|
||||||
child = (ActorRef) Await.result(ask(supervisor, new Props(Child.class), 5000), timeout);
|
child = (ActorRef) Await.result(ask(supervisor, new Props(Child.class), 5000), timeout);
|
||||||
child.tell(23);
|
child.tell(23);
|
||||||
assert Await.result(ask(child, "get", 5000), timeout).equals(23);
|
assert Await.result(ask(child, "get", 5000), timeout).equals(23);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue