From dedc32d4931964a1691b26a58708b6e9a04639f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Andr=C3=A9n?= Date: Tue, 21 May 2024 11:16:55 +0200 Subject: [PATCH] formatting --- .../cluster/bootstrap/IntegrationTest.scala | 73 ++++++++++--------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/integration-test/aws-api-ec2/src/test/scala/akka/cluster/bootstrap/IntegrationTest.scala b/integration-test/aws-api-ec2/src/test/scala/akka/cluster/bootstrap/IntegrationTest.scala index c4399656b..8ef7e725d 100644 --- a/integration-test/aws-api-ec2/src/test/scala/akka/cluster/bootstrap/IntegrationTest.scala +++ b/integration-test/aws-api-ec2/src/test/scala/akka/cluster/bootstrap/IntegrationTest.scala @@ -7,21 +7,21 @@ import akka.actor.ActorSystem import akka.event.Logging import akka.http.scaladsl.Http import akka.http.scaladsl.model.HttpRequest -import akka.management.cluster.{ClusterHttpManagementJsonProtocol, ClusterMembers} +import akka.management.cluster.{ ClusterHttpManagementJsonProtocol, ClusterMembers } import akka.util.ByteString import com.amazonaws.services.cloudformation.AmazonCloudFormationClientBuilder import com.amazonaws.services.cloudformation.model._ import com.amazonaws.services.ec2.AmazonEC2ClientBuilder -import com.amazonaws.services.ec2.model.{DescribeInstancesRequest, Filter, Reservation} -import org.scalatest.concurrent.PatienceConfiguration.{Interval, Timeout} -import org.scalatest.concurrent.{Eventually, ScalaFutures} -import org.scalatest.time.{Seconds, Span, SpanSugar} +import com.amazonaws.services.ec2.model.{ DescribeInstancesRequest, Filter, Reservation } +import org.scalatest.concurrent.PatienceConfiguration.{ Interval, Timeout } +import org.scalatest.concurrent.{ Eventually, ScalaFutures } +import org.scalatest.time.{ Seconds, Span, SpanSugar } import org.scalatest.BeforeAndAfterAll import org.scalatest.funsuite.AnyFunSuite import org.scalatest.matchers.should.Matchers import spray.json._ -import scala.concurrent.{Await, Future} +import scala.concurrent.{ Await, Future } import scala.language.postfixOps trait HttpClient { @@ -35,16 +35,21 @@ trait HttpClient { val http = Http() def httpGetRequest(url: String): Future[(Int, String)] = { - http.singleRequest(HttpRequest(uri = url)) + http + .singleRequest(HttpRequest(uri = url)) .flatMap(r => r.entity.toStrict(3 seconds).map(s => r.status -> s)) - .flatMap(t => t._2.dataBytes.runFold(ByteString.empty)(_ ++ _).map(_.utf8String).map(_.filter(_ >= ' ')) - .map(r => t._1.intValue() -> r)) + .flatMap(t => + t._2.dataBytes + .runFold(ByteString.empty)(_ ++ _) + .map(_.utf8String) + .map(_.filter(_ >= ' ')) + .map(r => t._1.intValue() -> r)) } } class IntegrationTest - extends AnyFunSuite + extends AnyFunSuite with Eventually with BeforeAndAfterAll with ScalaFutures @@ -83,10 +88,10 @@ class IntegrationTest // Once the CloudFormation stack has CREATE_COMPLETE status, the EC2 instances are // still "initializing" (seems to take a very long time) so we add some additional patience for that. private val clusterBootstrapPatience: PatienceConfig = - PatienceConfig( - timeout = 12 minutes, - interval = 5 seconds - ) + PatienceConfig( + timeout = 12 minutes, + interval = 5 seconds + ) private var clusterPublicIps: List[String] = List() @@ -124,8 +129,8 @@ class IntegrationTest def conditions: Boolean = (dsr.getStacks.size() == 1) && { val stack = dsr.getStacks.get(0) stack.getStackStatus == StackStatus.CREATE_COMPLETE.toString && - stack.getOutputs.size() >= 1 && - stack.getOutputs.asScala.exists(_.getOutputKey == "AutoScalingGroupName") + stack.getOutputs.size() >= 1 && + stack.getOutputs.asScala.exists(_.getOutputKey == "AutoScalingGroupName") } implicit val patienceConfig: PatienceConfig = createStackPatience @@ -148,15 +153,14 @@ class IntegrationTest dsr.getStacks.get(0).getOutputs.asScala.find(_.getOutputKey == "AutoScalingGroupName").get.getOutputValue val ips: List[(String, String)] = awsEc2Client - .describeInstances(new DescribeInstancesRequest() - .withFilters(new Filter("tag:aws:autoscaling:groupName", List(asgName).asJava))) + .describeInstances( + new DescribeInstancesRequest().withFilters(new Filter("tag:aws:autoscaling:groupName", List(asgName).asJava))) .getReservations .asScala .flatMap((r: Reservation) => r.getInstances.asScala.map(instance => (instance.getPublicIpAddress, instance.getPrivateIpAddress))) .toList - .filter(ips => - ips._1 != null && ips._2 != null) // TODO: investigate whether there are edge cases that may makes this necessary + .filter(ips => ips._1 != null && ips._2 != null) // TODO: investigate whether there are edge cases that may makes this necessary clusterPublicIps = ips.map(_._1) clusterPrivateIps = ips.map(_._2) @@ -190,25 +194,27 @@ class IntegrationTest eventually { - log.info("querying the Cluster Http Management interface of each node, eventually we should see a well formed cluster") + log.info( + "querying the Cluster Http Management interface of each node, eventually we should see a well formed cluster") - clusterPublicIps.foreach { nodeIp => { + clusterPublicIps.foreach { nodeIp => + { - val result = httpGetRequest(s"http://$nodeIp:8558/cluster/members").futureValue(httpCallTimeout) - result._1 should ===(200) - result._2.nonEmpty should be (true) + val result = httpGetRequest(s"http://$nodeIp:8558/cluster/members").futureValue(httpCallTimeout) + result._1 should ===(200) + result._2.nonEmpty should be(true) - val clusterMembers = result._2.parseJson.convertTo[ClusterMembers] + val clusterMembers = result._2.parseJson.convertTo[ClusterMembers] - clusterMembers.members should have size instanceCount - clusterMembers.members.count(_.status == "Up") should ===(instanceCount) - clusterMembers.members.map(_.node) should ===(expectedNodes) + clusterMembers.members should have size instanceCount + clusterMembers.members.count(_.status == "Up") should ===(instanceCount) + clusterMembers.members.map(_.node) should ===(expectedNodes) - clusterMembers.unreachable.isEmpty should be(true) - clusterMembers.leader shouldBe defined - clusterMembers.oldest shouldBe defined + clusterMembers.unreachable.isEmpty should be(true) + clusterMembers.leader shouldBe defined + clusterMembers.oldest shouldBe defined - } + } } } } @@ -225,5 +231,4 @@ class IntegrationTest system.terminate() } - }