New posts
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package lab.gatling;
|
||||
|
||||
import static io.gatling.javaapi.core.CoreDsl.*;
|
||||
import static io.gatling.javaapi.http.HttpDsl.*;
|
||||
|
||||
import io.gatling.javaapi.core.FeederBuilder;
|
||||
import io.gatling.javaapi.core.ScenarioBuilder;
|
||||
import io.gatling.javaapi.core.Simulation;
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* A scenario with a feeder, checks and a mix of injection steps.
|
||||
* Every user looks up two random symbols with a short think time in between.
|
||||
*/
|
||||
public class BasicSimulation extends Simulation {
|
||||
|
||||
FeederBuilder<String> symbols = csv("data/symbols.csv").random();
|
||||
|
||||
ScenarioBuilder browse = scenario("Browse quotes")
|
||||
.feed(symbols)
|
||||
.exec(http("get quote")
|
||||
.get("/api/quote/#{symbol}")
|
||||
.check(
|
||||
status().is(200),
|
||||
jmesPath("symbol").isEL("#{symbol}"),
|
||||
jmesPath("price").ofDouble().gt(0.0)))
|
||||
.pause(Duration.ofMillis(200), Duration.ofMillis(500))
|
||||
.feed(symbols)
|
||||
.exec(http("get another quote")
|
||||
.get("/api/quote/#{symbol}")
|
||||
.check(status().is(200)));
|
||||
|
||||
{
|
||||
setUp(browse.injectOpen(
|
||||
atOnceUsers(5),
|
||||
nothingFor(Duration.ofSeconds(2)),
|
||||
rampUsers(20).during(Duration.ofSeconds(5)),
|
||||
constantUsersPerSec(10).during(Duration.ofSeconds(10))))
|
||||
.protocols(Config.protocol())
|
||||
.assertions(
|
||||
global().responseTime().percentile(95).lt(200),
|
||||
global().successfulRequests().percent().gt(99.0));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user