Request was neither completed nor rejected within 1 second

455 views
Skip to first unread message

Chris Stewart

unread,
Aug 25, 2015, 4:56:59 PM8/25/15
to spray.io User List
I'm trying to run a test on a web service that requires the web service under test to reach a database server resulting in a request that is over 1 second. I'm trying to allow for my Scala Spray tests to accept tests that are longer than one second, but I haven't had any luck. I've referenced this post on this google group to no avail. Here is the code I have right now in my test

import akka.testkit._
import akka.actor.ActorSystem
import com.github.nfldb.config.{NflDbApiActorSystemConfig, NflDbApiDbConfigTest}
import org.scalatest.MustMatchers
import org.specs2.mutable.Specification
import spray.testkit.Specs2RouteTest
import spray.routing.HttpService
import spray.http.StatusCodes._
import spray.json.DefaultJsonProtocol._
import spray.httpx.SprayJsonSupport._
import concurrent.duration._
import akka.testkit._

/**
 * Created by chris on 8/25/15.
 */

class NflPlayerScoringSvcTest extends Specification with Specs2RouteTest  with NflPlayerScoringService
 
with NflDbApiDbConfigTest with NflDbApiActorSystemConfig {
 
import PlayerScoreProtocol.playerScoreProtocol
 
implicit def actorRefFactory = actorSystem
 
implicit def default(system: ActorSystem = actorSystem) = RouteTestTimeout(new DurationInt(5).second.dilated)

 
"NflPlayerScoringSvc" should {

   
"return hello" in {
     
Get("/hello") ~> nflPlayerScoringServiceRoutes ~> check {
        responseAs
[String] must contain("Say hello")
     
}
   
}

   
"calculate a player's score for a given week" in  {
     
import PlayerScoreProtocol.playerScoreProtocol
     
Get("/playerScore?playerId=00-0031237&gsisId=2015081551") ~> nflPlayerScoringServiceRoutes ~> check {
        val playerScore
:  DfsNflScoringEngineComponent.PlayerScore = responseAs[DfsNflScoringEngineComponent.PlayerScore]
        playerScore
.playerId must be ("00-0031237")
     
}
   
}

 
}
}


When I execute this test, I get the following result:
> test-only *NflPlayerScoringSvcTest*
[info] Compiling 1 Scala source to /home/chris/dev/suredbits-dfs/target/scala-2.11/test-classes...
15:46:27.875 TKD [com-suredbits-dfs-nfl-scoring-NflPlayerScoringSvcTest-akka.actor.default-dispatcher-2] INFO  akka.event.slf4j.Slf4jLogger - Slf4jLogger started
15:46:28.266 TKD [NflDbApiActorSystemConfig-akka.actor.default-dispatcher-3] INFO  akka.event.slf4j.Slf4jLogger - Slf4jLogger started
15:46:28.324 TKD [NflDbApiActorSystemConfig-akka.actor.default-dispatcher-3] INFO  test test test - Trying to find score for player: 00-0031237 and optional gsisId: Some(2015081551)
15:46:28.325 TKD [NflDbApiActorSystemConfig-akka.actor.default-dispatcher-3] INFO  test test test - Searching for player 00-0031237 with optional game: Some(2015081551)
15:46:28.370 TKD [NflDbApiActorSystemConfig-akka.actor.default-dispatcher-2] INFO  c.s.d.n.s.NflPlayerScoringSvcTest - Creating database for class com.suredbits.dfs.nfl.scoring.NflPlayerScoringSvcTest
[info] NflPlayerScoringSvcTest
[info] 
[info] NflPlayerScoringSvc should
[info] + return hello
[info] x calculate a player's score for a given week
[error]    Request was neither completed nor rejected within 1 second (NflPlayerScoringSvcTest.scala:33)
[info] 
[info] 
[info] Total for specification NflPlayerScoringSvcTest
[info] Finished in 1 second, 232 ms
[info] 2 examples, 1 failure, 0 error
[info] ScalaTest
[info] Run completed in 2 seconds, 479 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[error] Failed: Total 2, Failed 1, Errors 0, Passed 1
[error] Failed tests:
[error] 	com.suredbits.dfs.nfl.scoring.NflPlayerScoringSvcTest
[error] (test:testOnly) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 7 s, completed Aug 25, 2015 3:46:30 PM
> 15:46:30.194 TKD [NflDbApiActorSystemConfig-akka.actor.default-dispatcher-2] INFO  c.s.d.n.s.NflPlayerScoringSvcTest - Calculating score for game: NflGame(2015081551,Some(56772),2015-08-16T00:00:00.000Z,NflPreSeasonWeek1,Saturday,2015,Preseason,true,HomeTeam(MIN,26,9,14,3,0,2),AwayTeam(TB,16,3,6,7,0,1),2015-05-22T21:54:43.143Z,2015-08-16T17:29:01.729Z) and player: NflPlayer(00-0031237,Some(T.Bridgewater),Some(Teddy Bridgewater),Some(Teddy),Some(Bridgewater),MIN,QB,Some(2543465),Some(http://www.nfl.com/player/teddybridgewater/2543465/profile),Some(5),Some(11/10/1992),Some(Louisville),Some(2),Some(74),Some(215),Active)


I'm not sure what to do next, can I get any guidance?

Also will this issue happen in production when I am running this web service? 



Reply all
Reply to author
Forward
0 new messages