Bug 61709 - SampleResult : Add a method setIgnore() to make JMeter ignore the SampleResult and not send it to listeners
Summary: SampleResult : Add a method setIgnore() to make JMeter ignore the SampleResul...
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 3.3
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-01 21:53 UTC by Philippe Mouawad
Modified: 2017-11-23 15:43 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Mouawad 2017-11-01 21:53:15 UTC
We often need to do some processing with JSR223 elements without wanting the generation of a SampleResult.

Sampler which return null SampleResult will not impact results CSV/XML, but JSR223 Sampler cannot do that currently as the SampleResult is created before calling custom code.

So what would be the best way to do that:

- Add a method setNoResult(boolean) on SampleResult ? calling this from script code would make JSR223Sampler return null. This seems to be the most performing way
- Throw some custom exception ? But throwing an exception has a cost and it is done for exceptional case, it's not the case here
- Other ideas ?
Comment 1 Philippe Mouawad 2017-11-02 22:38:58 UTC
Was:

JSR223 Sampler : There should be a way to make it not impact results
Comment 2 Philippe Mouawad 2017-11-02 22:44:45 UTC
Author: pmouawad
Date: Thu Nov  2 22:44:12 2017
New Revision: 1814121

URL: http://svn.apache.org/viewvc?rev=1814121&view=rev
Log:
Bug 61709 - SampleResult : Add a method setIgnore() to make JMeter ignore the SampleResult and not send it to listeners
Bugzilla Id: 61709

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
    jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/component_reference.xml
Comment 3 mchassagneux 2017-11-23 15:34:42 UTC
@Philippe Mouawad

Hello, 

I find this new method really usefull for me !!! 
But I want to use it some time in PostProcessor or Assertion script but it's not possible. 

Are you Ok if I add a new test in JMeterThread to check this property just before send result to listener ?

runPostProcessors(pack.getPostProcessors());
checkAssertions(pack.getAssertions(), result, threadContext);
if ( !result.isIgnore() ) {
   // Do not send subsamples to listeners which receive the transaction sample
   List<SampleListener> sampleListeners = getSampleListeners(pack, transactionPack, transactionSampler);
   notifyListeners(sampleListeners, result);
}
Comment 4 Philippe Mouawad 2017-11-23 15:43:37 UTC
Hi Maxime,
Happy you find it useful :-) 

Can you create another bugzilla and discuss this on mailing list before ?

I'd like other brains to ensure I am not missing something.

Thanks