2013-01-22 13:48:36 +01:00
|
|
|
/**
|
2016-01-25 10:16:14 +01:00
|
|
|
* Copyright (C) 2009-2016 Typesafe Inc. <http://www.typesafe.com>
|
2013-01-22 13:48:36 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package akka.io
|
|
|
|
|
|
|
|
|
|
import akka.testkit.{ TestProbe, AkkaSpec }
|
2015-04-01 14:03:06 +02:00
|
|
|
import akka.testkit.SocketUtil._
|
2013-01-22 13:48:36 +01:00
|
|
|
import Tcp._
|
|
|
|
|
|
2013-05-29 16:13:10 +02:00
|
|
|
class CapacityLimitSpec extends AkkaSpec("""
|
|
|
|
|
akka.loglevel = ERROR
|
|
|
|
|
akka.io.tcp.max-channels = 4
|
|
|
|
|
akka.actor.serialize-creators = on
|
|
|
|
|
""")
|
2013-02-06 12:17:52 +01:00
|
|
|
with TcpIntegrationSpecSupport {
|
2013-01-22 13:48:36 +01:00
|
|
|
|
|
|
|
|
"The TCP transport implementation" should {
|
|
|
|
|
|
|
|
|
|
"reply with CommandFailed to a Bind or Connect command if max-channels capacity has been reached" in new TestSetup {
|
|
|
|
|
establishNewClientConnection()
|
|
|
|
|
|
|
|
|
|
// we now have three channels registered: a listener, a server connection and a client connection
|
|
|
|
|
// so register one more channel
|
2013-01-22 14:15:37 +01:00
|
|
|
val commander = TestProbe()
|
2013-02-22 14:14:13 +01:00
|
|
|
val addresses = temporaryServerAddresses(2)
|
|
|
|
|
commander.send(IO(Tcp), Bind(bindHandler.ref, addresses(0)))
|
2013-04-13 20:53:52 +02:00
|
|
|
commander.expectMsg(Bound(addresses(0)))
|
2013-01-22 13:48:36 +01:00
|
|
|
|
|
|
|
|
// we are now at the configured max-channel capacity of 4
|
2013-01-22 14:15:37 +01:00
|
|
|
|
2013-02-22 14:14:13 +01:00
|
|
|
val bindToFail = Bind(bindHandler.ref, addresses(1))
|
2013-01-22 14:15:37 +01:00
|
|
|
commander.send(IO(Tcp), bindToFail)
|
2013-12-17 14:25:56 +01:00
|
|
|
commander.expectMsgType[CommandFailed].cmd should be theSameInstanceAs (bindToFail)
|
2013-01-22 14:15:37 +01:00
|
|
|
|
|
|
|
|
val connectToFail = Connect(endpoint)
|
|
|
|
|
commander.send(IO(Tcp), connectToFail)
|
2013-12-17 14:25:56 +01:00
|
|
|
commander.expectMsgType[CommandFailed].cmd should be theSameInstanceAs (connectToFail)
|
2013-01-22 13:48:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|