How to loop on a gatling inject?




down votefavorite


|


I’ve modeled some usage pattern that I want to run against our web app, and what I want to do is loop that pattern over and over for a week. I haven’t been able to find the right combination of things to do this though.



<br>val scn: ScenarioBuilder = scenario("Issue Cert Request")<br> .exec(http("enroll_child_actor").post("/v1/actor/enroll")<br> .body(StringBody(session => createRequestActorBody(getActorId(session.userId))))<br> .header("Content-Type","text/plain")<br> .header("Authorization", jwt => "ID " + TokenGenerator.get().generateOneTimeUseToken(uberActorSubjectName, Array("ots"), "http://localhost",<br> uberActorPrivateKey, uberActorIdentityCert).getEncoded)<br> .check(jsonPath("$.identityCertificate").saveAs("childIdCert"),<br> jsonPath("$.secureEndpointCertificate").saveAs("childEndpointCert")<br> )<br> ).exec(http("request_secure_endpoint_certificate").post("/v1/cert/issue")<br> .body(StringBody(createRequestCertBodySecureEndpoint))<br> .header("Content-Type","text/plain")<br> .header("Authorization", session => "ID " + TokenGenerator.get.generateTokenForActor(s"CN=http://localhost,UID=ots:${getActorId(session.userId)}", actorSecureEndpointKeyPair.getPrivate, CaCryptoUtils.certFromPemText(session.get("childEndpointCert")<br> .as[String])).getEncoded)<br> ).exec(http("request_identity_certificate").post("/v1/cert/issue")<br> .body(StringBody(createRequestCertBodySecureEndpoint))<br> .header("Content-Type","text/plain")<br> .header("Authorization", session => "ID " + TokenGenerator.get.generateTokenForActor(s"CN=http://localhost,UID=ots:${getActorId(session.userId)}", actorIdentityKeyPair.getPrivate, CaCryptoUtils.certFromPemText(session.get("childIdCert").as[String]))<br> .getEncoded)<br> )<br><br>



This is where my test is run and these steps are what I want to repeat. I have tried putting a repeat on the scenario itself (above) but that looks like it repeats sessions so that the session.userId duplicates and errors out in the app I’m testing (that field I’m using it in has to be unique).



<br>setUp {<br> scn.inject(nothingFor(4 seconds),<br> rampUsersPerSec(2) to usersMax during(durationAtMaxInSecs seconds),<br> constantUsersPerSec(usersConstant) during(durationAtLowerInSecs seconds),<br> nothingFor(3000 seconds)<br> ).protocols(httpConf)<br>}<br><br>



Short of copying and pasting the injections over and over, how can I get those steps to repeat a specified number of times?


|