Scala Play 2.4, Slick, and Postgres (timeout connection)

scala
java

#1

Hello, I’m having problems with running my test suite on CircleCI. When I run the test suite locally all tests pass and works for all other developers just fine. Virtually all of our tests fail out with the following error when running in CircleCI.

This is the tech stack being used.

  • Scala
  • Play 2.4
  • Slick 3.0 (for integration with Play)
  • Postgres 9.4
  • Specs2 (for testing)

This is the stack trace that I receive from when running the test suite on CircleCI.

[error]   ! for a new user return a JWT
[error]    Task slick.backend.DatabaseComponent$DatabaseDef$$anon$2@53150157 rejected from java.util.concurrent.ThreadPoolExecutor@45d6ec47[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 2] (DatabaseComponent.scala:230)
[error] slick.backend.DatabaseComponent$DatabaseDef$class.runSynchronousDatabaseAction(DatabaseComponent.scala:230)
[error] slick.jdbc.JdbcBackend$DatabaseDef.runSynchronousDatabaseAction(JdbcBackend.scala:38)
[error] slick.backend.DatabaseComponent$DatabaseDef$class.runInContext(DatabaseComponent.scala:207)
[error] slick.jdbc.JdbcBackend$DatabaseDef.runInContext(JdbcBackend.scala:38)
[error] slick.backend.DatabaseComponent$DatabaseDef$class.runInternal(DatabaseComponent.scala:75)
[error] slick.jdbc.JdbcBackend$DatabaseDef.runInternal(JdbcBackend.scala:38)
[error] slick.backend.DatabaseComponent$DatabaseDef$class.run(DatabaseComponent.scala:72)
[error] slick.jdbc.JdbcBackend$DatabaseDef.run(JdbcBackend.scala:38)
[error] daos.UserDAO$.find(UserDAO.scala:41)
[error] services.impls.UserServiceImpl.retrieve(UserServiceImpl.scala:12)
[error] controllers.SignUp$$anonfun$signUp$1$$anonfun$apply$2$$anonfun$apply$4.apply(SignUp.scala:35)
[error] controllers.SignUp$$anonfun$signUp$1$$anonfun$apply$2$$anonfun$apply$4.apply(SignUp.scala:33)
[error] akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
[error] akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:91)
[error] akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
[error] akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
[error] akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:90)
[error] akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
[error] akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397)
[info]
[error]   ! for existing user match previous JWT
[error]    Task slick.backend.DatabaseComponent$DatabaseDef$$anon$2@72b75ed6 rejected from java.util.concurrent.ThreadPoolExecutor@45d6ec47[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 2] (DatabaseComponent.scala:230)
[error] slick.backend.DatabaseComponent$DatabaseDef$class.runSynchronousDatabaseAction(DatabaseComponent.scala:230)
[error] slick.jdbc.JdbcBackend$DatabaseDef.runSynchronousDatabaseAction(JdbcBackend.scala:38)
[error] slick.backend.DatabaseComponent$DatabaseDef$class.runInContext(DatabaseComponent.scala:207)
[error] slick.jdbc.JdbcBackend$DatabaseDef.runInContext(JdbcBackend.scala:38)
[error] slick.backend.DatabaseComponent$DatabaseDef$class.runInternal(DatabaseComponent.scala:75)
[error] slick.jdbc.JdbcBackend$DatabaseDef.runInternal(JdbcBackend.scala:38)
[error] slick.backend.DatabaseComponent$DatabaseDef$class.run(DatabaseComponent.scala:72)
[error] slick.jdbc.JdbcBackend$DatabaseDef.run(JdbcBackend.scala:38)
[error] daos.UserDAO$.find(UserDAO.scala:41)
[error] services.impls.UserServiceImpl.retrieve(UserServiceImpl.scala:12)
[error] controllers.SignUp$$anonfun$signUp$1$$anonfun$apply$2$$anonfun$apply$4.apply(SignUp.scala:35)
[error] controllers.SignUp$$anonfun$signUp$1$$anonfun$apply$2$$anonfun$apply$4.apply(SignUp.scala:33)
[error] akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
[error] akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:91)
[error] akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
[error] akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
[error] akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:90)
[error] akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
[error] akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397)

It is worth noting that one of the tests does make a 3rd party call to an outside service. It would be great to receive some feedback on why this is occurring in the CircleCI environment. Thanks!


#2

Here is the solution to the problem. I have a build.sbt file and inside of it contains the following line.

javaOptions in Test += "-Dconfig.file=conf/application.test.conf"

However, for some reason CircleCI doesn’t seem to pick up the configuration file in build.sbt for testing when running the command sbt test. The solution is to include the following line inside of your circle.yml file.

test:
  override:
    - sbt test -Dconfig.file=conf/application.test.conf

Afterward, CircleCI is able to run the test suite against the correct configuration and our tests ran successfully.

This was noticed by bumping up the timeout in application.test.conf and it not be respected as given by the stack trace posted above.


#3