-
-
Save anonymous/f26b7a0334ce15a6fe17 to your computer and use it in GitHub Desktop.
SampleLoadTest
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
import java.util.concurrent.atomic.AtomicInteger | |
import io.gatling.core.Predef._ | |
import io.gatling.http.Predef._ | |
import scala.util.Random | |
class LoadTest extends Simulation { | |
val httpProtocol = http.baseURL("someUrl") | |
val deleteCounter = new AtomicInteger(1) | |
val randomNumber = new Random() | |
def getIt(requestTitle: String, | |
requestURL: String, | |
pause: Int) = { | |
exec(http(requestTitle).get(Session => requestURL)).pause(pause) //Session => doesn't work here | |
} | |
def postMePlease(requestTitle: String, | |
requestURL: String, | |
pause: Int, | |
listOfParams: Seq[(String, String)]) = { | |
exec(http(requestTitle) | |
.post(requestURL) | |
.formParamSeq(Session => listOfParams)) //Session => doesn't work here | |
.pause(pause) | |
} | |
def goHome = { | |
getIt("HomePage", "/", 3) | |
} | |
def delete = { | |
getIt("PressDelete", "/", "SomeUrlFirstPart_" | |
+ deleteCounter.getAndIncrement //This part of url I need to be different for all sessions | |
+ "_SomeUrlSecondPart", 3) | |
} | |
def deleteConfirm = { | |
postMePlease("ConfirmDelete", "SomeUrl", 3, | |
.formParamSeq(Seq( | |
("delete", "Jah"))) | |
} | |
def setMeUp(scenarioName: io.gatling.core.structure.ScenarioBuilder, | |
delayTime: Int, | |
usersFromStart: Int, | |
rampUpUsers: Int, | |
rampUpDuration: Int, | |
protocolName: io.gatling.http.config.HttpProtocolBuilder) = { | |
scenarioName.inject( | |
nothingFor(delayTime), | |
atOnceUsers(usersFromStart), | |
rampUsers(rampUpUsers) over (rampUpDuration)) | |
.protocols(protocolName) | |
} | |
val scenarioDeleteDeclarations = scenario("Delete") | |
.exec(goHome) | |
.exec(delete) | |
.exec(deleteConfirm) | |
setUp ( | |
setMeUp(scenarioDeleteDeclarations, 0, 45, 1, 1, httpProtocol) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment