-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to set increment, max and perThread settings in counters
- Loading branch information
1 parent
8283081
commit 47db8f6
Showing
2 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 55 additions & 6 deletions
61
jmeter-java-dsl/src/test/java/us/abstracta/jmeter/javadsl/core/configs/DslCounterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,74 @@ | ||
package us.abstracta.jmeter.javadsl.core.configs; | ||
|
||
import static com.github.tomakehurst.wiremock.client.WireMock.*; | ||
import static us.abstracta.jmeter.javadsl.JmeterDsl.*; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.verify; | ||
import static us.abstracta.jmeter.javadsl.JmeterDsl.counter; | ||
import static us.abstracta.jmeter.javadsl.JmeterDsl.httpSampler; | ||
import static us.abstracta.jmeter.javadsl.JmeterDsl.testPlan; | ||
import static us.abstracta.jmeter.javadsl.JmeterDsl.threadGroup; | ||
|
||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import us.abstracta.jmeter.javadsl.JmeterDslTest; | ||
import us.abstracta.jmeter.javadsl.codegeneration.MethodCallBuilderTest; | ||
import us.abstracta.jmeter.javadsl.core.DslTestPlan; | ||
|
||
public class DslCounterTest extends JmeterDslTest { | ||
|
||
@Test | ||
public void shouldUseIncrementalValuesInRequestWhenSharedCounterInRequest() throws Exception { | ||
int threads = 2; | ||
int iterations = 2; | ||
testPlan( | ||
threadGroup(threads, iterations, | ||
counter("USER_ID"), | ||
httpSampler(wiremockUri + "/${USER_ID}") | ||
) | ||
).run(); | ||
for (int i = 0; i < threads * iterations; i++) { | ||
verify(getRequestedFor(urlEqualTo("/" + i))); | ||
} | ||
} | ||
|
||
@Test | ||
public void shouldUseIncrementalValuesInRequestWhenCounterInRequest() throws Exception { | ||
int startingValue = 1; | ||
int increment = 2; | ||
int threads = 2; | ||
testPlan( | ||
threadGroup(1, 2, | ||
threadGroup(threads, 3, | ||
counter("USER_ID") | ||
.startingValue(startingValue), | ||
.startingValue(startingValue) | ||
.increment(increment) | ||
.maximumValue(startingValue + increment) | ||
.perThread(true), | ||
httpSampler(wiremockUri + "/${USER_ID}") | ||
) | ||
).run(); | ||
verify(getRequestedFor(urlEqualTo("/" + startingValue))); | ||
verify(getRequestedFor(urlEqualTo("/" + (startingValue + 1)))); | ||
verify(threads * 2, getRequestedFor(urlEqualTo("/" + startingValue))); | ||
verify(threads, getRequestedFor(urlEqualTo("/" + (startingValue + increment)))); | ||
} | ||
|
||
@Nested | ||
public class CodeBuilderTest extends MethodCallBuilderTest { | ||
|
||
public DslTestPlan testPlanWithDefaultCounter() { | ||
return testPlan( | ||
counter("MY_COUNTER") | ||
); | ||
} | ||
|
||
public DslTestPlan testPlanWithCustomizedCounter() { | ||
return testPlan( | ||
counter("MY_COUNTER") | ||
.startingValue(1) | ||
.increment(2) | ||
.maximumValue(10) | ||
.perThread(true) | ||
); | ||
} | ||
|
||
} | ||
|
||
} |