playframework 2.2 - Redis connection closes when multiple tests are running in the same time -


i have few test cases in 1 class , 1 succeed others failed redis pool exception. how can make sure other tests can connection pool?

[error]    jedisconnectionexception: : not resource pool  (pool.java:22) [error] redis.clients.util.pool.getresource(pool.java:22) [error] org.sedis.pool.withjedisclient(sedis.scala:79) [error] com.typesafe.plugin.redisplugin$$anon$1.set_(redisplugin.scala:147) [error] com.typesafe.plugin.redisplugin$$anon$1.set(redisplugin.scala:106) [error] play.api.cache.cache$.set(cache.scala:58) [error] controllers.security$resultwithtoken.withtokenshort(security.scala:51) [error] controllers.security$resultwithtoken.withtemptoken(security.scala:62) [error] controllers.security$$anonfun$hastoken$1$$anonfun$apply$3.apply(security.scala:83) [error] controllers.security$$anonfun$hastoken$1$$anonfun$apply$3.apply(security.scala:83) [error] controllers.security$$anonfun$hastoken$1.apply(security.scala:82) [error] controllers.security$$anonfun$hastoken$1.apply(security.scala:76) [error] play.api.mvc.actionbuilder$$anonfun$apply$10.apply(action.scala:221) [error] play.api.mvc.actionbuilder$$anonfun$apply$10.apply(action.scala:220) caused by: java.lang.illegalstateexception: pool not open     @ org.apache.commons.pool.baseobjectpool.assertopen(baseobjectpool.java:137)     @ org.apache.commons.pool.impl.genericobjectpool.borrowobject(genericobjectpool.java:1065)     @ redis.clients.util.pool.getresource(pool.java:20) 

this controller class sets uuid token play cache sets redis play-redis-plugin. play cache calls redisplugin , pool jedis client. controller class used in apis want return auth token.

trait security { self: controller =>    implicit val app: play.api.application = play.api.play.current    lazy val cacheexpirationshort =     this.app.configuration.getint("cache.expiration").getorelse(8 * 60 * 60) // 8 hrs    val authtokencookiekey = "xsrf-token"    /* additional methods handle token passing */   implicit class resultwithtoken(result: simpleresult)(implicit req: requestheader) {     def withtokenshort(token: (string, string)): simpleresult = {       cache.set(token._1, token._2, cacheexpiration)       membertoken.add(token._2, token._1)       val issecure = req.headers.get("x-scheme").collect {         case "https" => true } getorelse { false }       result.withcookies(cookie(authtokencookiekey, token._1, some(cacheexpirationshort), path="/", domain=some(app.cookiedomainfromhost(req.host)), secure=issecure , httponly=false))     }   } object security extends controller security 

edit1:

according play ! 2.2.4 / akka : tests failed when run together, ok separately, think @ redisplugin, jedispool should change def.

 lazy val jedispool = {    val poolconfig = createpoolconfig(app)    logger.info(s"redis plugin enabled. connecting redis on ${host}:${port} ${database} timeout ${timeout}.")    logger.info("redis plugin pool configuration: " + new reflectiontostringbuilder(poolconfig).tostring())    new jedispool(poolconfig, host, port, timeout, password, database)  } 

i had same issue , seems best solution (as long not testing redis itself) disable redis plugin tests , let use default cache.

val config = map(   "ehcacheplugin" -> "enabled",   "redisplugin" -> "disabled")  "this test" should {   "not die" in {     running(fakeapplication(additionalconfiguration = config)) {       ...     }   } } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -