sebb 2003/10/05 15:21:24
Modified: src/core/org/apache/jmeter/threads/gui ThreadGroupGui.java
src/core/org/apache/jmeter/engine StandardJMeterEngine.java
src/core/org/apache/jmeter/threads ThreadGroup.java
JMeterThread.java
Log:
Added sampler error handling to Thread group GUI: Continue, Stop Thread or Stop Test
Revision Changes Path
1.20 +66 -5
jakarta-jmeter/src/core/org/apache/jmeter/threads/gui/ThreadGroupGui.java
Index: ThreadGroupGui.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/threads/gui/ThreadGroupGui.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ThreadGroupGui.java 28 Jun 2003 19:35:40 -0000 1.19
+++ ThreadGroupGui.java 5 Oct 2003 22:21:23 -0000 1.20
@@ -61,10 +61,13 @@
import java.util.Date;
import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
+import javax.swing.JRadioButton;
import javax.swing.JTextField;
import org.apache.jmeter.control.LoopController;
@@ -78,6 +81,7 @@
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.property.BooleanProperty;
import org.apache.jmeter.testelement.property.LongProperty;
+import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jmeter.threads.ThreadGroup;
import org.apache.jmeter.util.JMeterUtils;
@@ -106,7 +110,12 @@
private JDateField start;
private JDateField end;
private JCheckBox scheduler;
-
+
+ // Sampler error action buttons
+ private JRadioButton continueBox;
+ private JRadioButton stopThrdBox;
+ private JRadioButton stopTestBox;
+
public ThreadGroupGui()
{
super();
@@ -150,6 +159,23 @@
((Date) end.getDate()).getTime()));
tg.setProperty(
new BooleanProperty(ThreadGroup.SCHEDULER, scheduler.isSelected()));
+ tg.setProperty(
+ new StringProperty(
+ ThreadGroup.ON_SAMPLE_ERROR,onSampleError()));
+ }
+
+ private void setSampleErrorBoxes(ThreadGroup te){
+ stopTestBox.setSelected(te.getOnErrorStopTest());
+ stopThrdBox.setSelected(te.getOnErrorStopThread());
+ continueBox.setSelected(!te.getOnErrorStopThread() &&
!te.getOnErrorStopTest());
+ }
+
+ private String onSampleError(){
+ if (stopTestBox.isSelected()) return ThreadGroup.ON_SAMPLE_ERROR_STOPTEST;
+ if (stopThrdBox.isSelected()) return
ThreadGroup.ON_SAMPLE_ERROR_STOPTHREAD;
+
+ // Defaults to continue
+ return ThreadGroup.ON_SAMPLE_ERROR_CONTINUE;
}
public void configure(TestElement tg)
@@ -174,6 +200,8 @@
start.setDate(new Date(tg.getPropertyAsLong(ThreadGroup.START_TIME)));
end.setDate(new Date(tg.getPropertyAsLong(ThreadGroup.END_TIME)));
+
+ setSampleErrorBoxes((ThreadGroup) tg);
}
public void itemStateChanged(ItemEvent ie)
@@ -258,13 +286,46 @@
return JMeterUtils.getResString("threadgroup");
}
+ private JPanel createOnErrorPanel()
+ {
+ JPanel panel = new JPanel();
+ panel.setBorder(
+ BorderFactory.createTitledBorder(
+ JMeterUtils.getResString("sampler_on_error_action")));
+
+ ButtonGroup group = new ButtonGroup();
+
+ continueBox =
+ new JRadioButton(JMeterUtils.getResString("sampler_on_error_continue"));
+ group.add(continueBox);
+ continueBox.setSelected(true);
+ panel.add(continueBox);
+
+ stopThrdBox =
+ new
JRadioButton(JMeterUtils.getResString("sampler_on_error_stop_thread"));
+ group.add(stopThrdBox);
+ panel.add(stopThrdBox);
+
+ stopTestBox =
+ new
JRadioButton(JMeterUtils.getResString("sampler_on_error_stop_test"));
+ group.add(stopTestBox);
+ panel.add(stopTestBox);
+
+ return panel;
+ }
+
+
+
private void init()
{
setLayout(new BorderLayout(0, 5));
setBorder(makeBorder());
-
- add(makeTitlePanel(), BorderLayout.NORTH);
-
+
+ Box box = Box.createVerticalBox();
+ box.add(makeTitlePanel());
+ box.add(createOnErrorPanel());
+ add(box,BorderLayout.NORTH);
+
//JPanel mainPanel = new JPanel(new BorderLayout());
// THREAD PROPERTIES
1.33 +5 -1
jakarta-jmeter/src/core/org/apache/jmeter/engine/StandardJMeterEngine.java
Index: StandardJMeterEngine.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/engine/StandardJMeterEngine.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- StandardJMeterEngine.java 5 Oct 2003 00:10:33 -0000 1.32
+++ StandardJMeterEngine.java 5 Oct 2003 22:21:23 -0000 1.33
@@ -317,7 +317,11 @@
scheduleThread(threads[i], group);
+ // Set up variables for stop handling
threads[i].setEngine(this);
+
threads[i].setOnErrorStopTest(group.getOnErrorStopTest());
+
threads[i].setOnErrorStopThread(group.getOnErrorStopThread());
+
Thread newThread = new Thread(threads[i]);
newThread.setName(threads[i].getThreadName());
allThreads.put(threads[i], newThread);
1.17 +28 -2
jakarta-jmeter/src/core/org/apache/jmeter/threads/ThreadGroup.java
Index: ThreadGroup.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/threads/ThreadGroup.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ThreadGroup.java 5 Oct 2003 01:05:31 -0000 1.16
+++ ThreadGroup.java 5 Oct 2003 22:21:23 -0000 1.17
@@ -98,6 +98,12 @@
public final static String END_TIME= "ThreadGroup.end_time";
+ /* Action to be taken when a Sampler error occurs*/
+ public final static String ON_SAMPLE_ERROR= "ThreadGroup.on_sample_error";
//int
+ public final static String ON_SAMPLE_ERROR_CONTINUE = "continue";
+ public final static String ON_SAMPLE_ERROR_STOPTHREAD = "stopthread";
+ public final static String ON_SAMPLE_ERROR_STOPTEST = "stoptest";
+
private final int DEFAULT_NUM_THREADS = 1;
private final int DEFAULT_RAMP_UP = 0;
private SampleQueue queue = null;
@@ -425,6 +431,26 @@
public void initialize()
{
getSamplerController().initialize();
+ }
+
+ /**
+ * Check if a sampler error should cause thread to stop.
+ *
+ * @return true if should stop
+ */
+ public boolean getOnErrorStopThread()
+ {
+ return getPropertyAsString(ThreadGroup.ON_SAMPLE_ERROR) ==
ON_SAMPLE_ERROR_STOPTHREAD;
+ }
+
+ /**
+ * Check if a sampler error should cause test to stop.
+ *
+ * @return true if should stop
+ */
+ public boolean getOnErrorStopTest()
+ {
+ return getPropertyAsString(ThreadGroup.ON_SAMPLE_ERROR) ==
ON_SAMPLE_ERROR_STOPTEST;
}
}
1.36 +34 -7
jakarta-jmeter/src/core/org/apache/jmeter/threads/JMeterThread.java
Index: JMeterThread.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/threads/JMeterThread.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- JMeterThread.java 5 Oct 2003 00:10:33 -0000 1.35
+++ JMeterThread.java 5 Oct 2003 22:21:23 -0000 1.36
@@ -91,7 +91,7 @@
static Map samplers = new HashMap();
int initialDelay = 0;
Controller controller;
- private boolean running;//TODO should this be volatile?
+ private boolean running;
HashTree testTree;
TestCompiler compiler;
JMeterThreadMonitor monitor;
@@ -105,7 +105,12 @@
long endTime = 0;
private boolean scheduler = false;
//based on this scheduler is enabled or disabled
- private StandardJMeterEngine engine = null;
+
+
+ private StandardJMeterEngine engine = null; // For access to stop methods.
+ private boolean onErrorStopTest;
+ private boolean onErrorStopThread;
+
public JMeterThread()
{
@@ -282,12 +287,12 @@
checkAssertions(pack.getAssertions(), result);
notifyListeners(pack.getSampleListeners(), result);
compiler.done(pack);
- if (result.isStopThread()){
+ if (result.isStopThread() || (!result.isSuccessful() &&
onErrorStopThread)){
stopThread();
}
- if (result.isStopTest()){
- stopTest();
- }
+ if (result.isStopTest() || (!result.isSuccessful() &&
onErrorStopTest)){
+ stopTest();
+ }
if (scheduler)
{
//checks the scheduler to stop the iteration
@@ -467,11 +472,33 @@
}
}
/**
+ * Save the engine instance for access to the stop methods
+ *
* @param engine
*/
public void setEngine(StandardJMeterEngine engine)
{
this.engine = engine;
+ }
+
+ /**
+ * Should Test stop on sampler error?
+ *
+ * @param boolean
+ */
+ public void setOnErrorStopTest(boolean b)
+ {
+ onErrorStopTest = b;
+ }
+
+ /**
+ * Should Thread stop on Sampler error?
+ *
+ * @param boolean
+ */
+ public void setOnErrorStopThread(boolean b)
+ {
+ onErrorStopThread = b;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]