Created
April 22, 2020 18:03
-
-
Save polarnik/39092c71eea1b2120fe832ea2bdd91a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package qaload | |
import java.text.SimpleDateFormat | |
import java.util.Calendar | |
import io.gatling.core.Predef._ | |
import io.gatling.http.Predef._ | |
import scala.concurrent.duration._ | |
import qaload.gatling.asynclogplugin.Predef._ | |
class BasicSimulation extends Simulation { | |
val httpProtocol = http | |
.baseUrl("http://computer-database.gatling.io") // Here is the root for all relative URLs | |
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // Here are the common headers | |
.acceptEncodingHeader("gzip, deflate") | |
.acceptLanguageHeader("en-US,en;q=0.5") | |
.userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0") | |
val scn = scenario("Scenario Name") // A scenario is a chain of requests and pauses | |
.exec { | |
session => | |
val now = System.currentTimeMillis; | |
val nowDate = Calendar.getInstance().getTime() | |
val dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz") | |
val nowString = dateFormat.format(nowDate) | |
session | |
.set("start", now) | |
.set("startDate", nowDate) | |
.set("startDateString", nowString) | |
} | |
.exec( | |
http("/ (GET)").get("/") | |
) | |
.exec { | |
session => | |
val now = System.currentTimeMillis; | |
val nowDate = Calendar.getInstance().getTime() | |
val dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz") | |
val nowString = dateFormat.format(nowDate) | |
session | |
.set("stop", now) | |
.set("stopDate", nowDate) | |
.set("stopDateString", nowString) | |
} | |
.exec { | |
session => | |
session | |
} | |
.exec(asynclog | |
.requestName("Generate req 1") | |
.startTimestamp("${start}") | |
.endTimestamp("${stop}") | |
.status(io.gatling.commons.stats.OK) | |
.responseCode("200") | |
.message("startTimestamp(System.currentTimeMillis), endTimestamp(System.currentTimeMillis)") | |
) | |
.exec(asynclog | |
.requestName("Generate req 2") | |
.startTimestamp("${start}") | |
.endTimestamp("${stop}") | |
.status(io.gatling.commons.stats.KO) | |
.responseCode("500") | |
.message("500 Error Message") | |
) | |
.exec(asynclog | |
.requestName("Generate req 3") | |
.startDate("${startDate}") | |
.endDate("${stopDate}") | |
.status(io.gatling.commons.stats.OK) | |
.responseCode("200") | |
.message("startDate(java.util.Date), endDate(java.util.Date) [${startDate}, ${stopDate}]") | |
) | |
.exec(asynclog | |
.requestName("Generate req 4") | |
.startTimestamp("${startDateString}", "yyyy-MM-dd HH:mm:ss.SSS zzz") | |
.endTimestamp("${stopDateString}", "yyyy-MM-dd HH:mm:ss.SSS zzz") | |
.status(io.gatling.commons.stats.OK) | |
.responseCode("200") | |
.message("startTimestamp(String, Format), endTimestamp(String, Format) [${startDateString}, ${stopDateString}]") | |
) | |
.exec(asynclog | |
.requestName("Generate req 5") | |
.startTimestamp("${start}") | |
.endTimestamp("${stopDateString}", "yyyy-MM-dd HH:mm:ss.SSS zzz") | |
.status(io.gatling.commons.stats.OK) | |
.responseCode("201") | |
.message("startTimestamp(System.currentTimeMillis), endTimestamp(String, Format) [${start}, ${stopDateString}]") | |
) | |
setUp(scn.inject(atOnceUsers(1)).protocols(httpProtocol)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RUN qaload.BasicSimulation basicsimulation 1587578007201 open workload model 3.3.1 | |
USER Scenario Name 1 START 1587578008541 1587578008541 | |
REQUEST 1 / (GET) 1587578008577 1587578008945 OK | |
REQUEST 1 / (GET) Redirect 1 1587578008975 1587578009038 OK | |
REQUEST 1 Generate req 1 1587578008546 1587578009069 OK startTimestamp(System.currentTimeMillis), endTimestamp(System.currentTimeMillis) | |
REQUEST 1 Generate req 2 1587578008546 1587578009069 KO 500 Error Message | |
REQUEST 1 Generate req 3 1587578008546 1587578009069 OK startDate(java.util.Date), endDate(java.util.Date) [Wed Apr 22 20:53:28 MSK 2020, Wed Apr 22 20:53:29 MSK 2020] | |
REQUEST 1 Generate req 4 1587578008546 1587578009069 OK startTimestamp(String, Format), endTimestamp(String, Format) [2020-04-22 20:53:28.546 MSK, 2020-04-22 20:53:29.069 MSK] | |
REQUEST 1 Generate req 5 1587578008546 1587578009069 OK startTimestamp(System.currentTimeMillis), endTimestamp(String, Format) [1587578008546, 2020-04-22 20:53:29.069 MSK] | |
USER Scenario Name 1 END 1587578008541 1587578009086 |
Author
polarnik
commented
Apr 22, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment