Log gatling-session on test failure

Hi.

We have a simulation, and if a request fails, we want to log the gatling-session object to easily find the username and other info about the current user.

Is this possible to do in gatling? What we want is something like “execute this block when the request fails”, or “execute this block when a check fails”.

Regards,
Henrik Wingerei

Hi,

Since 2.0.0-M1, infoExtractor hook takes a Session parameter:
https://github.com/excilys/gatling/issues/1004

There’s also a builtin that adds the Session content to simulation.log records when the request fails.
https://github.com/excilys/gatling/commit/b7b6299c658d0aa1b88971208eb0c98a9808e37f

You can adapt this example if you just want to log with logback.

class MySimulation extends Simulation with Logging {

def logSessionOnFailure(status: RequestStatus, session: Session, request: Request, response: ExtendedResponse): List[String] = {
if (status == KO) logger.error(session)
Nil
}

val httpConf = http

.extraInfoExtractor(logSessionOnFailure)

}

Cheers,

Stéphane

Thanks! I’ll look into it!

Is something similar possible in 1.5.0 as well? We’re currently using that version on the project I’m working on.

Henrik

kl. 14:20:38 UTC+2 mandag 13. mai 2013 skrev Stéphane Landelle følgende:

Sadly no: the hook before Gatling 2 doesn’t take the session.

Ok. I’ll see whether it’s possible to upgrade the project.

Just to be clear: There are no ways in 1.5.X to execute any “custom” code (written in the simulation) when a request fails? For example, if we want to execute a block of code.

kl. 14:35:42 UTC+2 mandag 13. mai 2013 skrev Stéphane Landelle følgende:

Nope, sorry…

Actually, that’s something we could easily add to log triggered on request failure: https://github.com/excilys/gatling/wiki/Configuration#wiki-config-files
If that would meet your needs, please open an issue and we’ll add it for 1.5.1.

Cheers,

Stéphane

That would definitely help us!

Created the following issue: https://github.com/excilys/gatling/issues/1160

-Henrik

kl. 15:14:37 UTC+2 mandag 13. mai 2013 skrev Stéphane Landelle følgende:

Done! Will be in 1.5.1 and 2.0.0-M3.

Thanks! Impressive response time you guys have!

Any idea of when 1.5.1 will be released?

-Henrik

kl. 00:58:53 UTC+2 tirsdag 14. mai 2013 skrev Stéphane Landelle følgende:

Probably next week.