Skip to content

Instantly share code, notes, and snippets.

@laurentbristiel
Created June 10, 2013 21:39
Show Gist options
  • Save laurentbristiel/5752602 to your computer and use it in GitHub Desktop.
Save laurentbristiel/5752602 to your computer and use it in GitHub Desktop.
Gatling Stress Testing script generated by the recorder. This is 3 clicks in Jenkins!
package Jenkins
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import com.excilys.ebi.gatling.jdbc.Predef._
import com.excilys.ebi.gatling.http.Headers.Names._
import akka.util.duration._
import bootstrap._
import assertions._
class RecordedSimulation extends Simulation {
val httpConf = httpConfig
.baseURL("http://localhost:8080")
.acceptHeader("image/png,image/*;q=0.8,*/*;q=0.5")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("fr,en-us;q=0.7,en;q=0.3")
.connection("keep-alive")
.userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0")
/* the requests that were recorder used 3 different headers
that will be used in the next section to describe the requests */
val headers_1 = Map(
"Accept" -> """text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"""
)
val headers_12 = Map(
"Accept" -> """text/javascript, text/html, application/xml, text/xml, */*""",
"Cache-Control" -> """no-cache""",
"Content-Type" -> """application/json; charset=UTF-8""",
"Pragma" -> """no-cache""",
"X-Prototype-Version" -> """1.7""",
"X-Requested-With" -> """XMLHttpRequest"""
)
val headers_20 = Map(
"Accept" -> """text/css,*/*;q=0.1"""
)
val headers_22 = Map(
"Accept" -> """*/*"""
)
/* this is the scenario made of requests and pauses
pauses can be:
- human: as a user, I waited I second before clicking on "job" link
- technical: as a browser, Firefox retrieved some PNG 33ms after starting to download the job page */
val scn = scenario("Scenario Name")
.exec(http("request_1")
.get("/job/fakejob/")
.headers(headers_1)
)
.pause(47 milliseconds)
.exec(http("request_2")
.get("/static/c933ba45/images/24x24/up.png")
)
.exec(http("request_3")
.get("/static/c933ba45/images/48x48/folder.png")
)
.exec(http("request_4")
.get("/static/c933ba45/images/24x24/search.png")
)
.exec(http("request_5")
.get("/static/c933ba45/images/16x16/red.png")
)
.exec(http("request_6")
.get("/static/c933ba45/images/24x24/folder.png")
)
.exec(http("request_7")
.get("/static/c933ba45/images/24x24/edit-delete.png")
)
.exec(http("request_8")
.get("/static/c933ba45/images/16x16/blue.png")
)
.exec(http("request_9")
.get("/static/c933ba45/images/48x48/notepad.png")
)
.pause(242 milliseconds)
.exec(http("request_10")
.get("/static/c933ba45/scripts/yui/assets/skins/sam/sprite.png")
)
.pause(622 milliseconds)
.exec(http("request_11")
.get("http://updates.jenkins-ci.org/update-center.json.html")
.headers(headers_1)
.queryParam("""id""", """default""")
.queryParam("""version""", """1.517""")
)
.pause(1)
.exec(http("request_12")
.post("/updateCenter/byId/default/postBack")
.headers(headers_12)
.fileBody("RecordedSimulation_request_12.txt")
)
.pause(160 milliseconds)
.exec(http("request_13")
.get("/job/fakejob/3/")
.headers(headers_1)
)
.pause(40 milliseconds)
.exec(http("request_14")
.get("/static/c933ba45/images/48x48/orange-square.png")
)
.exec(http("request_15")
.get("/static/c933ba45/images/24x24/previous.png")
)
.exec(http("request_16")
.get("/static/c933ba45/images/48x48/blue.png")
)
.exec(http("request_17")
.get("/static/c933ba45/images/24x24/terminal.png")
)
.pause(1)
.exec(http("request_18")
.get("/job/fakejob/3/console")
.headers(headers_1)
)
.pause(28 milliseconds)
.exec(http("request_19")
.get("/static/c933ba45/images/24x24/document.png")
)
.exec(http("request_20")
.get("/descriptor/hudson.tasks._ant.AntOutcomeNote/style.css")
.headers(headers_20)
)
.exec(http("request_21")
.get("/descriptor/hudson.console.ExpandableDetailsNote/style.css")
.headers(headers_20)
)
.pause(13 milliseconds)
.exec(http("request_22")
.get("/descriptor/hudson.console.ExpandableDetailsNote/script.js")
.headers(headers_22)
)
.exec(http("request_23")
.get("/descriptor/hudson.tasks._ant.AntTargetNote/script.js")
.headers(headers_22)
)
/* I will run the scenario for 1 user only */
setUp(scn.users(1).protocolConfig(httpConf))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment