Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

working play plugin which defines its own extension of Simulation tha…

…t starts and stops a fake server
  • Loading branch information...
commit c1337344a4aa7c6396bfaef98ee73b84f8349473 1 parent 6eeb4c3
@andypetrella authored
View
27 src/gatling-test/conf/gatling.conf
@@ -1,27 +0,0 @@
-#########################
-# Gatling Configuration #
-#########################
-
-# This file contains all the settings configurable for Gatling with their default values
-
-gatling {
- encoding = "utf-8" # encoding for every file manipulation made in gatling
-
- simulation {
- timeout = 86400 # max duration of a simulation in seconds
- scalaPackage = ""
- }
- charting {
- indicators {
- lowerBound = 100 # in ms
- higherBound = 500 # in ms
- }
- }
- http {
- provider = "Netty" # Choose between 'Netty', 'JDK', 'Apache' or 'Grizzly'
- compressionEnabled = true # Set if compression should be supported or not
- connectionTimeout = 60000 # Timeout of the connection to the server (ms)
- requestTimeout = 60000 # Timeout of the requests (ms)
- maxRetry = 5 # number of times that a request should be tried again
- }
-}
View
23 src/gatling-test/simulations/PlaySimulation.scala
@@ -1,23 +0,0 @@
-import com.excilys.ebi.gatling.core.Predef._
-import com.excilys.ebi.gatling.core.Predef._
-import com.excilys.ebi.gatling.core.scenario.configuration.ScenarioConfigurationBuilder
-
-import play.api.test._
-import play.api.test.Helpers._
-
-trait PlaySimulation extends Simulation {
-
- def port:Int
-
- implicit def application:FakeApplication
-
- def createServer = new TestServer(port, application)
-
- def shoot:Seq[ScenarioConfigurationBuilder]
-
- def apply = {
- createServer
- shoot
- }
-
-}
View
36 src/gatling-test/simulations/SampleSimulation.scala
@@ -1,36 +0,0 @@
-import com.excilys.ebi.gatling.core.scenario.configuration.Simulation
-import com.excilys.ebi.gatling.core.Predef._
-import com.excilys.ebi.gatling.http.Predef._
-
-import play.api.test._
-import play.api.test.Helpers.running
-
-
-class SampleSimulation() extends PlaySimulation {
- val port = 3333
-
- implicit val application = FakeApplication(/*additionalPlugins = Seq("be.nextlab.play.gatling.GatlingPlugin")*/)
-
- def shoot = {
- val baseUrl = "http://localhost:3333"
-
- running(TestServer(3333, application)) {
- val headers_1 = Map(
- "Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
- "Accept-Charset" -> "ISO-8859-1,utf-8;q=0.7,*;q=0.7"
- )
-
- val scn = scenario("test")
- .exec(
- http("request_1")
- .get("/")
- .headers(headers_1)
- .check(status.is(200))
- )
-
- val httpConf = httpConfig.baseURL(baseUrl)
-
- Seq(scn.configure users 10 ramp 2 protocolConfig httpConf)
- }
- }
-}
View
20 src/main/scala/PlaySimulation.scala
@@ -1,6 +1,11 @@
-import com.excilys.ebi.gatling.core.Predef._
-import com.excilys.ebi.gatling.core.Predef._
+import com.excilys.ebi.gatling.core.Predef.{Simulation=>GSimulation, _}
import com.excilys.ebi.gatling.core.scenario.configuration.ScenarioConfigurationBuilder
+import be.nextlab.gatling.sbt.plugin.Simulation
+
+
+import play.api._
+import play.api.mvc._
+import play.api.http._
import play.api.test._
import play.api.test.Helpers._
@@ -11,13 +16,14 @@ trait PlaySimulation extends Simulation {
implicit def application:FakeApplication
- def createServer = new TestServer(port, application)
+ lazy val server = new TestServer(port, application)
- def shoot:Seq[ScenarioConfigurationBuilder]
+ def pre = {
+ server.start()
+ }
- def apply = {
- createServer
- shoot
+ def post = {
+ server.stop()
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.