Skip to content

Commit

Permalink
add test route
Browse files Browse the repository at this point in the history
  • Loading branch information
kr7ysztof committed Dec 7, 2023
1 parent b70acde commit acecca6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/scala/com/ing/wbaa/rokku/proxy/RokkuS3Proxy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Directives._
import com.ing.wbaa.rokku.proxy.api.directive.ProxyDirectives.cors
import com.ing.wbaa.rokku.proxy.api.{ HealthService, OptionService, PostRequestActions, ProxyService }
import com.ing.wbaa.rokku.proxy.api.{ HealthService, OptionService, PostRequestActions, ProxyService, TestService }
import com.ing.wbaa.rokku.proxy.config.HttpSettings
import com.typesafe.scalalogging.LazyLogging

import scala.concurrent.{ ExecutionContext, Future }
import scala.util.{ Failure, Success }

trait RokkuS3Proxy extends LazyLogging with ProxyService with PostRequestActions with HealthService with OptionService {
trait RokkuS3Proxy extends LazyLogging with ProxyService with PostRequestActions with HealthService with OptionService with TestService {

protected[this] implicit def system: ActorSystem

Expand All @@ -23,7 +23,7 @@ trait RokkuS3Proxy extends LazyLogging with ProxyService with PostRequestActions
// The routes we serve.
final val allRoutes =
cors() {
healthRoute ~ optionRoute ~ proxyServiceRoute
testRoute ~ healthRoute ~ optionRoute ~ proxyServiceRoute
}

// Details about the server binding.
Expand Down
43 changes: 43 additions & 0 deletions src/main/scala/com/ing/wbaa/rokku/proxy/api/TestService.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.ing.wbaa.rokku.proxy.api

import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import com.ing.wbaa.rokku.proxy.data.RequestId
import com.ing.wbaa.rokku.proxy.handler.LoggerHandlerWithId

trait TestService {

private val logger = new LoggerHandlerWithId

final val testRoute: Route =
path("test200") {
get {
parameters("timeout".as[Long]) { (timeout) =>
logger.debug("start test200")(RequestId("test200"))
Thread.sleep(timeout)
logger.debug("stop test200")(RequestId("test200"))
complete(StatusCodes.OK -> "test")
}
}
} ~ path("test502") {
get {
parameters("timeout".as[Long]) { (timeout) =>
logger.debug("start test502")(RequestId("test200"))
Thread.sleep(timeout)
logger.debug("stop test502")(RequestId("test200"))
complete(StatusCodes.BadGateway -> "502")
}
}
} ~ path("test503") {
get {
parameters("timeout".as[Long]) { (timeout) =>
logger.debug("start test503")(RequestId("test503"))
Thread.sleep(timeout)
logger.debug("stop test503")(RequestId("test503"))
complete(StatusCodes.ServiceUnavailable -> "503")
}
}
}

}

0 comments on commit acecca6

Please sign in to comment.