Check status

I’m not really an experienced programmer. I’m in my first internship, and I’m experimenting with gatling (basically I’m the only person doing gatling at this company so I can’t ask anyone else). My question is, when I’m doing a check, can I check the status when logging in from a feed and if the status is wrong can I get the feeds username so I know which ones are failing?

val scn = scenario(“Scenario Name”)
.param(""“j_username”"", “”"${username}""")
.param(""“j_password”"", “”"${password}"""))

.doIf(check( { //<— How can I write that line properly?
print("""${username}""") }

.pause(577 milliseconds)
.pause(135 milliseconds)

I just realized that by doing ${username} in the print statement of the conditional, it probably moves on to the next username and prints it out instead of printing out the right one… I just need someone to tell me how to do what I want to do because I feel like I have no idea what I’m doing.

Is this only for debugging, or do you want to have this information while running the actual load test?

This sounds like a typical thing you would want to know when running tests. Bad test data is not uncommon.

With Gatling 2M3a, you can:

With Gatling 2 snapshot:

  • it’s easier to write your own check
  • you can define extraInfoExtractor on request too

Let me actually explain the problem. So, I have 80,000 users or so in a csv file, and some of them have wrong passwords and right passwords (I’m still trying to figure out a way to maybe randomly feed wrong passwords from one csv file and right ones from the other csv file). My boss wants me to test both logging in sucesses and failures. But before I figure that out, I need to know how to print information. I probably wouldn’t print much for 80,000 users, but for smaller amounts definitely. Just so I could know which user is being entered in. Also it would be beneficial for other information later on.

I’m reading over the extraInfoExtractor and I’m not really understanding what I should be entering in as the parameters? I got this from doing a little bit of searching the group

val httpConf = httpConfig
.extraInfoExtractor((status:Status, session:Session, request:Request, response: Response) => {

But as I said, I’m a noob. I’m not really getting the parameters.

Status: As in a HTTP status code? If that is the case, can I make it any status code? I really want to use this for every situation…
Session: ???
Request: .exec(http(“REQUEST_NAME”). So the “REQUEST_NAME” is what I should enter.
Response: ???

Sessions were actually another thing I was looking at.

You’d probably feel more comfortable with an IDE so that you can explore types and Gatling DSL.
You can also explore on Github (tip: type T and then the name of the file you’re looking for)


Request and response are the actual request and response objects.

You could write something like this:

import io.gatling.core.result.message._

.extraInfoExtractor((status, session, _, _) => status match {
case KO => List(session(“username”).as[String])
case _ => Nil

Then, you’d get the username printed in simulation.log file.

For debugging purpose, you can just log in the console:

.extraInfoExtractor((status, session, _, _) => {
if (status == KO)

In cases like this: What you really want to do is to generate a new CSV file with the same format as the input data during the test, so that you can immediately import that into a spreadsheet and/or hand that data back to your loadtest.

So you don’t want to print just the failed users. You want to print all of them.

Easiest way to do that in loadrunner is to print/log a line for every login, listing the username, password (if needed/applicable), and login result (pass/fail), in comma seperated format, and then simply use a grep over the final set of vuser logs (you get one file per virtual user in loadrunner) to put the end result together.

Usually that file is then used to

  1. feed good users to the loadtest
  2. put together a spreadsheet for the people responsible for the test data in question, so that the problems can be fixed.

( I’ve also seen scripts where ‘fixing it’ is actually done dynamically by the loadtest script itself, simply by hitting a settings page in the application every time we come across a ‘bad’ user.

That distorts the load a little but … either it doesn’t happen enough to cause a real problem, or it happens too often and then fixing it is the right thing to do anyway, even if the test itself is a loss. :wink: )

Ok cool. Finally ran without errors. I set it up like this:

val httpProtocol = http

.extraInfoExtractor((status, session, _, _) => status match {
case KO => List(session(“username”).as[String])
case _ => Nil

It seems to work, but when I check my simulation.log file, there’s nothing relevant in the file?

Here’s my logback file if this helps…

Are you sure? I just checked with current master and I do have additional columns in simulation.log with the data I logged.