From 08bd5dca5076cdd9fb51fc4d29f806e5185c72d9 Mon Sep 17 00:00:00 2001 From: Ryan Means Date: Wed, 13 Jul 2016 10:13:02 -0400 Subject: [PATCH] Add Travis (#2) * Add travis and bump coverage min. * fix issues with test order and akka system cleanup --- .travis.yml | 12 ++++++++++++ README.md | 2 ++ app/global/AppGlobalSettings.scala | 5 +++-- build.sbt | 2 +- conf/application.test.conf | 4 ++-- test/actors/workflow/tasks/ASGInfoSpec.scala | 8 ++++++-- test/actors/workflow/tasks/ASGSizeSpec.scala | 8 ++++++-- test/actors/workflow/tasks/DeleteStackSpec.scala | 8 ++++++-- .../tasks/ELBHealthInstanceCheckerSpec.scala | 8 ++++++-- test/actors/workflow/tasks/FreezeASGSpec.scala | 8 ++++++-- .../tasks/StackCreateCompleteMonitorSpec.scala | 7 +++++-- test/actors/workflow/tasks/StackCreatorSpec.scala | 7 +++++-- .../tasks/StackDeleteCompleteMonitorSpec.scala | 8 ++++++-- test/actors/workflow/tasks/StackInfoSpec.scala | 8 ++++++-- test/actors/workflow/tasks/StackListSpec.scala | 7 +++++-- test/actors/workflow/tasks/StackLoaderSpec.scala | 8 ++++++-- test/actors/workflow/tasks/UnfreezeASGSpec.scala | 8 ++++++-- test/controllers/ApplicationSpec.scala | 8 ++++++-- test/functional/WorkflowManagerSystemTest.scala | 8 ++++++-- 19 files changed, 101 insertions(+), 33 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b6333f4 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +jdk: + - oraclejdk8 +language: scala +script: sbt clean compile coverage test +before_cache: + - find $HOME/.ivy2 -name "ivydata-*.properties" -delete + - find $HOME/.sbt -name "*.lock" -delete +cache: + directories: + - $HOME/.ivy2/cache + - $HOME/.sbt/boot/ +sudo: false diff --git a/README.md b/README.md index 21e3447..f5703fa 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/lifeway/Chadash.svg?branch=master)](https://travis-ci.org/lifeway/Chadash) + # Chadash An immutable cloud deployer for AWS EC2 Instances. diff --git a/app/global/AppGlobalSettings.scala b/app/global/AppGlobalSettings.scala index 1acd75b..e85ed9a 100644 --- a/app/global/AppGlobalSettings.scala +++ b/app/global/AppGlobalSettings.scala @@ -3,7 +3,7 @@ package global import actors.ChadashSystem import com.google.inject.{Guice, Module} import play.api.mvc.{EssentialAction, Filters} -import play.api.{Application, GlobalSettings, Logger} +import play.api.{Application, GlobalSettings, Logger, Mode} import play.filters.gzip.GzipFilter import play.filters.headers.SecurityHeadersFilter @@ -19,7 +19,8 @@ trait AppGlobalSettings extends GlobalSettings { override def onStop(app: Application) { Logger.info("Application shutdown...") - ChadashSystem.system.shutdown() + if(app.mode != Mode.Test) + ChadashSystem.system.shutdown() } override def doFilter(next: EssentialAction): EssentialAction = { diff --git a/build.sbt b/build.sbt index bf45398..1357a62 100644 --- a/build.sbt +++ b/build.sbt @@ -38,7 +38,7 @@ buildInfoKeys ++= Seq[BuildInfoKey]( ) buildInfoPackage := "com.lifeway.chadash.appversion" -ScoverageSbtPlugin.ScoverageKeys.coverageMinimum := 14.50 +ScoverageSbtPlugin.ScoverageKeys.coverageMinimum := 60 ScoverageSbtPlugin.ScoverageKeys.coverageFailOnMinimum := false ScoverageSbtPlugin.ScoverageKeys.coverageHighlighting := true diff --git a/conf/application.test.conf b/conf/application.test.conf index a1eee05..5759f5e 100644 --- a/conf/application.test.conf +++ b/conf/application.test.conf @@ -12,8 +12,8 @@ logger { aws { credentialsProvider = "TypesafeConfigAWSCredentialsProvider" # If you use a "TypesafeConfigAWSCredentialsProvider" credentialsProvider, you can specify the crendetials in the following fields: - #accessKey = "" - #secretKey = "" + accessKey = "fake-key" + secretKey = "fake-secret-key" } akka { diff --git a/test/actors/workflow/tasks/ASGInfoSpec.scala b/test/actors/workflow/tasks/ASGInfoSpec.scala index 6e85086..466f006 100644 --- a/test/actors/workflow/tasks/ASGInfoSpec.scala +++ b/test/actors/workflow/tasks/ASGInfoSpec.scala @@ -10,13 +10,13 @@ import com.amazonaws.services.autoscaling.model._ import com.amazonaws.{AmazonClientException, AmazonServiceException} import org.mockito.Mockito import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import utils._ import scala.concurrent.duration._ class ASGInfoSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) with FlatSpecLike with Matchers - with MockitoSugar { + with MockitoSugar with BeforeAndAfterAll { val mockedClient = mock[AmazonAutoScaling] val describeASGRequest = new DescribeAutoScalingGroupsRequest().withAutoScalingGroupNames("test-asg-name") @@ -30,6 +30,10 @@ class ASGInfoSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testC Mockito.when(mockedClient.describeAutoScalingGroups(describeASGReqFail)).thenThrow(new AmazonServiceException("failed")) Mockito.when(mockedClient.describeAutoScalingGroups(describeASGReqClientExc)).thenThrow(new AmazonClientException("connection problems")).thenReturn(describeASGResult) + override def afterAll { + TestKit.shutdownActorSystem(system) + } + "An ASGInfo fetcher" should "return a valid response if AWS is up" in { val probe = TestProbe() val proxy = TaskProxyBuilder(probe, ASGInfo, system, TestActorFactory) diff --git a/test/actors/workflow/tasks/ASGSizeSpec.scala b/test/actors/workflow/tasks/ASGSizeSpec.scala index fb4f79c..fe4625b 100644 --- a/test/actors/workflow/tasks/ASGSizeSpec.scala +++ b/test/actors/workflow/tasks/ASGSizeSpec.scala @@ -10,13 +10,13 @@ import com.amazonaws.services.autoscaling.model.{AutoScalingGroup, DescribeAutoS import com.amazonaws.{AmazonClientException, AmazonServiceException} import org.mockito.Mockito import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import utils.{ActorFactory, PropFactory, TestConfiguration} import scala.concurrent.duration._ class ASGSizeSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) with FlatSpecLike with - Matchers with MockitoSugar { + Matchers with MockitoSugar with BeforeAndAfterAll { val mockedClient = mock[AmazonAutoScaling] val describeASGReq = new DescribeAutoScalingGroupsRequest().withAutoScalingGroupNames("test-asg-name") @@ -33,6 +33,10 @@ class ASGSizeSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testC Mockito.doThrow(new AmazonServiceException("failed")).when(mockedClient).describeAutoScalingGroups(failReq) Mockito.doThrow(new AmazonClientException("connection problems")).doReturn(describeASGResult).when(mockedClient).describeAutoScalingGroups(clientExceptionReq) + override def afterAll { + TestKit.shutdownActorSystem(system) + } + "An ASGSize actor" should "return an ASG size response if an ASG is queried" in { val probe = TestProbe() val proxy = TaskProxyBuilder(probe, ASGSize, system, TestActorFactory) diff --git a/test/actors/workflow/tasks/DeleteStackSpec.scala b/test/actors/workflow/tasks/DeleteStackSpec.scala index 869b269..d61c832 100644 --- a/test/actors/workflow/tasks/DeleteStackSpec.scala +++ b/test/actors/workflow/tasks/DeleteStackSpec.scala @@ -10,13 +10,13 @@ import com.amazonaws.services.cloudformation.model.DeleteStackRequest import com.amazonaws.{AmazonClientException, AmazonServiceException} import org.mockito.Mockito import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import utils.{ActorFactory, PropFactory, TestConfiguration} import scala.concurrent.duration._ class DeleteStackSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) with FlatSpecLike - with Matchers with MockitoSugar { + with Matchers with MockitoSugar with BeforeAndAfterAll { val mockedClient = mock[AmazonCloudFormation] val successReq = new DeleteStackRequest().withStackName("delete-success") @@ -29,6 +29,10 @@ class DeleteStackSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.t Mockito.doThrow(new AmazonServiceException("failed")).when(mockedClient).deleteStack(failReq) Mockito.doThrow(new AmazonClientException("connection problems")).doNothing().when(mockedClient).deleteStack(clientExceptionReq) + override def afterAll { + TestKit.shutdownActorSystem(system) + } + "A DeleteStack actor" should "request to delete the stack and return a response" in { val probe = TestProbe() val proxy = TaskProxyBuilder(probe, DeleteStack, system, TestActorFactory) diff --git a/test/actors/workflow/tasks/ELBHealthInstanceCheckerSpec.scala b/test/actors/workflow/tasks/ELBHealthInstanceCheckerSpec.scala index 16ffe55..f026dd4 100644 --- a/test/actors/workflow/tasks/ELBHealthInstanceCheckerSpec.scala +++ b/test/actors/workflow/tasks/ELBHealthInstanceCheckerSpec.scala @@ -10,13 +10,13 @@ import com.amazonaws.services.elasticloadbalancing.model.{DescribeInstanceHealth import com.amazonaws.{AmazonClientException, AmazonServiceException} import org.mockito.Mockito import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import utils.{ActorFactory, PropFactory, TestConfiguration} import scala.concurrent.duration._ class ELBHealthInstanceCheckerSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) - with FlatSpecLike with Matchers with MockitoSugar { + with FlatSpecLike with Matchers with MockitoSugar with BeforeAndAfterAll { val mockedClient = mock[AmazonElasticLoadBalancing] val instance = new Instance("instance-1") @@ -36,6 +36,10 @@ class ELBHealthInstanceCheckerSpec extends TestKit(ActorSystem("TestKit", TestCo Mockito.when(mockedClient.describeInstanceHealth(failReq)).thenThrow(new AmazonServiceException("failed")) Mockito.when(mockedClient.describeInstanceHealth(clientExceptionReq)).thenThrow(new AmazonClientException("connection problems")).thenReturn(successResultAllHealthy) + override def afterAll { + TestKit.shutdownActorSystem(system) + } + "A ELBHealthInstanceChecker actor" should "return an all healthy message if all instance are healthy" in { val probe = TestProbe() val proxy = TaskProxyBuilder(probe, ELBHealthyInstanceChecker, system, TestActorFactory) diff --git a/test/actors/workflow/tasks/FreezeASGSpec.scala b/test/actors/workflow/tasks/FreezeASGSpec.scala index 02351eb..9e7ca49 100644 --- a/test/actors/workflow/tasks/FreezeASGSpec.scala +++ b/test/actors/workflow/tasks/FreezeASGSpec.scala @@ -10,7 +10,7 @@ import com.amazonaws.services.autoscaling.model.SuspendProcessesRequest import com.amazonaws.{AmazonClientException, AmazonServiceException} import org.mockito.Mockito import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import utils.{ActorFactory, PropFactory, TestConfiguration} import scala.collection.JavaConverters._ @@ -18,7 +18,7 @@ import scala.concurrent.duration._ class FreezeASGSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) with FlatSpecLike with Matchers - with MockitoSugar { + with MockitoSugar with BeforeAndAfterAll { val mockedClient = mock[AmazonAutoScaling] val successReq = new SuspendProcessesRequest().withAutoScalingGroupName("freeze-success").withScalingProcesses(Seq("AlarmNotification", "ScheduledActions").asJava) @@ -31,6 +31,10 @@ class FreezeASGSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.tes Mockito.doThrow(new AmazonServiceException("failed")).when(mockedClient).suspendProcesses(reqFail) Mockito.doThrow(new AmazonClientException("connection problems")).doNothing().when(mockedClient).suspendProcesses(reqClientExc) + override def afterAll { + TestKit.shutdownActorSystem(system) + } + "A FreezeASG actor" should " return a freeze completed response if successful" in { val probe = TestProbe() val proxy = TaskProxyBuilder(probe, FreezeASG, system, TestActorFactory) diff --git a/test/actors/workflow/tasks/StackCreateCompleteMonitorSpec.scala b/test/actors/workflow/tasks/StackCreateCompleteMonitorSpec.scala index 84d86ed..07027be 100644 --- a/test/actors/workflow/tasks/StackCreateCompleteMonitorSpec.scala +++ b/test/actors/workflow/tasks/StackCreateCompleteMonitorSpec.scala @@ -10,14 +10,14 @@ import com.amazonaws.services.cloudformation.model.{DescribeStacksRequest, Descr import com.amazonaws.{AmazonClientException, AmazonServiceException} import org.mockito.Mockito import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import utils.{ActorFactory, PropFactory, TestConfiguration} import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.duration._ class StackCreateCompleteMonitorSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) - with FlatSpecLike with Matchers with MockitoSugar { + with FlatSpecLike with Matchers with MockitoSugar with BeforeAndAfterAll { val mockedClient = mock[AmazonCloudFormation] val createCompleteReq = new DescribeStacksRequest().withStackName("create-completed") @@ -43,6 +43,9 @@ class StackCreateCompleteMonitorSpec extends TestKit(ActorSystem("TestKit", Test Mockito.doThrow(new AmazonServiceException("failed")).when(mockedClient).describeStacks(awsFailReq) Mockito.doThrow(new AmazonClientException("connection problems")).doReturn(stackPendingResp).doReturn(stackCompleteResp).when(mockedClient).describeStacks(clientExceptionReq) + override def afterAll { + TestKit.shutdownActorSystem(system) + } "A StackCreateComplete Monitor actor" should "send a create complete message when the stack has reached CREATE_COMPLETE status" in { val props = Props(new StackCreateCompleteMonitor(null, "create-completed") with Override) diff --git a/test/actors/workflow/tasks/StackCreatorSpec.scala b/test/actors/workflow/tasks/StackCreatorSpec.scala index 1a38d15..f84e093 100644 --- a/test/actors/workflow/tasks/StackCreatorSpec.scala +++ b/test/actors/workflow/tasks/StackCreatorSpec.scala @@ -11,14 +11,14 @@ import com.amazonaws.services.cloudformation.model.{Capability, CreateStackReque import com.amazonaws.{AmazonClientException, AmazonServiceException} import org.mockito.Mockito import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import play.api.libs.json.Json import utils.{ActorFactory, PropFactory, TestConfiguration} import scala.concurrent.duration._ class StackCreatorSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) with FlatSpecLike - with Matchers with MockitoSugar { + with Matchers with MockitoSugar with BeforeAndAfterAll { val mockedClient = mock[AmazonCloudFormation] val appVersionTag = new Tag().withKey("ApplicationVersion").withValue("1.0") @@ -36,6 +36,9 @@ class StackCreatorSpec extends TestKit(ActorSystem("TestKit", TestConfiguration. Mockito.doThrow(new AmazonServiceException("failed")).when(mockedClient).createStack(reqFail) Mockito.doThrow(new AmazonClientException("connection problems")).doReturn(null).when(mockedClient).createStack(reqClientExc) + override def afterAll { + TestKit.shutdownActorSystem(system) + } "A stack creator actor" should "return a stack create request completed if successful" in { val probe = TestProbe() diff --git a/test/actors/workflow/tasks/StackDeleteCompleteMonitorSpec.scala b/test/actors/workflow/tasks/StackDeleteCompleteMonitorSpec.scala index 660af02..dad3d2b 100644 --- a/test/actors/workflow/tasks/StackDeleteCompleteMonitorSpec.scala +++ b/test/actors/workflow/tasks/StackDeleteCompleteMonitorSpec.scala @@ -10,14 +10,14 @@ import com.amazonaws.services.cloudformation.model.{DescribeStacksRequest, Descr import com.amazonaws.{AmazonClientException, AmazonServiceException} import org.mockito.Mockito import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import utils.{ActorFactory, PropFactory, TestConfiguration} import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.duration._ class StackDeleteCompleteMonitorSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) - with FlatSpecLike with Matchers with MockitoSugar { + with FlatSpecLike with Matchers with MockitoSugar with BeforeAndAfterAll { val mockedClient = mock[AmazonCloudFormation] val deleteCompleteReq = new DescribeStacksRequest().withStackName("delete-completed") @@ -42,6 +42,10 @@ class StackDeleteCompleteMonitorSpec extends TestKit(ActorSystem("TestKit", Test Mockito.doThrow(new AmazonServiceException("failed")).when(mockedClient).describeStacks(awsFailReq) Mockito.doThrow(new AmazonClientException("connection problems")).doReturn(stackPendingResp).doReturn(stackCompleteResp).when(mockedClient).describeStacks(clientExceptionReq) + override def afterAll { + TestKit.shutdownActorSystem(system) + } + "A StackDeleteComplete Monitor actor" should "send a delete complete message when the stack has reached DELETE_COMPLETE status" in { val props = Props(new StackDeleteCompleteMonitor(null, "delete-completed", "delete-completed") with Override) val factory = new TestActorFactory(props) diff --git a/test/actors/workflow/tasks/StackInfoSpec.scala b/test/actors/workflow/tasks/StackInfoSpec.scala index 245abd3..9d1b18e 100644 --- a/test/actors/workflow/tasks/StackInfoSpec.scala +++ b/test/actors/workflow/tasks/StackInfoSpec.scala @@ -10,13 +10,13 @@ import com.amazonaws.services.cloudformation.model.{DescribeStacksRequest, Descr import com.amazonaws.{AmazonClientException, AmazonServiceException} import org.mockito.Mockito import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import utils.{ActorFactory, PropFactory, TestConfiguration} import scala.concurrent.duration._ class StackInfoSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) with FlatSpecLike - with Matchers with MockitoSugar { + with Matchers with MockitoSugar with BeforeAndAfterAll { val mockedClient = mock[AmazonCloudFormation] val asgSuccessReq = new DescribeStacksRequest().withStackName("asg-name-query") @@ -35,6 +35,10 @@ class StackInfoSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.tes Mockito.doThrow(new AmazonServiceException("failed")).when(mockedClient).describeStacks(failReq) Mockito.doThrow(new AmazonClientException("connection problems")).doReturn(idSuccessResult).when(mockedClient).describeStacks(clientExceptionReq) + override def afterAll { + TestKit.shutdownActorSystem(system) + } + "A StackInfo actor" should "return the name of the ASG for a given stack" in { val probe = TestProbe() val proxy = TaskProxyBuilder(probe, StackInfo, system, TestActorFactory) diff --git a/test/actors/workflow/tasks/StackListSpec.scala b/test/actors/workflow/tasks/StackListSpec.scala index 26e5ed6..e0cd11d 100644 --- a/test/actors/workflow/tasks/StackListSpec.scala +++ b/test/actors/workflow/tasks/StackListSpec.scala @@ -11,13 +11,13 @@ import com.amazonaws.services.cloudformation.model.{ListStacksRequest, ListStack import com.amazonaws.{AmazonClientException, AmazonServiceException} import org.mockito.Mockito import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import utils.{ActorFactory, PropFactory, TestConfiguration} import scala.concurrent.duration._ class StackListSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) with FlatSpecLike - with Matchers with MockitoSugar { + with Matchers with MockitoSugar with BeforeAndAfterAll { val mockedClient = mock[AmazonCloudFormation] val failMockedClient = mock[AmazonCloudFormation] @@ -31,6 +31,9 @@ class StackListSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.tes .doReturn(successResp) .when(mockedClient).listStacks(req) + override def afterAll { + TestKit.shutdownActorSystem(system) + } "A StackList actor" should "retrieve filtered stacks" in { val probe = TestProbe() diff --git a/test/actors/workflow/tasks/StackLoaderSpec.scala b/test/actors/workflow/tasks/StackLoaderSpec.scala index 4303e5d..2cedf17 100644 --- a/test/actors/workflow/tasks/StackLoaderSpec.scala +++ b/test/actors/workflow/tasks/StackLoaderSpec.scala @@ -12,14 +12,14 @@ import com.amazonaws.services.s3.model.S3Object import com.amazonaws.{AmazonClientException, AmazonServiceException} import org.mockito.Mockito import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import play.api.libs.json.{JsString, Json} import utils.{ActorFactory, PropFactory, TestConfiguration} import scala.concurrent.duration._ class StackLoaderSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) with FlatSpecLike - with Matchers with MockitoSugar { + with Matchers with MockitoSugar with BeforeAndAfterAll { val mockedClient = mock[AmazonS3] val s3successObject = new S3Object() @@ -36,6 +36,10 @@ class StackLoaderSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.t Mockito.doThrow(new AmazonServiceException("failed")).when(mockedClient).getObject("test-bucket-name", "chadash-stacks/test-aws-down.json") Mockito.doThrow(new AmazonClientException("connection problems")).doReturn(s3restartObject).when(mockedClient).getObject("test-bucket-name", "chadash-stacks/test-aws-restart.json") + override def afterAll { + TestKit.shutdownActorSystem(system) + } + "A StackLoader actor" should "return a JSON value for a valid stack" in { val probe = TestProbe() val proxy = TaskProxyBuilder(probe, StackLoader, system, TestActorFactory) diff --git a/test/actors/workflow/tasks/UnfreezeASGSpec.scala b/test/actors/workflow/tasks/UnfreezeASGSpec.scala index b726f0b..cf4dab9 100644 --- a/test/actors/workflow/tasks/UnfreezeASGSpec.scala +++ b/test/actors/workflow/tasks/UnfreezeASGSpec.scala @@ -10,13 +10,13 @@ import com.amazonaws.services.autoscaling.model.ResumeProcessesRequest import com.amazonaws.{AmazonClientException, AmazonServiceException} import org.mockito.Mockito import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import utils.{ActorFactory, PropFactory, TestConfiguration} import scala.concurrent.duration._ class UnfreezeASGSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) with FlatSpecLike - with Matchers with MockitoSugar { + with Matchers with MockitoSugar with BeforeAndAfterAll { val mockedClient = mock[AmazonAutoScaling] val successReq = new ResumeProcessesRequest().withAutoScalingGroupName("success-req") @@ -29,6 +29,10 @@ class UnfreezeASGSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.t Mockito.doThrow(new AmazonServiceException("failed")).when(mockedClient).resumeProcesses(failReq) Mockito.doThrow(new AmazonClientException("client-exception-req")).doNothing().when(mockedClient).resumeProcesses(clientExceptionReq) + override def afterAll { + TestKit.shutdownActorSystem(system) + } + "A UnfreezeASG actor" should "unfreeze an ASG successfully" in { val probe = TestProbe() val proxy = TaskProxyBuilder(probe, UnfreezeASG, system, TestActorFactory) diff --git a/test/controllers/ApplicationSpec.scala b/test/controllers/ApplicationSpec.scala index e02b1a7..6a44e98 100644 --- a/test/controllers/ApplicationSpec.scala +++ b/test/controllers/ApplicationSpec.scala @@ -7,7 +7,7 @@ import akka.actor._ import akka.testkit.TestKit import com.google.inject.{AbstractModule, Module} import global.AppGlobalSettings -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import org.scalatestplus.play.{OneServerPerSuite, WsScalaTestClient} import play.api.libs.json.{JsValue, Json} import play.api.libs.ws.{WS, WSAuthScheme} @@ -18,10 +18,14 @@ import scala.concurrent.Await import scala.concurrent.duration._ class ApplicationSpec extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) with FlatSpecLike - with Matchers with WsScalaTestClient with OneServerPerSuite { + with Matchers with WsScalaTestClient with OneServerPerSuite with BeforeAndAfterAll { implicit override lazy val app: FakeApplication = FakeApplication(withGlobal = Some(TestGlobal)) + override def afterAll { + TestKit.shutdownActorSystem(system) + } + "A Deployment API" should "start a workflow" in { val testURL = s"http://localhost:$port/api/deploy/workflow-started" val f = WS.url(testURL).withAuth("test", "password", WSAuthScheme.BASIC).post(Json.obj("version" -> "1.01", "ami_id" -> "some-id")) diff --git a/test/functional/WorkflowManagerSystemTest.scala b/test/functional/WorkflowManagerSystemTest.scala index 431ceba..4c1da85 100644 --- a/test/functional/WorkflowManagerSystemTest.scala +++ b/test/functional/WorkflowManagerSystemTest.scala @@ -21,7 +21,7 @@ import com.amazonaws.services.s3.AmazonS3 import com.amazonaws.services.s3.model.S3Object import org.mockito.Mockito import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpecLike, Matchers} +import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import play.api.libs.json.{JsString, Json} import utils.{ActorFactory, PropFactory, TestConfiguration} @@ -30,10 +30,14 @@ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.duration._ class WorkflowManagerSystemTest extends TestKit(ActorSystem("TestKit", TestConfiguration.testConfig)) with FlatSpecLike - with Matchers { + with Matchers with BeforeAndAfterAll { import functional.WorkflowManagerSystemTest._ + override def afterAll { + TestKit.shutdownActorSystem(system) + } + "A WorkflowManager Supervisor" should "complete a new stack workflow deploy" in { val sendingProbe = TestProbe() val loggingProbe = TestProbe()