Re-enable multicast tests (#28252)

* Re-enable multicast tests #28147

Some change on jenkins node a4 seems to have made the test pass again.
This commit is contained in:
Johan Andrén 2019-11-26 18:45:31 +01:00 committed by Arnout Engelen
parent f2f3f64f21
commit a9d545bf2b
2 changed files with 24 additions and 15 deletions

View file

@ -31,10 +31,6 @@ public class JavaUdpMulticastTest extends AbstractJavaTest {
}
@Test
public void dummy() {}
// disabled until we figure #28147 out
// @Test
public void testUdpMulticast() throws Exception {
new TestKit(system) {
{

View file

@ -4,20 +4,26 @@
package docs.io
import java.net.{ Inet6Address, InetSocketAddress, NetworkInterface, StandardProtocolFamily }
import java.nio.channels.DatagramChannel
import scala.util.Random
import akka.actor.{ ActorSystem, Props }
import java.net.Inet6Address
import java.net.NetworkInterface
import akka.Done
import akka.actor.ActorSystem
import akka.actor.Props
import akka.io.Udp
import akka.testkit.TestKit
import org.scalatest.{ BeforeAndAfter, WordSpecLike }
import org.scalatest.BeforeAndAfterAll
import akka.testkit.SocketUtil
import akka.testkit.TestKit
import akka.util.ccompat.JavaConverters._
import org.scalatest.BeforeAndAfterAll
import org.scalatest.Matchers
import org.scalatest.WordSpecLike
import scala.util.Random
class ScalaUdpMulticastSpec
extends TestKit(ActorSystem("ScalaUdpMulticastSpec"))
with WordSpecLike
with Matchers
with BeforeAndAfterAll {
"listener" should {
@ -37,7 +43,11 @@ class ScalaUdpMulticastSpec
// on the platform (awsdl0 can't be used on OSX, docker[0-9] can't be used in a docker machine etc.)
// therefore: try hard to find an interface that _does_ work, and only fail if there was any potentially
// working interfaces but all failed
ipv6ifaces.exists { ipv6iface =>
var failures: List[AssertionError] = Nil
var foundOneThatWorked = false
val iterator = ipv6ifaces.iterator
while (!foundOneThatWorked && iterator.hasNext) {
val ipv6iface = iterator.next()
// host assigned link local multicast address http://tools.ietf.org/html/rfc3307#section-4.3.2
// generate a random 32 bit multicast address with the high order bit set
val randomAddress: String = (Random.nextInt().abs.toLong | (1L << 31)).toHexString.toUpperCase
@ -52,18 +62,21 @@ class ScalaUdpMulticastSpec
val sender = system.actorOf(Props(classOf[Sender], iface, group, port, msg))
// fails here, so binding succeeds but sending a message does not
expectMsg(msg)
true
foundOneThatWorked = true
} catch {
case _: AssertionError =>
case ex: AssertionError =>
system.log.info("Failed to run test on interface {}", ipv6iface.getDisplayName)
false
failures = ex :: failures
} finally {
// unbind
system.stop(listener)
}
}
if (failures.size == ipv6ifaces.size)
fail(s"Multicast failed on all available interfaces: ${failures}")
}
}