I can run Gatling simulation using the following script from command line.
JAVA_OPTS="-XX:-MaxFDLimit -Dusers=1" JAVA_CLASSPATH=pwd
$GATLING_SH -sf pwd
-s FanFlow
However I want to do it from a java code as I want to keep the Gatling simulation and the java class(lets call that as SimulationDriver) in a single jar.
I came across the Gatling.fromArgs api and was able to run it as a simulation
using the following piece of code(This is basically my SimulationDriver). But I would also like to pass the command line arguments to the Gatling simulation from the java code.(like -Dusers).
Is there a way to do that?
Gatling.fromArgs(new String[] { “-s”, “FanFlowSimulation” },
new Option<Class>() {
private static final long serialVersionUID = 1L;
@Override
public int productArity() {
return 0;
}
@Override
public Object productElement(int arg0) {
return null;
}
@SuppressWarnings(“unchecked”)
@Override
public Class get() {
try {
return (Class) Class
.forName(MySimulation.class
.getCanonicalName());
} catch (ClassNotFoundException e) {
}
return null;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public boolean canEqual(Object o) {
return false;
}
});