Skip to content

Commit 1d1f03e

Browse files
committedJul 29, 2018
Added a large stubs GET scenario
1 parent 91f81ca commit 1d1f03e

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed
 

‎.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.1.10

‎perf-test/src/gatling/scala/wiremock/StubbingAndVerifyingSimulation.scala

+14-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class StubbingAndVerifyingSimulation extends Simulation {
1414
before {
1515
loadTestConfiguration.before()
1616
// loadTestConfiguration.mixed100StubScenario()
17-
loadTestConfiguration.onlyGet6000StubScenario()
17+
// loadTestConfiguration.onlyGet6000StubScenario()
18+
loadTestConfiguration.getLargeStubScenario()
1819
}
1920

2021
after {
@@ -80,9 +81,20 @@ class StubbingAndVerifyingSimulation extends Simulation {
8081
}
8182
}
8283

84+
val getLargeStubsScenario = {
85+
scenario("100 large GETs")
86+
.repeat(1) {
87+
exec(http("GETs")
88+
.get(session => s"load-test/${random.nextInt(99) + 1}")
89+
.header("Accept", "text/plain+stuff")
90+
.check(status.is(200)))
91+
}
92+
}
93+
8394
setUp(
8495
// mixed100StubScenario.inject(constantUsersPerSec(loadTestConfiguration.getRate) during(loadTestConfiguration.getDurationSeconds seconds))
85-
onlyGet6000StubScenario.inject(constantUsersPerSec(loadTestConfiguration.getRate) during(loadTestConfiguration.getDurationSeconds seconds))
96+
// onlyGet6000StubScenario.inject(constantUsersPerSec(loadTestConfiguration.getRate) during(loadTestConfiguration.getDurationSeconds seconds))
97+
getLargeStubsScenario.inject(constantUsersPerSec(loadTestConfiguration.getRate) during(loadTestConfiguration.getDurationSeconds seconds))
8698
).protocols(httpConf)
8799

88100
}

‎perf-test/src/main/java/wiremock/LoadTestConfiguration.java

+39-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void before() {
8080
}
8181

8282
public void onlyGet6000StubScenario() {
83-
System.out.println("Regsitering stubs");
83+
System.out.println("Registering stubs");
8484

8585
ExecutorService executorService = Executors.newFixedThreadPool(100);
8686

@@ -117,6 +117,44 @@ public void run() {
117117
executorService.shutdown();
118118
}
119119

120+
public void getLargeStubScenario() {
121+
System.out.println("Registering stubs");
122+
123+
ExecutorService executorService = Executors.newFixedThreadPool(10);
124+
125+
wm.register(any(anyUrl()).atPriority(10)
126+
.willReturn(notFound())
127+
);
128+
129+
List<Future<?>> futures = new ArrayList<>();
130+
for (int i = 1; i <= 100; i++) {
131+
final int count = i;
132+
futures.add(executorService.submit(new Runnable() {
133+
@Override
134+
public void run() {
135+
wm.register(get("/load-test/" + count)
136+
.willReturn(ok(randomAscii(50000, 90000))));
137+
138+
if (count % 100 == 0) {
139+
System.out.print(count + " ");
140+
}
141+
142+
}
143+
}));
144+
145+
}
146+
147+
for (Future<?> future: futures) {
148+
try {
149+
future.get(30, SECONDS);
150+
} catch (Exception e) {
151+
e.printStackTrace();
152+
}
153+
}
154+
155+
executorService.shutdown();
156+
}
157+
120158
public void mixed100StubScenario() {
121159
// TODO: Optionally add delay
122160
wm.setGlobalRandomDelayVariable(new UniformDistribution(100, 2000));

0 commit comments

Comments
 (0)
Please sign in to comment.