Skip to content

Commit

Permalink
jugando un poco con las distintas formas de inyeccion que tiene gatling
Browse files Browse the repository at this point in the history
  • Loading branch information
Esteban Montes committed Apr 30, 2018
1 parent 331440a commit 9d4c937
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import scala.concurrent.duration._

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._


/**
Tutorial probando REST API: https://www.blazemeter.com/blog/api-load-testing-with-gatling
Se crean 1000 incidencias a lo largo de 35 segundos, en menos segundos empieza a haber problemas, 10k a lo largo de 350s
Las incidencias seran creadas en intervalos random de tiempo
*/

class IncidenceRESTServiceSimulation extends Simulation {

val httpProtocol = http
.baseURL("http://localhost:8090")
.inferHtmlResources()
.acceptHeader("*/*")
.contentTypeHeader("application/json")
.userAgentHeader("curl/7.54.0")

val scn = scenario("IncidenceRESTServiceSimulation")
.exec(http("request_0")
.post("/incidence-creator")
.body(StringBody(""" {"ident":"entidad2","password":"123456","kind":2,"name":"inc_GHKB","description":"Nueva lectura de humedad","location":"2919,178","tags":["Nieve","Fuego","Niebla","Terremoto"],"additionalInformation":"http://puntoverdeleon.com.mx/wp-content/uploads/2016/09/imagen-de-prueba-320x240.jpg","properties":{"p0":"v0","p1":"v1","p2":"v2","p3":"v3"},"state":"Abierta","notification":"si","expireAt":"2018-10-25 10:02:29.769579","assignedTo":"oper_rUxl"} """)).asJSON
)

setUp(scn.inject(rampUsers(1000) over(35 seconds) randomized)).protocols(httpProtocol)
}
29 changes: 29 additions & 0 deletions simulations/RestService/IncidenceRESTServiceSimulationRanged.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import scala.concurrent.duration._

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._


/**
Tutorial probando REST API: https://www.blazemeter.com/blog/api-load-testing-with-gatling
Se intentaran crear entre 500 y 1000 incidencias a lo largo de 20 segundos
*/

class IncidenceRESTServiceSimulationRanged extends Simulation {

val httpProtocol = http
.baseURL("http://localhost:8090")
.inferHtmlResources()
.acceptHeader("*/*")
.contentTypeHeader("application/json")
.userAgentHeader("curl/7.54.0")

val scn = scenario("IncidenceRESTServiceSimulationRanged")
.exec(http("request_0")
.post("/incidence-creator")
.body(StringBody(""" {"ident":"entidad2","password":"123456","kind":2,"name":"inc_GHKB","description":"Nueva lectura de humedad","location":"2919,178","tags":["Nieve","Fuego","Niebla","Terremoto"],"additionalInformation":"http://puntoverdeleon.com.mx/wp-content/uploads/2016/09/imagen-de-prueba-320x240.jpg","properties":{"p0":"v0","p1":"v1","p2":"v2","p3":"v3"},"state":"Abierta","notification":"si","expireAt":"2018-10-25 10:02:29.769579","assignedTo":"oper_rUxl"} """)).asJSON
)

setUp(scn.inject(rampUsersPerSec(500) to (1000) during(20 seconds))).protocols(httpProtocol)
}

0 comments on commit 9d4c937

Please sign in to comment.