ASF Bugzilla – Attachment 19860 Details for
Bug 41913
Let TransactionController create samples that contains the samples of the transaction
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Minimal patch to let transaction sample fail if subsamples fails
patch_for_41913_minimal.patch (text/plain), 7.44 KB, created by
Alf Hogemark
on 2007-04-01 07:10:07 UTC
(
hide
)
Description:
Minimal patch to let transaction sample fail if subsamples fails
Filename:
MIME Type:
Creator:
Alf Hogemark
Created:
2007-04-01 07:10:07 UTC
Size:
7.44 KB
patch
obsolete
>Index: C:/Documents and Settings/alf/workspace/JMeter 2.2 Official/src/components/org/apache/jmeter/control/TransactionController.java >=================================================================== >--- C:/Documents and Settings/alf/workspace/JMeter 2.2 Official/src/components/org/apache/jmeter/control/TransactionController.java (revision 524590) >+++ C:/Documents and Settings/alf/workspace/JMeter 2.2 Official/src/components/org/apache/jmeter/control/TransactionController.java (working copy) >@@ -21,8 +21,10 @@ > import java.io.Serializable; > > import org.apache.jmeter.samplers.SampleEvent; >+import org.apache.jmeter.samplers.SampleListener; > import org.apache.jmeter.samplers.SampleResult; > import org.apache.jmeter.samplers.Sampler; >+import org.apache.jmeter.testelement.property.BooleanProperty; > import org.apache.jmeter.threads.JMeterContext; > import org.apache.jmeter.threads.JMeterThread; > import org.apache.jmeter.threads.JMeterVariables; >@@ -35,15 +37,25 @@ > * Transaction Controller to measure transaction times > * > */ >-public class TransactionController extends GenericController implements Controller, Serializable { >+public class TransactionController extends GenericController implements SampleListener, Controller, Serializable { > protected static final Logger log = LoggingManager.getLoggerForClass(); > >+ private final static String REPORT_SAMPLES_NONE = "TransactionController.report_samples_none"; // $NON-NLS-1$ >+ >+ private final static String REPORT_SAMPLES_FAILING = "TransactionController.report_samples_failing"; // $NON-NLS-1$ >+ >+ private final static String REPORT_SAMPLES_ALL = "TransactionController.report_samples_all"; // $NON-NLS-1$ >+ > transient private String threadName; > > transient private ListenerNotifier lnf; > > transient private SampleResult res; >+ >+ transient private int calls; > >+ transient private int noFailingSamples; >+ > /** > * Creates a Transaction Controller > */ >@@ -62,26 +74,49 @@ > String n = this.getName(); > log.debug(threadName + " " + n + " " + s); > } >+ >+ public void setReportSamplesNone(boolean value) { >+ setProperty(new BooleanProperty(REPORT_SAMPLES_NONE, value)); >+ } > >- private int calls; >+ public boolean getReportSamplesNone() { >+ return getPropertyAsBoolean(REPORT_SAMPLES_NONE, true); >+ } > >+ public void setReportSamplesFailing(boolean value) { >+ setProperty(new BooleanProperty(REPORT_SAMPLES_FAILING, value)); >+ } >+ >+ public boolean getReportSamplesFailing() { >+ return getPropertyAsBoolean(REPORT_SAMPLES_FAILING, false); >+ } >+ >+ public void setReportSamplesAll(boolean value) { >+ setProperty(new BooleanProperty(REPORT_SAMPLES_ALL, value)); >+ } >+ >+ public boolean getReportSamplesAll() { >+ return getPropertyAsBoolean(REPORT_SAMPLES_ALL, false); >+ } >+ > /** > * @see org.apache.jmeter.control.Controller#next() > */ > public Sampler next() { >- Sampler returnValue = null; > if (isFirst()) // must be the start of the subtree > { > log_debug("+++++++++++++++++++++++++++++"); > calls = 0; >+ noFailingSamples = 0; > res = new SampleResult(); >+ res.setSampleLabel(getName()); >+ // Assume success >+ res.setSuccessful(true); > res.sampleStart(); > } > >- calls++; >- >- returnValue = super.next(); >- >+ Sampler returnValue = super.next(); >+ > if (returnValue == null) // Must be the end of the controller > { > log_debug("-----------------------------" + calls); >@@ -89,11 +124,10 @@ > log_debug("already called"); > } else { > res.sampleEnd(); >- res.setSuccessful(true); >- res.setSampleLabel(getName()); >- res.setResponseCodeOK(); >- res.setResponseMessage("Called: " + calls); >- res.setThreadName(threadName); >+ res.setResponseMessage("Number of samples in transaction : " + calls + ", number of failing samples : " + noFailingSamples); >+ if(res.isSuccessful()) { >+ res.setResponseCodeOK(); >+ } > > // TODO could these be done earlier (or just once?) > JMeterContext threadContext = getThreadContext(); >@@ -103,12 +137,42 @@ > if (pack == null) { > log.warn("Could not fetch SamplePackage"); > } else { >- lnf.notifyListeners(new SampleEvent(res, getName()), pack.getSampleListeners()); >+ SampleEvent event = new SampleEvent(res, getName()); >+ // We must set res to null now, before sending the event for the transaction, >+ // so that we can ignore that event in our sampleOccured method >+ res = null; >+ lnf.notifyListeners(event, pack.getSampleListeners()); > } >- res = null; > } > } >+ else { >+ // We have sampled one of our children >+ calls++; >+ } > > return returnValue; > } >+ >+ public void sampleOccurred(SampleEvent se) { >+ // Check if we have are still sampling our children >+ if(res != null) { >+ SampleResult sampleResult = se.getResult(); >+ res.setThreadName(sampleResult.getThreadName()); >+ res.setBytes(res.getBytes() + sampleResult.getBytes()); >+ if(!sampleResult.isSuccessful()) { >+ res.setSuccessful(false); >+ noFailingSamples++; >+ } >+ // Check if we should include the sample in the transaction sample >+ if(getReportSamplesAll() || (getReportSamplesFailing() && !sampleResult.isSuccessful())) { >+ res.addSubResult(sampleResult); >+ } >+ } >+ } >+ >+ public void sampleStarted(SampleEvent e) { >+ } >+ >+ public void sampleStopped(SampleEvent e) { >+ } > } >Index: C:/Documents and Settings/alf/workspace/JMeter 2.2 Official/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java >=================================================================== >--- C:/Documents and Settings/alf/workspace/JMeter 2.2 Official/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java (revision 524590) >+++ C:/Documents and Settings/alf/workspace/JMeter 2.2 Official/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java (working copy) >@@ -200,7 +200,7 @@ > addSubResults(currNode, res); > // Add any assertion that failed as children of the sample node > AssertionResult assertionResults[] = res.getAssertionResults(); >- int assertionIndex = 0; >+ int assertionIndex = currNode.getChildCount(); > for (int j = 0; j < assertionResults.length; j++) { > AssertionResult item = assertionResults[j]; > >@@ -231,6 +231,17 @@ > > treeModel.insertNodeInto(leafNode, currNode, leafIndex++); > addSubResults(leafNode, child); >+ // Add any assertion that failed as children of the sample node >+ AssertionResult assertionResults[] = child.getAssertionResults(); >+ int assertionIndex = leafNode.getChildCount(); >+ for (int j = 0; j < assertionResults.length; j++) { >+ AssertionResult item = assertionResults[j]; >+ >+ if (item.isFailure() || item.isError()) { >+ DefaultMutableTreeNode assertionNode = new DefaultMutableTreeNode(item); >+ treeModel.insertNodeInto(assertionNode, leafNode, assertionIndex++); >+ } >+ } > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 41913
:
19763
|
19777
|
19860
|
19861
|
20157
|
20158
|
20159
|
20237