mirror of https://github.com/apache/jmeter.git
Run tearDown Thread Groups after shutdown of main threads
Bugzilla Id: 53671
git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1378929 13f79535-47bb-0310-9956-ffa450edef68
Former-commit-id: aee904c46e
This commit is contained in:
parent
0cd170c1d2
commit
0a7d702eb2
|
|
@ -55,6 +55,8 @@ public class TestPlanGui extends AbstractJMeterGuiComponent {
|
|||
|
||||
private final JCheckBox serializedMode;
|
||||
|
||||
private final JCheckBox tearDownOnShutdown;
|
||||
|
||||
/** A panel allowing the user to define variables. */
|
||||
private final ArgumentsPanel argsPanel;
|
||||
|
||||
|
|
@ -68,6 +70,7 @@ public class TestPlanGui extends AbstractJMeterGuiComponent {
|
|||
argsPanel = new ArgumentsPanel(JMeterUtils.getResString("user_defined_variables")); // $NON-NLS-1$
|
||||
serializedMode = new JCheckBox(JMeterUtils.getResString("testplan.serialized")); // $NON-NLS-1$
|
||||
functionalMode = new JCheckBox(JMeterUtils.getResString("functional_mode")); // $NON-NLS-1$
|
||||
tearDownOnShutdown = new JCheckBox(JMeterUtils.getResString("teardown_on_shutdown")); // $NON-NLS-1$
|
||||
init();
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +116,7 @@ public class TestPlanGui extends AbstractJMeterGuiComponent {
|
|||
if (plan instanceof TestPlan) {
|
||||
TestPlan tp = (TestPlan) plan;
|
||||
tp.setFunctionalMode(functionalMode.isSelected());
|
||||
tp.setTearDownOnShutdown(tearDownOnShutdown.isSelected());
|
||||
tp.setSerialized(serializedMode.isSelected());
|
||||
tp.setUserDefinedVariables((Arguments) argsPanel.createTestElement());
|
||||
tp.setTestPlanClasspathArray(browseJar.getFiles());
|
||||
|
|
@ -151,6 +155,7 @@ public class TestPlanGui extends AbstractJMeterGuiComponent {
|
|||
TestPlan tp = (TestPlan) el;
|
||||
functionalMode.setSelected(tp.isFunctionalMode());
|
||||
serializedMode.setSelected(tp.isSerialized());
|
||||
tearDownOnShutdown.setSelected(tp.isTearDownOnShutdown());
|
||||
final JMeterProperty udv = tp.getUserDefinedVariablesAsProperty();
|
||||
if (udv != null) {
|
||||
argsPanel.configure((Arguments) udv.getObjectValue());
|
||||
|
|
@ -172,6 +177,7 @@ public class TestPlanGui extends AbstractJMeterGuiComponent {
|
|||
|
||||
VerticalPanel southPanel = new VerticalPanel();
|
||||
southPanel.add(serializedMode);
|
||||
southPanel.add(tearDownOnShutdown);
|
||||
southPanel.add(functionalMode);
|
||||
JTextArea explain = new JTextArea(JMeterUtils.getResString("functional_mode_explanation")); // $NON-NLS-1$
|
||||
explain.setEditable(false);
|
||||
|
|
@ -187,6 +193,7 @@ public class TestPlanGui extends AbstractJMeterGuiComponent {
|
|||
super.clearGui();
|
||||
functionalMode.setSelected(false);
|
||||
serializedMode.setSelected(false);
|
||||
tearDownOnShutdown.setSelected(false);
|
||||
argsPanel.clear();
|
||||
browseJar.clearFiles();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,12 +91,18 @@ public class StandardJMeterEngine implements JMeterEngine, Runnable {
|
|||
/** Flag to show whether test is running. Set to false to stop creating more threads. */
|
||||
private volatile boolean running = false;
|
||||
|
||||
/** Flag to show whether test was shutdown gracefully. */
|
||||
private volatile boolean shutdown = false;
|
||||
|
||||
/** Flag to show whether engine is active. Set to false at end of test. */
|
||||
private volatile boolean active = false;
|
||||
|
||||
/** Thread Groups run sequentially */
|
||||
private volatile boolean serialized = false;
|
||||
|
||||
/** tearDown Thread Groups run after shutdown of main threads */
|
||||
private volatile boolean tearDownOnShutdown = false;
|
||||
|
||||
private HashTree test;
|
||||
|
||||
private final String host;
|
||||
|
|
@ -160,9 +166,9 @@ public class StandardJMeterEngine implements JMeterEngine, Runnable {
|
|||
if (plan.length == 0) {
|
||||
throw new RuntimeException("Could not find the TestPlan class!");
|
||||
}
|
||||
if (((TestPlan) plan[0]).isSerialized()) {
|
||||
serialized = true;
|
||||
}
|
||||
TestPlan tp = (TestPlan) plan[0];
|
||||
serialized = tp.isSerialized();
|
||||
tearDownOnShutdown = tp.isTearDownOnShutdown();
|
||||
active = true;
|
||||
test = testTree;
|
||||
}
|
||||
|
|
@ -245,8 +251,9 @@ public class StandardJMeterEngine implements JMeterEngine, Runnable {
|
|||
stopTest(true);
|
||||
}
|
||||
|
||||
public synchronized void stopTest(boolean b) {
|
||||
Thread stopThread = new Thread(new StopTest(b));
|
||||
public synchronized void stopTest(boolean now) {
|
||||
shutdown = !now;
|
||||
Thread stopThread = new Thread(new StopTest(now));
|
||||
stopThread.start();
|
||||
}
|
||||
|
||||
|
|
@ -371,6 +378,7 @@ public class StandardJMeterEngine implements JMeterEngine, Runnable {
|
|||
System.gc();
|
||||
|
||||
JMeterContextService.getContext().setSamplingStarted(true);
|
||||
boolean mainGroups = running; // still running at this point, i.e. setUp was not cancelled
|
||||
while (running && iter.hasNext()) {// for each thread group
|
||||
AbstractThreadGroup group = iter.next();
|
||||
//ignore Setup and Post here. We could have filtered the searcher. but then
|
||||
|
|
@ -406,6 +414,9 @@ public class StandardJMeterEngine implements JMeterEngine, Runnable {
|
|||
groupCount = 0;
|
||||
JMeterContextService.clearTotalThreads();
|
||||
log.info("Starting tearDown thread groups");
|
||||
if (mainGroups && !running) { // i.e. shutdown/stopped during main thread groups
|
||||
running = shutdown & tearDownOnShutdown; // re-enable for tearDown if necessary
|
||||
}
|
||||
while (running && postIter.hasNext()) {//for each setup thread group
|
||||
AbstractThreadGroup group = postIter.next();
|
||||
groupCount++;
|
||||
|
|
@ -502,7 +513,7 @@ public class StandardJMeterEngine implements JMeterEngine, Runnable {
|
|||
}
|
||||
|
||||
/**
|
||||
* For each thread group, invoke:
|
||||
* For each current thread group, invoke:
|
||||
* <ul>
|
||||
* <li>{@link AbstractThreadGroup#stop()} - set stop flag</li>
|
||||
* </ul>
|
||||
|
|
|
|||
|
|
@ -1006,6 +1006,7 @@ tcp_port=Port Number\:
|
|||
tcp_request_data=Text to send
|
||||
tcp_sample_title=TCP Sampler
|
||||
tcp_timeout=Timeout (milliseconds)\:
|
||||
teardown_on_shutdown=Run tearDown Thread Groups after shutdown of main threads
|
||||
template_field=Template\:
|
||||
test=Test
|
||||
test_action_action=Action
|
||||
|
|
|
|||
|
|
@ -1000,6 +1000,7 @@ tcp_port=Num\u00E9ro de port \:
|
|||
tcp_request_data=Texte \u00E0 envoyer \:
|
||||
tcp_sample_title=Requ\u00EAte TCP
|
||||
tcp_timeout=Expiration (millisecondes) \:
|
||||
teardown_on_shutdown=Run tearDown Thread Groups after shutdown of main threads
|
||||
template_field=Canevas \:
|
||||
test=Test
|
||||
test_action_action=Action \:
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ public class TestPlan extends AbstractTestElement implements Serializable, TestS
|
|||
private static final String SERIALIZE_THREADGROUPS = "TestPlan.serialize_threadgroups"; //$NON-NLS-1$
|
||||
|
||||
private static final String CLASSPATHS = "TestPlan.user_define_classpath"; //$NON-NLS-1$
|
||||
|
||||
private static final String TEARDOWN_ON_SHUTDOWN = "TestPlan.tearDown_on_shutdown"; //$NON-NLS-1$
|
||||
|
||||
//- JMX field names
|
||||
|
||||
private static final String CLASSPATH_SEPARATOR = ","; //$NON-NLS-1$
|
||||
|
|
@ -144,6 +147,14 @@ public class TestPlan extends AbstractTestElement implements Serializable, TestS
|
|||
setProperty(new BooleanProperty(SERIALIZE_THREADGROUPS, serializeTGs));
|
||||
}
|
||||
|
||||
public void setTearDownOnShutdown(boolean tearDown) {
|
||||
setProperty(TEARDOWN_ON_SHUTDOWN, tearDown, false);
|
||||
}
|
||||
|
||||
public boolean isTearDownOnShutdown() {
|
||||
return getPropertyAsBoolean(TEARDOWN_ON_SHUTDOWN, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the classpath for the test plan
|
||||
* @param text
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ The original behaviour can be restored by setting the property <code>TestCompile
|
|||
|
||||
<h3>Controllers</h3>
|
||||
<ul>
|
||||
<li><bugzilla>53671</bugzilla> - tearDown thread group to run even if shutdown test happens</li>
|
||||
</ul>
|
||||
|
||||
<h3>Listeners</h3>
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 9.9 KiB |
|
|
@ -5076,6 +5076,10 @@ If more data is required for a particular sampler only, then add a Listener to i
|
|||
[The option does not affect CSV result files, which cannot currently store such information.]
|
||||
</p>
|
||||
<p>Also, an option exists here to instruct JMeter to run the <complink name="Thread Group"/> serially rather than in parallel.</p>
|
||||
<p>Run tearDown Thread Groups after shutdown of main threads:
|
||||
if selected, the tearDown groups (if any) will be run after graceful shutdown of the main threads.
|
||||
The tearDown threads won't be run if the test is forcibly stopped.
|
||||
</p>
|
||||
<p>
|
||||
Test plan now provides an easy way to add classpath setting to a specific test plan.
|
||||
The feature is additive, meaning that you can add jar files or directories, but removing an entry requires restarting JMeter.
|
||||
|
|
|
|||
Loading…
Reference in New Issue