Skip to content

Commit 1fec922

Browse files
committed
extra test
1 parent ca6f886 commit 1fec922

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

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

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,23 @@
1414
package org.apache.pekko.management.cluster.bootstrap.internal
1515

1616
import java.util.concurrent.atomic.AtomicReference
17+
1718
import org.apache.pekko
1819
import pekko.actor.{ ActorRef, ActorSystem, Props }
1920
import pekko.discovery.ServiceDiscovery.{ Resolved, ResolvedTarget }
2021
import pekko.discovery.{ Lookup, MockDiscovery }
2122
import pekko.http.scaladsl.model.Uri
22-
import com.typesafe.config.ConfigFactory
2323
import pekko.management.cluster.bootstrap.internal.BootstrapCoordinator.Protocol.InitiateBootstrapping
2424
import pekko.management.cluster.bootstrap.{ ClusterBootstrapSettings, LowestAddressJoinDecider }
25-
import org.scalatest.concurrent.Eventually
25+
import com.typesafe.config.ConfigFactory
2626
import org.scalatest.BeforeAndAfterAll
27+
import org.scalatest.concurrent.Eventually
28+
import org.scalatest.matchers.should.Matchers
2729
import org.scalatest.time.{ Millis, Seconds, Span }
30+
import org.scalatest.wordspec.AnyWordSpec
2831

2932
import scala.concurrent.{ Await, Future }
3033
import scala.concurrent.duration._
31-
import org.scalatest.matchers.should.Matchers
32-
import org.scalatest.wordspec.AnyWordSpec
3334

3435
class BootstrapCoordinatorSpec extends AnyWordSpec with Matchers with BeforeAndAfterAll with Eventually {
3536
val serviceName = "bootstrap-coordinator-test-service"
@@ -156,6 +157,39 @@ class BootstrapCoordinatorSpec extends AnyWordSpec with Matchers with BeforeAndA
156157
targetsToCheck.flatMap(_.port).toSet shouldBe empty
157158
}
158159
}
160+
161+
"probe all hosts with fallback port (https)" in {
162+
163+
MockDiscovery.set(
164+
Lookup(serviceName, portName = None, protocol = Some("tcp")),
165+
() =>
166+
Future.successful(
167+
Resolved(
168+
serviceName,
169+
List(
170+
ResolvedTarget("host1", None, None),
171+
ResolvedTarget("host1", None, None),
172+
ResolvedTarget("host2", None, None),
173+
ResolvedTarget("host2", None, None)))))
174+
175+
val targets = new AtomicReference[List[ResolvedTarget]](Nil)
176+
val coordinator = system.actorOf(Props(new BootstrapCoordinator(discovery, joinDecider, settings) {
177+
override def ensureProbing(selfContactPointScheme: String, contactPoint: ResolvedTarget): Option[ActorRef] = {
178+
println(s"Resolving $contactPoint")
179+
val targetsSoFar = targets.get
180+
targets.compareAndSet(targetsSoFar, contactPoint +: targetsSoFar)
181+
None
182+
}
183+
}))
184+
coordinator ! InitiateBootstrapping(secureSelfUri)
185+
eventually {
186+
val targetsToCheck = targets.get
187+
targetsToCheck.length should be >= 2
188+
targetsToCheck.map(_.host) should contain("host1")
189+
targetsToCheck.map(_.host) should contain("host2")
190+
targetsToCheck.flatMap(_.port).toSet shouldBe empty
191+
}
192+
}
159193
}
160194

161195
"BootstrapCoordinator target filtering" should {

0 commit comments

Comments
 (0)