diff --git a/gatling/chat/ChatSimulation.scala b/gatling/chat/ChatSimulation.scala index 1e70c3bc0bfc3fabb6b6919c8eeabe6482e58c0a..419a0431038418f80c833f3a57afedb6084cee88 100644 --- a/gatling/chat/ChatSimulation.scala +++ b/gatling/chat/ChatSimulation.scala @@ -8,70 +8,68 @@ import io.gatling.jdbc.Predef._ class ChatSimulation extends Simulation { - val httpProtocol = http - .baseURL("http://localhost") - .inferHtmlResources(BlackList(""".*\.css""", """.*\.js""", """.*\.ico"""), WhiteList()) - .acceptHeader("*/*") - .acceptEncodingHeader("gzip, deflate") - .acceptLanguageHeader("no,en;q=0.9,en-US;q=0.8,nb-NO;q=0.7,nb;q=0.6") - .userAgentHeader("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36") + val httpProtocol = http // 4 + .baseUrl("http://localhost") // 5 + .acceptHeader("*/*") // 6 + .doNotTrackHeader("1") + .acceptEncodingHeader("gzip, deflate") + .acceptLanguageHeader("no,en;q=0.9,en-US;q=0.8,nb-NO;q=0.7,nb;q=0.6") + .userAgentHeader("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36") - val headers_0 = Map( - "Content-Type" -> "application/json; charset=utf-8;", - "Origin" -> "http://localhost" - ) + val headers_0 = Map( + "Content-Type" -> "application/json; charset=utf-8;", + "Origin" -> "http://localhost") - val headers_3 = Map( - "Accept" -> "application/json", - "Content-Type" -> "application/json", - "Origin" -> "http://localhost" - ) + val headers_3 = Map( + "Accept" -> "application/json", + "Content-Type" -> "application/json", + "Origin" -> "http://localhost") - val uri1 = "http://localhost/api" + val uri1 = "http://localhost/api" - private val userFeeder = csv("usernames.csv").random + private val userFeeder = csv("usernames.csv").random - val scn = scenario("ChatSimulation") - .feed(userFeeder) - .exec(http("Login") - .post("/api/user") - .headers(headers_0) - .body(StringBody( - """{ - | "username": "${username}", - | "password": "passordpassord" - |}""".stripMargin)) - .resources(http("Fetch users") - .get("/api/user/")) - .check( - jsonPath("$[?(@.username=='${username}')].userId").findAll.saveAs("userId") - )) - .pause(6) - .exec(http("Click on Ola") - .get("/api/message/${userId(0)}/1")) - .pause(16) - .exec(http("Send msg to Ola") - .post("/api/message") - .headers(headers_3) - .body(StringBody( - """{ - | "userId1": ${userId(0)}, - | "userId2": 1, - | "messageContent":"Hei fra gatling" - |}""".stripMargin))) - .pause(15) - .exec(http("Click on kari") - .get("/api/message/${userId(0)}/2")) - .pause(2) - .exec(http("Send msg to Kari") - .post("/api/message") - .headers(headers_3) - .body(StringBody( - """{ - | "userId1": ${userId(0)}, - | "userId2": 2, - | "messageContent":"Hei fra gatling" - |}""".stripMargin))) + val scn = scenario("ChatSimulation") + .feed(userFeeder) + .exec(http("Login") + .post("/api/user") + .headers(headers_0) + .body(StringBody( + """{ + | "username": "${username}", + | "password": "passordpassord" + |}""".stripMargin)) + .resources(http("Fetch users") + .get("/api/user/")) + .check( + jsonPath("$[?(@.username=='${username}')].userId").findAll.saveAs("userId") + )) + .pause(6) + .exec(http("Click on Ola") + .get("/api/message/${userId(0)}/1")) + .pause(16) + .exec(http("Send msg to Ola") + .post("/api/message") + .headers(headers_3) + .body(StringBody( + """{ + | "userId1": ${userId(0)}, + | "userId2": 1, + | "messageContent":"Hei fra gatling" + |}""".stripMargin))) + .pause(15) + .exec(http("Click on kari") + .get("/api/message/${userId(0)}/2")) + .pause(2) + .exec(http("Send msg to Kari") + .post("/api/message") + .headers(headers_3) + .body(StringBody( + """{ + | "userId1": ${userId(0)}, + | "userId2": 2, + | "messageContent":"Hei fra gatling" + |}""".stripMargin))) - setUp(scn.inject(atOnceUsers(100))).protocols(httpProtocol) -} + setUp(scn.inject(atOnceUsers(100))).protocols(httpProtocol) +} \ No newline at end of file diff --git a/installGatling b/installGatling old mode 100644 new mode 100755 index 9f11520c790f7d3081572dd28ec7ae279eac2249..6093eecea65ed5b8e9e0bac929add261c6d83fa9 --- a/installGatling +++ b/installGatling @@ -1,4 +1,4 @@ #!/bin/bash -wget https://repo1.maven.org/maven2/io/gatling/highcharts/gatling-charts-highcharts-bundle/2.3.1/gatling-charts-highcharts-bundle-2.3.1-bundle.zip -P ~ -unzip ~/gatling-charts-highcharts-bundle-2.3.1-bundle.zip -d ~ +wget https://repo1.maven.org/maven2/io/gatling/highcharts/gatling-charts-highcharts-bundle/3.9.1/gatling-charts-highcharts-bundle-3.9.1-bundle.zip -P ~ +unzip ~/gatling-charts-highcharts-bundle-3.9.1-bundle.zip -d ~ echo Gatling Stress Tool installed diff --git a/runGatling b/runGatling old mode 100644 new mode 100755 index 179f2815d882290d2306ba25d37f4034c82ce20d..499ab643521e683ba34c81a6a1dc8534e1fcca05 --- a/runGatling +++ b/runGatling @@ -1,4 +1,4 @@ #!/bin/bash -cp -r gatling/chat ~/gatling-charts-highcharts-bundle-2.3.1/user-files/simulations -cp gatling/usernames.csv ~/gatling-charts-highcharts-bundle-2.3.1/user-files/data -~/gatling-charts-highcharts-bundle-2.3.1/bin/gatling.sh \ No newline at end of file +cp -r gatling/chat ~/gatling-charts-highcharts-bundle-3.9.1/user-files/simulations +cp gatling/usernames.csv ~/gatling-charts-highcharts-bundle-3.9.1/user-files/resources +~/gatling-charts-highcharts-bundle-3.9.1/bin/gatling.sh \ No newline at end of file