Skip to content

Commit a76280d

Browse files
authored
Reporting the correct value to updateIterationIndex (undera#719)
1 parent 402f99b commit a76280d

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

plugins/casutg/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>kg.apc</groupId>
1414
<artifactId>jmeter-plugins-casutg</artifactId>
15-
<version>3.1</version>
15+
<version>3.1.1</version>
1616

1717
<name>Custom Thread Groups</name>
1818
<description>Custom Thread Groups</description>

plugins/casutg/src/main/java/com/blazemeter/jmeter/control/VirtualUserController.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class VirtualUserController extends GenericController implements Iteratin
2323

2424
@Override
2525
public Sampler next() {
26-
updateIterationIndex(owner.getName(), (int) iterationNo);
26+
updateIterationIndex();
2727
try {
2828
if (breakLoop || owner.isLimitReached()) {
2929
setDone(true);
@@ -33,7 +33,7 @@ public Sampler next() {
3333
}
3434
hasArrived = true;
3535
incrementLoopCount();
36-
updateIterationIndex(owner.getName(), (int) iterationNo);
36+
updateIterationIndex();
3737
if (owner instanceof ArrivalsThreadGroup) {
3838
getOwnerAsArrivals().arrivalFact(JMeterContextService.getContext().getThread(), iterationNo);
3939
if (!owner.isRunning()) {
@@ -44,10 +44,16 @@ public Sampler next() {
4444
}
4545
return super.next();
4646
} finally {
47-
updateIterationIndex(owner.getName(), (int) iterationNo);
47+
updateIterationIndex();
4848
}
4949
}
5050

51+
private void updateIterationIndex() {
52+
// This controller increment prior sample and ThreadGroup controllers do the opposite
53+
// We subtract one to JMeter IterationIndex to be aligned with TG (start with 0)
54+
updateIterationIndex(owner.getName(), getIterCount() - 1);
55+
}
56+
5157
private boolean moveToPool(JMeterThread thread) {
5258
if (thread instanceof DynamicThread) {
5359
if (!owner.isLimitReached() && getOwnerAsArrivals().movedToPool((DynamicThread) thread)) {
@@ -114,7 +120,7 @@ public void setOwner(AbstractDynamicThreadGroup owner) {
114120

115121
@Override
116122
protected int getIterCount() {
117-
return (int) (iterationNo + 1);
123+
return (int) (iterationNo);
118124
}
119125

120126
public void startNextLoop() {

0 commit comments

Comments
 (0)