From 5b296927c17864baec4aab5626c66dc2df4d59ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Andr=C3=A9n?= Date: Tue, 6 Aug 2024 18:00:15 +0200 Subject: [PATCH] build: Get rid of some final IntegrationTest deprecation warnings (#1292) * build: Get rid of some final IntegrationTest deprecation warnings --- .../aws-api-ec2/aws-api-ec2-tag-based.sh | 4 +- integration-test/aws-api-ec2/build.sbt | 6 +- .../{it => test}/resources/application.conf | 0 .../cluster/bootstrap/IntegrationTest.scala | 76 ++++++++++--------- 4 files changed, 47 insertions(+), 39 deletions(-) rename integration-test/aws-api-ec2/src/{it => test}/resources/application.conf (100%) rename integration-test/aws-api-ec2/src/{it => test}/scala/akka/cluster/bootstrap/IntegrationTest.scala (75%) diff --git a/integration-test/aws-api-ec2/aws-api-ec2-tag-based.sh b/integration-test/aws-api-ec2/aws-api-ec2-tag-based.sh index 2227746db..ea38f21a6 100755 --- a/integration-test/aws-api-ec2/aws-api-ec2-tag-based.sh +++ b/integration-test/aws-api-ec2/aws-api-ec2-tag-based.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# Note: this seems completely outdated and is not used by CI + echo Running integration tests for aws-api-ec2-tag-based echo You need to run this from the root folder of the akka-management project @@ -17,6 +19,6 @@ sbt bootstrap-demo-aws-api-ec2-tag-based/universal:packageBin aws s3api create-bucket --bucket $BUCKET --region us-east-1 aws s3 cp bootstrap-demo/aws-api-ec2/target/universal/app.zip s3://$BUCKET/$BUILD_ID/ --acl public-read # run the actual integration test -sbt bootstrap-demo-aws-api-ec2-tag-based/it:test +sbt bootstrap-demo-aws-api-ec2-tag-based/test # delete file (save a few cents) aws s3 rm s3://$BUCKET/$BUILD_ID/app.zip diff --git a/integration-test/aws-api-ec2/build.sbt b/integration-test/aws-api-ec2/build.sbt index 73fb91740..960dc6ba5 100644 --- a/integration-test/aws-api-ec2/build.sbt +++ b/integration-test/aws-api-ec2/build.sbt @@ -4,10 +4,10 @@ resolvers += "Akka library repository".at("https://repo.akka.io/maven") Universal / packageName := "app" // should produce app.zip -libraryDependencies += "com.amazonaws" % "aws-java-sdk-cloudformation" % "1.12.635" % IntegrationTest +libraryDependencies += "com.amazonaws" % "aws-java-sdk-cloudformation" % "1.12.635" % Test -libraryDependencies += "com.amazonaws" % "aws-java-sdk-autoscaling" % "1.12.635" % IntegrationTest +libraryDependencies += "com.amazonaws" % "aws-java-sdk-autoscaling" % "1.12.635" % Test libraryDependencies += "com.fasterxml.jackson.core" % "jackson-databind" % "2.15.3" // aws SDK depends on insecure jackson -libraryDependencies += "org.scalatest" %% "scalatest" % Dependencies.ScalaTestVersion % IntegrationTest +libraryDependencies += "org.scalatest" %% "scalatest" % Dependencies.ScalaTestVersion % Test diff --git a/integration-test/aws-api-ec2/src/it/resources/application.conf b/integration-test/aws-api-ec2/src/test/resources/application.conf similarity index 100% rename from integration-test/aws-api-ec2/src/it/resources/application.conf rename to integration-test/aws-api-ec2/src/test/resources/application.conf diff --git a/integration-test/aws-api-ec2/src/it/scala/akka/cluster/bootstrap/IntegrationTest.scala b/integration-test/aws-api-ec2/src/test/scala/akka/cluster/bootstrap/IntegrationTest.scala similarity index 75% rename from integration-test/aws-api-ec2/src/it/scala/akka/cluster/bootstrap/IntegrationTest.scala rename to integration-test/aws-api-ec2/src/test/scala/akka/cluster/bootstrap/IntegrationTest.scala index c4399656b..7e1b8a713 100644 --- a/integration-test/aws-api-ec2/src/it/scala/akka/cluster/bootstrap/IntegrationTest.scala +++ b/integration-test/aws-api-ec2/src/test/scala/akka/cluster/bootstrap/IntegrationTest.scala @@ -1,27 +1,28 @@ /* - * Copyright (C) 2017 Lightbend Inc. + * Copyright (C) 2017-2023 Lightbend Inc. */ + package akka.cluster.bootstrap 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 +36,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 +89,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 +130,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 +154,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 +195,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 +232,4 @@ class IntegrationTest system.terminate() } - }