0
votes

I am first time using gatling and I am stack with such task I need to provide working code of the following scenarios: dont know how to describe logging in/out

  1. Basic flow: user1 is login in > continue to landing page > navigating through pages
  2. Flow2 : user2 which is already logged in is downloading some pages
  3. Flow 3: user1 and user2 are logging in and out for about 500 time each during 10 minutes.
1

1 Answers

1
votes

You can use "Scenarios" and "Chain" them. Each flow you are mentioning will become a scenario.

To give you a hint: Start with defining User Requests: for e.x.: Login, Logout, Go To Landing Page, Navigate Some Pages, Download Something etc.

val loginRequest = exec(http("Login").get(...))

Then define Scenario like:

val basicFlow = scenario("My basic flow").exec(loginRequest).exec(browseRequest).exec(logout)
val flow2 = scenario("My 2nd Flow").exec(loginRequest).exec(browseRequest).exec(downloadRequest).exec(logout)

Then you can chain your scenarios in Simulation/setUp like:

setUp(basicFlow(injectAtOnce(1)), flow2(rampUsers(20) over (3 minutes))

You can then improve the load (setUp method), loop your requests etc. The Gatling Documentation is a good place to start. The following pages will help elaborate more on what I explained briefly above:

If all this seems overwhelming, I would suggest start your record your individual scenarios and then refactor the generated code.

Once you are familiar with the concepts, you can try their helpful Cheatsheet

Edit#1 Gatling has restructured their documentation, updated the links. Please note that the code is as of Gatling 2.0.3, current version is 2.3, so it might not work out of the box, but the concept remains the same.