cluster.joinSeedNodes(...) does not throw warnings when seed hostname contains underscores #25287 (#27222)

This commit is contained in:
Helena Edelson 2019-07-08 05:52:22 -07:00 committed by GitHub
parent d4167bc930
commit 501848dcca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 103 additions and 20 deletions

View file

@ -4,26 +4,28 @@
package akka.cluster
import scala.concurrent.duration._
import akka.testkit.AkkaSpec
import akka.testkit.ImplicitSender
import akka.actor.ExtendedActorSystem
import akka.actor.Address
import akka.cluster.InternalClusterAction._
import java.lang.management.ManagementFactory
import javax.management.ObjectName
import akka.testkit.TestProbe
import akka.actor.ActorSystem
import akka.actor.Props
import com.typesafe.config.ConfigFactory
import akka.actor.CoordinatedShutdown
import akka.cluster.ClusterEvent.MemberEvent
import akka.cluster.ClusterEvent._
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{ Sink, Source, StreamRefs }
import scala.concurrent.Await
import scala.concurrent.duration._
import akka.actor.ActorSystem
import akka.actor.Address
import akka.actor.CoordinatedShutdown
import akka.actor.ExtendedActorSystem
import akka.actor.Props
import akka.cluster.ClusterEvent.MemberEvent
import akka.cluster.ClusterEvent._
import akka.cluster.InternalClusterAction._
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Sink
import akka.stream.scaladsl.Source
import akka.stream.scaladsl.StreamRefs
import akka.testkit.AkkaSpec
import akka.testkit.ImplicitSender
import akka.testkit.TestProbe
import com.typesafe.config.ConfigFactory
import javax.management.ObjectName
object ClusterSpec {
val config = """
@ -70,6 +72,25 @@ class ClusterSpec extends AkkaSpec(ClusterSpec.config) with ImplicitSender {
expectMsgType[InitJoinNack]
}
"fail fast in a join if invalid chars in host names, e.g. docker host given name" in {
val addresses = scala.collection.immutable
.Seq(Address("akka", "sys", Some("in_valid"), Some(0)), Address("akka", "sys", Some("invalid._org"), Some(0)))
addresses.foreach(a => intercept[IllegalArgumentException](cluster.join(a)))
intercept[IllegalArgumentException](cluster.joinSeedNodes(addresses))
}
"not fail fast to attempt a join with valid chars in host names" in {
val addresses = scala.collection.immutable.Seq(
Address("akka", "sys", Some("localhost"), Some(0)),
Address("akka", "sys", Some("is_valid.org"), Some(0)),
Address("akka", "sys", Some("fu.is_valid.org"), Some(0)),
Address("akka", "sys", Some("fu_.is_valid.org"), Some(0)))
addresses.foreach(cluster.join)
cluster.joinSeedNodes(addresses)
}
"initially become singleton cluster when joining itself and reach convergence" in {
clusterView.members.size should ===(0)
cluster.join(selfAddress)