Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public SampleResult sample(Entry e) {
for (TestElement ctl : controllers) {
reqText.append(ctl.getName()).append("\n");
JMeterThread jmThread = new JMeterThreadParallel(getTestTree(ctl), this, notifier, getGenerateParent());
String name = JMeterContextService.getContext().getThread() + " - " + this.getName() + " - " + ctl.getName();
String name = JMeterContextService.getContext().getThread().toString();
jmThread.setThreadName(name);
jmThread.setThreadGroup(threadGroup);
jmThread.setEngine(JMeterContextService.getContext().getEngine());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,34 @@ public void underLoop() throws Exception {
assertEquals(5, EmulSampler.count.get());
}

@Test
public void underLoopWithIterationNumber() throws Exception {
EmulSampler payload = new NameChangingEmulSampler();
payload.setName("payload");

ParallelSampler sam = new ParallelSampler();
sam.threadStarted();
sam.setName("Parallel Sampler");
sam.addTestElement(payload);

LoopController ctl = getLoopController(5);
ctl.addTestElement(sam);

JMeterThread thr = new JMeterThread(new HashTree(ctl), sam, sam.notifier);
thr.setThreadName("root");
thr.setThreadGroup(new DummyThreadGroup());
JMeterContextService.getContext().setThread(thr);

addToContext(sam, thr);
addToContext(payload, thr);

sam.setRunningVersion(true);
ctl.setRunningVersion(true);
payload.setRunningVersion(true);
thr.run();
assertEquals(5, EmulSampler.count.get());
}

private LoopController getLoopController(int loops) {
LoopController ctl = new LoopControllerTracked();
ctl.setName("Top Loop");
Expand All @@ -149,7 +177,7 @@ public void addToContext(TestElement te, JMeterThread parentThread) throws NoSuc

public static class EmulSampler extends DummySampler {
private volatile transient static int instances = 0;
private volatile transient static AtomicInteger count = new AtomicInteger();
protected volatile transient static AtomicInteger count = new AtomicInteger();

public EmulSampler() {
instances++;
Expand All @@ -164,6 +192,17 @@ public SampleResult sample(Entry e) {
}
}

public static class NameChangingEmulSampler extends EmulSampler {

public NameChangingEmulSampler() {
super();
}

@Override
public String getName() {
return super.getName() + count.get();
}
}

@Test
public void testThreadSafeCookieManager() throws Exception {
Expand Down