Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run a test for specific duration in Gatling 2.2 #35

Closed
SaurabhNTT opened this issue Sep 23, 2016 · 2 comments
Closed

How to run a test for specific duration in Gatling 2.2 #35

SaurabhNTT opened this issue Sep 23, 2016 · 2 comments

Comments

@SaurabhNTT
Copy link

I have tried .during (x seconds) {

}
and also tried
setUp(scn.inject(rampUsers(200) over (100 seconds), during (560 seconds))).protocols(httpProtocol)

but none of above option works however if I remove the duration clause and just it with 100 seconds ramp test runs fine.

I searched like entire internet but didn't found any hint or solution on this.
Also I am using csv feeder for username password and kept the data extraction circular for CSV still I am getting error after sometime into test saying "no attribute found for username"
CSV file looks like this, I don't know why gatling has so weirdo format of csv rather than having it simple like jmeter.
username,passwordj2ee,j2eej2ee,j2eej2ee,j2eej2ee,j2eej2ee,j2eej2ee,j2eej2ee,j2eej2ee,j2eej2ee,j2ee

I have kept the csv like below first but it didn't worked then I found above sample somewhere which I referred.
username,password
j2ee,j2ee

My code is
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import scala.concurrent.duration._

class LoginRecordedSimulation extends Simulation {

val httpProtocol = http
    .baseURL("http://localhost:8080")
    .inferHtmlResources()
    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
    .acceptEncodingHeader("gzip, deflate, sdch")
    .acceptLanguageHeader("en-US,en;q=0.8")
    .userAgentHeader("Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36")

val headers_0 = Map("Upgrade-Insecure-Requests" -> "1")

val headers_2 = Map(
    "Accept-Encoding" -> "gzip, deflate",
    "Origin" -> "http://localhost:8080",
    "Upgrade-Insecure-Requests" -> "1")

val headers_3 = Map("Accept" -> "image/webp,image/*,*/*;q=0.8")

val csvfeeder = csv("username.csv").circular

val uri1 = "http://localhost:8080/jpetstore"



val scn = scenario("LoginRecordedSimulation")
.during (560 seconds)
{

    .exec(http("request_0")
        .get("/jpetstore")
        .headers(headers_0))
    .pause(8)
    .exec(http("request_1")
        .get("/jpetstore/shop/signonForm.shtml;jsessionid=5C5EC505BC93B2756A9F83F0308B8E61")
        .headers(headers_0))
    .pause(5)
    .exec(http("request_2")
        .post("/jpetstore/shop/signon.shtml")
        .headers(headers_2)
        .formParam("username", "${username}")
        .formParam("password", "${password}")
        .formParam("submit", "Login")
        .resources(http("request_3")
        .get("/jpetstore/images/banner_dogs.gif")
        .check(regex("Welcome").exists)
        .headers(headers_3)))
    .pause(6)
    .exec(http("request_4")
        .get("/jpetstore/shop/viewCategory.shtml?categoryId=DOGS")
        .headers(headers_0))
    .pause(2)
    .exec(http("request_5")
        .get("/jpetstore/shop/viewProduct.shtml?productId=K9-BD-01")
        .headers(headers_0))
    .pause(12)
    .exec(http("request_6")
        .get("/jpetstore/shop/viewItem.shtml?itemId=EST-6")
        .headers(headers_0)
        .resources(http("request_7")
        .get("/jpetstore/images/dog2.gif")
        .headers(headers_3)))
    .pause(6)
    .exec(http("request_8")
        .get("/jpetstore/shop/addItemToCart.shtml?workingItemId=EST-6")
        .headers(headers_0))
    .pause(8)
    .exec(http("request_9")
        .get("/jpetstore/shop/removeItemFromCart.shtml?workingItemId=EST-6")
        .headers(headers_0))
    .pause(7)
    .exec(http("request_10")
        .get("/jpetstore/shop/signoff.shtml")
        .headers(headers_0))
}
setUp(scn.inject(rampUsers(200) over (100 seconds))).protocols(httpProtocol)

}

@SaurabhNTT
Copy link
Author

Any suggestions on above issue are much appreciated. Kindly respond.

@mhjort
Copy link
Owner

mhjort commented Sep 26, 2016

Hi,

I am sorry but you posted the issue to wrong project. This project is clj-gatling which is a load testing tool for writing tests in Clojure not Scala. Probably you should post your issue to this one: https://github.com/gatling/gatling

@mhjort mhjort closed this as completed Sep 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants