-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test suite for bringing up agora and embedded mongo before all …
…tests and tearing it down after all tests. Removing mongodb service from travis yaml.
- Loading branch information
Showing
8 changed files
with
154 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
language: scala | ||
scala: | ||
- 2.11.6 | ||
services: | ||
- mongodb | ||
jdk: | ||
- oraclejdk8 | ||
script: sbt clean coverage test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/test/scala/org/broadinstitute/dsde/agora/server/AgoraTestData.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.broadinstitute.dsde.agora.server | ||
|
||
import org.broadinstitute.dsde.agora.server.model.{AgoraAddRequest, AgoraEntity} | ||
|
||
trait AgoraTestData { | ||
val namespace = "broad" | ||
|
||
val name = "testMethod" | ||
|
||
val synopsis = "This is a test method" | ||
|
||
val documentation = "This is the documentation" | ||
|
||
val owner = "bob the builder" | ||
|
||
val payload = """task wc { | ||
| command { | ||
| echo "${str}" | wc -c | ||
| } | ||
| output { | ||
| int count = read_int("stdout") - 1 | ||
| } | ||
|} | ||
| | ||
|workflow wf { | ||
| array[string] str_array | ||
| scatter(s in str_array) { | ||
| call wc{input: str=s} | ||
| } | ||
|}""".stripMargin | ||
|
||
val testEntity = AgoraEntity(namespace = Option(namespace), name = Option(name)) | ||
|
||
val testAddRequest = new AgoraAddRequest( | ||
namespace = namespace, | ||
name = name, | ||
synopsis = synopsis, | ||
documentation = documentation, | ||
owner = owner, | ||
payload = payload | ||
) | ||
|
||
val badPayload = "task test {" | ||
|
||
val testBadAddRequest = new AgoraAddRequest( | ||
namespace = namespace, | ||
name = name, | ||
synopsis = synopsis, | ||
documentation = documentation, | ||
owner = owner, | ||
payload = badPayload | ||
) | ||
} |
27 changes: 27 additions & 0 deletions
27
src/test/scala/org/broadinstitute/dsde/agora/server/AgoraTestSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.broadinstitute.dsde.agora.server | ||
|
||
import com.github.simplyscala.{MongoEmbedDatabase, MongodProps} | ||
import org.broadinstitute.dsde.agora.server.dataaccess.AgoraDao | ||
import org.broadinstitute.dsde.agora.server.dataaccess.mongo.MethodsDbTest | ||
import org.broadinstitute.dsde.agora.server.webservice.ApiServiceSpec | ||
import org.scalatest.{BeforeAndAfterAll, Suites} | ||
|
||
trait AgoraDbTest { | ||
val agoraDao = AgoraDao.createAgoraDao | ||
} | ||
|
||
class AgoraTestSuite extends Suites(new ApiServiceSpec, new MethodsDbTest) with BeforeAndAfterAll with MongoEmbedDatabase { | ||
var mongoProps: MongodProps = null | ||
|
||
override def beforeAll() { | ||
println("Starting embedded mongo db instance.") | ||
mongoProps = mongoStart(port = Agora.server.mongoDbPort) | ||
println("Starting Agora web services.") | ||
Agora.start() | ||
} | ||
|
||
override def afterAll() { | ||
println("Stopping embedded mongo db instance.") | ||
mongoStop(mongoProps) | ||
} | ||
} |
103 changes: 0 additions & 103 deletions
103
src/test/scala/org/broadinstitute/dsde/agora/server/ApiServiceSpec.scala
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
src/test/scala/org/broadinstitute/dsde/agora/server/ApiTestFixture.scala
This file was deleted.
Oops, something went wrong.
56 changes: 17 additions & 39 deletions
56
src/test/scala/org/broadinstitute/dsde/agora/server/dataaccess/mongo/MethodsDbTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/test/scala/org/broadinstitute/dsde/agora/server/webservice/ApiServiceSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.broadinstitute.dsde.agora.server.webservice | ||
|
||
import org.broadinstitute.dsde.agora.server.model.AgoraEntity | ||
import org.broadinstitute.dsde.agora.server.model.AgoraEntity._ | ||
import org.broadinstitute.dsde.agora.server.webservice.methods.MethodsService | ||
import org.broadinstitute.dsde.agora.server.webservice.util.{ApiUtil, ServiceHandlerProps} | ||
import org.broadinstitute.dsde.agora.server.{AgoraDbTest, AgoraTestData} | ||
import org.scalatest.{DoNotDiscover, FlatSpec, Matchers} | ||
import spray.http.StatusCodes._ | ||
import spray.httpx.marshalling._ | ||
import spray.routing.Directives | ||
import spray.testkit.ScalatestRouteTest | ||
|
||
@DoNotDiscover | ||
class ApiServiceSpec extends FlatSpec with Matchers with Directives with ScalatestRouteTest with AgoraTestData with AgoraDbTest { | ||
|
||
trait ActorRefFactoryContext { | ||
def actorRefFactory = system | ||
} | ||
|
||
val methodsService = new MethodsService with ActorRefFactoryContext with ServiceHandlerProps | ||
|
||
"Agora" should "return information about a method, including metadata " in { | ||
val insertedEntity = agoraDao.insert(testEntity) | ||
|
||
Get(ApiUtil.Methods.withLeadingSlash + "/" + namespace + "/" + name + "/" | ||
+ insertedEntity.id.get) ~> methodsService.queryRoute ~> check { | ||
responseAs[AgoraEntity] === insertedEntity | ||
} | ||
} | ||
|
||
"Agora" should "create and return a method" in { | ||
Post(ApiUtil.Methods.withLeadingSlash, marshal(testAddRequest)) ~> methodsService.postRoute ~> check { | ||
val response = responseAs[AgoraEntity] | ||
response.namespace === namespace | ||
response.name === name | ||
response.synopsis === synopsis | ||
response.documentation === documentation | ||
response.owner === owner | ||
response.payload === payload | ||
response.id === 1 | ||
response.createDate != null | ||
} | ||
} | ||
|
||
"Agora" should "return a 400 bad request when posting a malformed payload" in { | ||
Post(ApiUtil.Methods.withLeadingSlash, marshal(testBadAddRequest)) ~> methodsService.postRoute ~> check { | ||
status === BadRequest | ||
responseAs[String] != null | ||
} | ||
} | ||
|
||
} |