Gatling setup error while using andThen. Error required: io.gatling.commons.validation.Validation[io.gatling.core.structure.PopulationBuilder]

Hi,

I am writing a simulation, for the scenarios Login 9 users, API call by 9 users for 30 minutes and after 30 minutes user Logout.
val loginScenario = scenario(BaseConstants.FX_DL_LOGIN_SCENARIO)

var dealScenario=scenario(BaseConstants.FX_DL_SCENARIO)

var logoutScenario=scenario(BaseConstants.FX_DL_LOGOUT_SCENARIO)

To synchronize these scenarios, have used andThen in setup. Setup() is showing syntax error missing populationbuilder

setUp(
loginScenario
.inject(atOnceUsers(1)).andThen(dealScenario.inject(atOnceUsers(1)))
)

Error :

type mismatch;
found : io.gatling.core.structure.PopulationBuilder
required: io.gatling.commons.validation.Validation[io.gatling.core.structure.PopulationBuilder] => ?
dealScenario.inject(injectionProfile)

Please let us know if any solution to fix this issue.

Regards,
Umeshwaran.V

Please provide a real gist that someone else can try to compile.
It’s impossible to help you with just those pieces.

Hi Stephane,

Please find the sample code given below, .

import io.gatling.core.Predef._
class SyncScenarios extends Simulation{
val r = new scala.util.Random(100)
// Login Users
val loginScenario = scenario(“Login”)
.exec(session=>{
var range = r.nextInt(100)
session.set(“token”,range )
println("User : " + range)
session
} )

var dealScenario=scenario(“Deal Entry”)
.exec(session=>{
var token=session(“token”).as[String]

println("Deal Process by User : " + token )
session

})

var logOutScenario=scenario(“LogOut”)
.exec(session=>{
var token=session(“token”).as[String]

println("Logout User : " + token )
session

})

setUp(
loginScenario
.inject(atOnceUsers(1)).andThen(dealScenario.inject(atOnceUsers(1))
//.andThen(logOutScenario.inject(atOnceUsers(1))))
)
}

// getting the error while using andThen() method. I am trying to implement sequential scenario.

Error :

type mismatch;
found : io.gatling.core.structure.PopulationBuilder
required: io.gatling.commons.validation.Validation[io.gatling.core.structure.PopulationBuilder] => ?
dealScenario.inject(injectionProfile)

Thanks and Regards,
Umeshwaran.V

This code compiles just fine (tried with Gatling 3.5.0) once you fix it and add the missing closing parenthesis:

.inject(atOnceUsers(1)).andThen(dealScenario.inject(atOnceUsers(1)) <=== missing ) here

Thanks Stéphane . Parenthesis was missed during copy paste. As you suggested, have changed gatling version 3.5.0. So the andThen() method syntax is corrected.
While I am compiling getting the errors as given below. I also upgraded scala version to 2.13.4 and JDK 15.0.2. POM files have been attached for your reference.

Please let me know any other dependency or existing dependency need to correct.

scalac: error while loading GatlingRecorder, class file ‘C:\Users\uvijayan.m2\repository\io\gatling\gatling-recorder\3.5.0\gatling-recorder-3.5.0.jar(io/gatling/recorder/GatlingRecorder.class)’ is broken
(class java.lang.RuntimeException/error reading Scala signature of GatlingRecorder.class: Scala signature GatlingRecorder has wrong version
expected: 5.0
found: 5.2 in GatlingRecorder.class)

scalac: error while loading package, class file ‘C:\Users\uvijayan.m2\repository\org\scala-lang\scala-library\2.13.4\scala-library-2.13.4.jar(scala/util/package.class)’ is broken
(class java.lang.RuntimeException/error reading Scala signature of package.class: Scala signature package has wrong version
expected: 5.0
found: 5.2 in package.class)

Versions Reference

pom.xml (4.87 KB)

Your dependency tree is broken because you’re pulling org.scala-lang:scala-parser-combinators:2.11.0-M4 which is a VERY old version for Scala 2.11.
You’re ending up with multiple versions of Scala in your classpath: Scala 2.13 and Scala 2.11 that are not compatible.
You have to use only Scala libraries for Scala 2.13.

Hi Stephane,

Dependency issue has been solved. Thanks for your help.

We got another problem, the session is not shareable to scenarios. We want 9 users log in first, 5 users constantly do the deal entry for 30min, after 30mins 2 users logoff with the pacing of 30seconds.
When running the simulation the dealEntry scenario getting the error 20:53:13.491 [ERROR] i.g.h.a.HttpRequestAction - ‘httpRequest-9’ failed to execute: No attribute named ‘token’ is defined

I have shared the code :

class DealEntrySimulation extends Simulation with BaseTrait {

//loading the user feeders
val userFeeder = csv(BaseConstants.FX_DL_USERS).circular

//loading the user feeders
val dataFeeder = csv(BaseConstants.FX_DL_DATA).circular

// Login Users
val loginScenario = scenario(BaseConstants.FX_DL_LOGIN_SCENARIO)
.feed(userFeeder)
.exec(http(BaseConstants.LOGINACCESS)
.post( secUrl+ BaseConstants.LOGINURL)
.headers(secureHeaders)
.check(status.is(200))
.check(jsonPath(BaseConstants.ACCESS_TOKEN_JSON_KEY).saveAs(BaseConstants.TOKEN)))
.pause(20)

val httpApiProtocol=http.baseUrl(appUrl)

//Loading Deal Entry Body Json from file
var dealScenario=scenario(BaseConstants.FX_DL_SCENARIO)
.feed(dataFeeder)
.exec(session=>
session.set(BaseConstants.SIGNONBRANCH, signOnBranch).set(BaseConstants.BPD, BPD)

)
.exec(http(BaseConstants.FX_DL_SCENARIO)
.post( appUrl+ BaseConstants.FX_DL_URI)
.header(BaseConstants.TRADE_ACCESS_TOKEN,BaseConstants.TOKEN_VAR_KEY) //"${token}" error in this line No attribute named ‘token’ is defined
.body(ElFileBody(BaseConstants.FX_DL_BODY_JSON))
.asJson.check(status.is(200)))
.pause(10)

//Logout the users
var logoutScenario=scenario(BaseConstants.FX_DL_LOGOUT_SCENARIO)

.exec(http(BaseConstants.LOGOUTACCESS)
.post(secUrl+BaseConstants.LOGOUTURL)
.header(BaseConstants.ACCESS_TOKEN,BaseConstants.TOKEN_VAR_KEY) //"${token}" error in this line No attribute named ‘token’ is defined
.check(status.is(200))).pause(20)

setUp(
loginScenario
.inject(rampUsers(9).during(30)).andThen( dealScenario.inject(constantUsersPerSec(5).during(15)).throttle(
reachRps(2) in (20 seconds),
holdFor(5 minutes))
.andThen(logoutScenario.inject(constantUsersPerSec(2).during(30))))
)

}

Plesae let me any solution around problem.

Regards,
Umeshwaran.V

That’s not an issue, that’s how Gatling works. scenario + injection profile = independent population of virtual users

I recommend you read the documentation and/or go through the online course at Gatling Academy.

Hi Stephane,

Thanks a lot for your feedback. I have created a user token queue preserving the token during login scenario. Deal Processing used token from the preserved queue.

Setup have created to slow ramp users, steady run and ramp down users as given below.
setUp(
loginScenario.inject(rampUsers(9) during (3 minutes))
.andThen(dealScenario.inject( rampConcurrentUsers(1) to(9) during(4 minutes),
constantConcurrentUsers(9) during (5 minutes) ,
rampConcurrentUsers(9) to 1 during(4 minutes) )
.andThen( logoutScenario.inject(rampUsers(9) during(3 minutes)))
))

Also, I can able to generate the graph as expected.

one issue I have while generating the report for simulations in parallel execution. The reports generating for each simulation, its not aggregating and providing a single report for all simulations.
Could you please suggest is there a way to aggregate the reports?

Regards,
Umeshwaran.V

You’re confusing simulations and scenarios. Those are scenarios run concurrently in the same simulation.
No, in Gatling OSS HTML reports, there’s no way to tell scenarios appart. This filter is only available in FrontLine.
As a workaround, you can consider using groups.

Hi Stephane,

We have two simulations, one is DealEntry and DealVerify, Both will be performed a different set of users. If I run this simulation using parallel execution the reports are generating two different HTML files.
How to combine and generate a consolidated report.

Thanks and Regards,
Umeshwaran.v

Hi Stephane,

Finally, I can able to achieve the report for multiple simulations and it’s running together.
Combined all my simulations into the main simulation to run each action parallel and with simulation the sequential scenarios.

Thanks for your help, and let me know if any suggestion.

Regards,
Umeshwaran.V