-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCase0007AsyncReqSimulation.java
More file actions
51 lines (43 loc) · 1.86 KB
/
Case0007AsyncReqSimulation.java
File metadata and controls
51 lines (43 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package pl.gemiusz;
import io.gatling.javaapi.core.ScenarioBuilder;
import io.gatling.javaapi.core.Simulation;
import io.gatling.javaapi.http.HttpProtocolBuilder;
import io.netty.util.internal.ThreadLocalRandom;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.function.Supplier;
import java.util.stream.Stream;
import static io.gatling.javaapi.core.CoreDsl.*;
import static io.gatling.javaapi.http.HttpDsl.http;
public class Case0007AsyncReqSimulation extends Simulation {
HttpProtocolBuilder httpProtocol =
http
.baseUrl("https://postman-echo.com");
Iterator<Map<String, Object>> feederInt =
Stream.generate((Supplier<Map<String, Object>>) () -> {
int min = 3;
int max = 6;
int randomInt = ThreadLocalRandom.current().nextInt(min, max);
return Collections.singletonMap("randomInt", randomInt);
}
).iterator();
ScenarioBuilder scn =
scenario("GeMi_AsyncReqSimulation")
.feed(feederInt)
.exec(
http("GeMi_AsyncReqSimulation_get")
.get("/get?foo=#{randomInt}")
.check(jmesPath("args.foo").isEL("#{randomInt}"))
)
.repeat("#{randomInt}", "counterRandomInt").on(
exec(
http("GeMi_AsyncReqSimulation_async_#{counterRandomInt}")
.get("/get?foo=#{counterRandomInt}")
.check(jmesPath("args.foo").isEL("#{counterRandomInt}"))
)
);
{
setUp(scn.injectOpen(atOnceUsers(1)).protocols(httpProtocol));
}
}