Hi,
I read link below, but I cannot find answer
It is possible to pass assertion in parameter? I using maven and command similar to
mvn gatling:test -Dusers=500 -Dramp=3600 but need something more to correct configure in Jenkins.
Thx for help
Hi,
I read link below, but I cannot find answer
It is possible to pass assertion in parameter? I using maven and command similar to
mvn gatling:test -Dusers=500 -Dramp=3600 but need something more to correct configure in Jenkins.
Thx for help
What you have on mind writing
Please provide more details.
I need something like this:
mvn gatling:test -Dusers=500 -Dramp=3600 -Dassertion=2500
My code below:
{
setUp(
getAllAnalysis
.injectClosed(
constantConcurrentUsers(users).during(executionTime))
.protocols(httpProtocol),
getAllTemplates
.injectClosed(
constantConcurrentUsers(users).during(executionTime))
.protocols(httpProtocol)
)
.maxDuration(ofSeconds(executionTime))
.assertions(
global()
.successfulRequests()
.percent()
.is(100.0)
)
.assertions(
details("getOne")
.responseTime()
.percentile3()
.lt(2500),
details("getTwo")
.responseTime()
.percentile3()
.lt(2500));
}
Change values for variables and should work as you need.
Example code in Java below:
package pl.gemiusz;
import io.gatling.javaapi.core.ScenarioBuilder;
import io.gatling.javaapi.core.Simulation;
import io.gatling.javaapi.http.HttpProtocolBuilder;
import static io.gatling.javaapi.core.CoreDsl.*;
import static io.gatling.javaapi.http.HttpDsl.http;
/**
* HOW TO RUN:
* mvnw gatling:test -Dgatling.simulationClass=pl.gemiusz.Case0006CommandLineParametersSimulation -Dfoo=10 -Dbar=GeMi -Dpercentile3responseTime=15
*/
public class Case0006CommandLineParametersSimulation extends Simulation {
int foo = Integer.getInteger("foo", 1);
String bar = System.getProperty("bar");
int percentile3responseTime = Integer.getInteger("percentile3responseTime", 10);
HttpProtocolBuilder httpProtocol =
http
.baseUrl("https://postman-echo.com");
ScenarioBuilder scn =
scenario("GeMi_CommandLineParametersSimulation")
.exec(
http("GeMi_CommandLineParametersSimulation_get_1")
.get("/get?foo=" + foo + "&bar=" + bar)
.check(jmesPath("args.foo").is(String.valueOf(foo)))
.check(jmesPath("args.bar").is(String.valueOf(bar)))
).exec(
http("GeMi_CommandLineParametersSimulation_get_2")
.get("/get?foo=" + foo + "&bar=" + bar)
.check(jmesPath("args.foo").is(String.valueOf(foo)))
.check(jmesPath("args.bar").is(String.valueOf(bar)))
);
{
setUp(scn.injectOpen(atOnceUsers(1)).protocols(httpProtocol)).assertions(
global()
.successfulRequests()
.percent()
.is(100.0)
)
.assertions(
details("GeMi_CommandLineParametersSimulation_get_1")
.responseTime()
.percentile3()
.lt(percentile3responseTime),
details("GeMi_CommandLineParametersSimulation_get_2")
.responseTime()
.percentile3()
.lt(percentile3responseTime));
}
}
For:
mvnw gatling:test -Dgatling.simulationClass=pl.gemiusz.Case0006CommandLineParametersSimulation -Dfoo=10 -Dbar=GeMi -Dpercentile3responseTime=15
get:
GeMi_CommandLineParametersSimulation_get_1: 95th percentile of response time is less than 15.0 : false (actual : 882.0)
GeMi_CommandLineParametersSimulation_get_2: 95th percentile of response time is less than 15.0 : false (actual : 287.0)
For:
mvnw gatling:test -Dgatling.simulationClass=pl.gemiusz.Case0006CommandLineParametersSimulation -Dfoo=10 -Dbar=GeMi -Dpercentile3responseTime=1500
get:
GeMi_CommandLineParametersSimulation_get_1: 95th percentile of response time is less than 1500.0 : true
GeMi_CommandLineParametersSimulation_get_2: 95th percentile of response time is less than 1500.0 : true
For (missing percentile3responseTime):
mvnw gatling:test -Dgatling.simulationClass=pl.gemiusz.Case0006CommandLineParametersSimulation -Dfoo=10 -Dbar=GeMi
get:
GeMi_CommandLineParametersSimulation_get_1: 95th percentile of response time is less than 10.0 : false (actual : 830.0)
GeMi_CommandLineParametersSimulation_get_2: 95th percentile of response time is less than 10.0 : false (actual : 217.0)
I have updated Case0006CommandLineParametersSimulation in my repo → https://github.com/gemiusz/gatling-examples-maven-java to cover this case.
Feel free to check and use
Thank you very much
Maybe Gatling docs should be update?
Hi @lechf1,
We documented that we can pass parameters from Java System properties.
But after that, it is up to the user to use it anywhere a constant can be given.
We provided only a sample for some injection parameters, but we cannot humanly be exhaustive for all possible way to use such parameters.