Skip to content

Commit fdefb91

Browse files
committed
Update BootstrapCoordinatorSpec.scala
1 parent 38b47ba commit fdefb91

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

management-cluster-bootstrap/src/test/scala/org/apache/pekko/management/cluster/bootstrap/internal/BootstrapCoordinatorSpec.scala

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import org.scalatest.wordspec.AnyWordSpec
3434
class BootstrapCoordinatorSpec extends AnyWordSpec with Matchers with BeforeAndAfterAll with Eventually {
3535
val serviceName = "bootstrap-coordinator-test-service"
3636
val selfUri = Uri("http://localhost:7626/")
37+
val secureSelfUri = Uri("https://localhost:7626/")
3738
val system = ActorSystem(
3839
"test",
3940
ConfigFactory.parseString(s"""
@@ -87,6 +88,42 @@ class BootstrapCoordinatorSpec extends AnyWordSpec with Matchers with BeforeAndA
8788
}
8889
}
8990

91+
"probe only on the Pekko Management port (https)" in {
92+
93+
MockDiscovery.set(
94+
Lookup(serviceName, portName = None, protocol = Some("tcp")),
95+
() =>
96+
Future.successful(
97+
Resolved(
98+
serviceName,
99+
List(
100+
ResolvedTarget("host1", Some(7355), None),
101+
ResolvedTarget("host1", Some(7626), None),
102+
ResolvedTarget("host2", Some(7355), None),
103+
ResolvedTarget("host2", Some(7626), None)))))
104+
105+
val targets = new AtomicReference[List[ResolvedTarget]](Nil)
106+
val coordinator = system.actorOf(
107+
Props(new BootstrapCoordinator(discovery, joinDecider, settings) {
108+
override def ensureProbing(
109+
selfContactPointScheme: String,
110+
contactPoint: ResolvedTarget): Option[ActorRef] = {
111+
println(s"Resolving $contactPoint")
112+
val targetsSoFar = targets.get
113+
targets.compareAndSet(targetsSoFar, contactPoint +: targetsSoFar)
114+
None
115+
}
116+
}))
117+
coordinator ! InitiateBootstrapping(secureSelfUri)
118+
eventually {
119+
val targetsToCheck = targets.get
120+
targetsToCheck.length should be >= 2
121+
targetsToCheck.map(_.host) should contain("host1")
122+
targetsToCheck.map(_.host) should contain("host2")
123+
targetsToCheck.flatMap(_.port).toSet should be(Set(7626))
124+
}
125+
}
126+
90127
"probe all hosts with fallback port" in {
91128

92129
MockDiscovery.set(

0 commit comments

Comments
 (0)