Hi guys, I’m looking for a way to pass the scenario name I want to run in simulation via the command line./
For example:
The command line command and arguments look like this:
mvn gatling:test -Dgatling.simulationClass=performance.com.api.simulation.Simulation -DUSERS=10 -DRAMP_DURATION=100 -DDURATION=2400 -DTESTNAME=“scnCreateUser”
I am running this in Jenkins and I want to be able to configure the scenario to run from there and not have to hard code it
these are my different files:
request file(MSXPlatformUser.scala)
package ...
import ...
object MSXPlatformUser extends BaseSimulation{
def randomString(length: Int):String = {
rnd.alphanumeric.filter(_.isLetter).take(length).mkString
}
def getPagedTenants: ChainBuilder = {
feed(custPageIteratorFeeder)
.exec(http("Get Existing Tenants Paged")
...
)
}
def createNewUser: ChainBuilder = {
feed(custRandGroupTenantFeeder)
.exec(http("Create New User")
...
)
}
def getNewUser: ChainBuilder = {
exec(http("Retrieve New User")
...
)
}
}
Scenario File (Scenario.scala)
Thank you Vu! I got it to work well partly. And it works very well! Next I want to pass an argument with a list. For example -Dtestsimulationstorun=test5,test25,test7. Any idea if this is possible?
-George K
I’m glad you made it work.
Below is the gist of what I have currently. You may want to add more Scala codes for your specific need. Hope that helps!
`
class Test extends Simulation {
def getOption(key: String, default: String): String = { java.lang.System.getProperty(key, default) }
val simScenarios = getOption(…) /** this is your testsimulationstorun /
val simUrls = getOption(…) /* this is your target server urls */
def testSimulation = {
val testScenarios = Map(
“test1” → Set(
test1.inject(…)
),
“test2” → Set(
test2.inject(…)
),
“test3” → Set(
test3.inject(…)
)
)
simScenarios
.split(",|\+")
.foldLeftSet[io.gatling.core.structure.PopulationBuilder]((sim, scn) => sim ++ testScenarios(scn.trim()))
.toVector
}
def testProtocol = {
val testBaseUrls: Vector[String] = simUrls.split(",|\+").map(_.trim()).toVector
val testHeaders: Map[String, String] = Map(
“Connection” → “close”
)
http
.baseURLs(testBaseUrls: _*)
.disableFollowRedirect
.headers(testHeaders)
}
setUp(testSimulation: _*).protocols(testProtocol)
}
`