I have a simulation with 4 different scenarios. I want to create a couple of different setups. For example: small load, medium load and high load. For every setup every scenario will have different amount of users, ramp ups and so on. Is it possible to do this? Right now my simulation is run through Gradle:
args = Eval.me("[’-s’, ‘loadTests.LoadTest’]")
Is it possible to create something like this:
args = Eval.me("[’-s’, ‘loadTests.LoadTest’ -high/medium/small]")
I know I can copy the simulation and create 4 different scala classes with same content but different setup, but that doesn’t sound like the right thing to do.
I read about JAVA_OPTS in wiki, but I couldn’t figure out where do I put it in my build.gradle
task runLoadTest(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
// Gatling application
main = “io.gatling.app.Gatling”
// Specify the simulation to run
args = Eval.me("[’-s’, ‘loadTests.LoadTest’]")
}
In my LoadTest.scala class I put:
val nbUsers:Int = java.lang.Integer.getInteger(“users”, 1)
Then in setup I set number of users to nbUsers
Finally, to the build.gradle file I added:
task runLoadTest(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
// Gatling application
main = “io.gatling.app.Gatling”
// Specify the simulation to run
args = Eval.me("[’-s’, ‘JAVA_OPTS="-Dusers=100"’, ‘loadTests.LoadTest’]")
}
However, I keep getting
Error: Unknown argument ‘loadTests.LoadTest’
I still haven’t found a solution how to pass this parameters to Gradle. Maybe a hint?
Have you just tried to set a System property manually?
I did setup a system property manually:
export JAVA_OPTS="-Dusers=15"
But I still have no idea how to pass this to gradle. At the moment:
task runLoadTest(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
// Gatling application
main = “io.gatling.app.Gatling”
// Specify the simulation to run
args = me("[‘JAVA_OPTS’, ‘-s’, ‘loadTests.LoadTest’]")
}
shows that Error: Unknown argument ‘JAVA_OPTS’
That’s a question for the Gradle mailing list: how do I pass Java System properties.
I manage to write the script that passes parameters: Integer to gradle, but what if I want to pass the scenario name. What should I declare in the simulation file?
val nbScn:io.gatling.core.structure.ScenarioBuilder = java.lang.String(“scn”, someScenarioName)
Would this work?
That’s just plain old Java APIs. Don’t you have a Java background?
I started using gatling about 2 weeks ago without any background.
No programming background? At all? And you went with Gradle?
I did a little programming, but nothing major. Found some practice for 2 month - I need to write stress tests for an application. The developers said that I need to build my tests with some build system so I chose gradle as I found some tutorial.
OK, so now I get it.
so I chose gradle as I found some tutorial
No offense, but you might have chosen to climb from the North face.
I’m not criticizing the tool, just that we don’t have an official Gradle support yet and we (core committers) haven’t started growing Gradle skills yet. We have a maven plugin and a sbt plugin though.
val nbScn:io.gatling.core.structure.ScenarioBuilder = java.lang.String(“scn”, someScenarioName)
No, that wouldn’t work.
In Java (Scala uses the Java API for this), System properties are String that you retrieve this way: http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#getProperty(java.lang.String)
So if you want a simple String, that’s it.
Integer.getInteger(“key”, defaultValue) is just a convenient method built on top of it.
I tried:
val nbScn:io.gatling.core.structure.ScenarioBuilder = java.lang.System.getProperty(“scn”, scenarioAddDeclarations)
But it doesn’t compile:
cannot be applied to (String, io.gatling.core.structure.ScenarioBuilder)
I suppose it’s because the value of getProperty has to be String and not io.gatling.core.structure.ScenarioBuilder. But it doesn’t work the other way, because compiler expects the type io.gatling.core.structure.ScenarioBuilder and not the String.
You’re trying to go too fast and don’t properly read the documentation I send you.
With System.getProperty, you get a String.
Then, you can have something like a match in order to select the proper scenario.
val nbScn = System.getProperty(“scn”, “whateverDefaultValue”) match {
case “foo” => scenarioAddDeclarations
case “bar” => someOtherScenario
}
I tried:
val nbScn = System.getProperty(“scn”, “defValue”) match {
case “defValue” => scenarioAddDeclarations
}
It doesn’t compile. Exception in thread “main” java.lang.NullPointerException.
Actually I did it a bit differently, but it works now. Instead of setting the scenario name I called method the sets up some specific scenario. Thanks for your patience. Without you I wouldn’t have gone this far.