1

I would like to remove the test results during the ramp-up and ramp-down periods. This will help me to get test results during constant workloads. Also, it will remove outliers during the ramping time.

The solution shall be integrated with the JMeter script (JMX) itself. Removing the test results from the test result files (jtl,csv,xml) adds some extra work.

Synthesis Report plugin could help to a certain extent. But it needs manual intervention and has limited reporting capability. Synthesis Report is a mix between Summary Report and Aggregate Report:

Janesh Kodikara
  • 1,670
  • 1
  • 12
  • 23

2 Answers2

2

I have created a Test Fragment with a JSR223 Post Processor and placed it just after the Test Plan component to ensure it is applied to all the Samplers in the Test Plan.

enter image description here

Add the following arguments into the Parameters

${__P(ignore_ramping_time_results,true)}  ${__P(testResultToIgnoreBeforeInMin,5)} ${__P(testResultToIgnoreAfterInMin,65)}
  1. arg[0] - Set true to ignore the result and false to include the result
  2. arg[1] - Set the ramp-up time in minutes. If you set 2, test results during the first two minutes will be ignored
  3. arg[2] - Set the ramp-down start time in minutes. If you set it to 10, all the results after 10 minutes will be ignored.

enter image description here

if(args[0].toBoolean()){
    int testResultToIgnoreBeforeInMin=args[1].toInteger()
    int testResultToIgnoreAfterInMin=args[2].toInteger()
    
    long testResultToIgnoreBeforeInMillis=testResultToIgnoreBeforeInMin*60*1000
    long testResultToIgnoreAfterInMillis=testResultToIgnoreAfterInMin*60*1000
    
    long startTimeInMillis=vars.get("TESTSTART.MS").toLong()
    long currentTimeInMillis = new Date().getTime()
    long currentTestDurationInMillis=currentTimeInMillis-startTimeInMillis
    
    log.info("currentTestDurationInMillis ${currentTestDurationInMillis}")
    
    
    if(currentTestDurationInMillis< testResultToIgnoreBeforeInMillis || currentTestDurationInMillis >testResultToIgnoreAfterInMillis){
        prev.setIgnore()
        log.info("Test result is ignored")
    }
}

Pre-Defined Property

TESTSTART.MS - test start time in milliseconds is used in the script to get the test start time.

Janesh Kodikara
  • 1,670
  • 1
  • 12
  • 23
  • Hey, I pasted your code in a JSR223 Postprocessor underneath a HTTP Request sampler and it's throwing an exception: 2021-10-14 10:59:46,263 ERROR o.a.j.e.JSR223PostProcessor: Problem in JSR223 script, JSR223 PostProcessor javax.script.ScriptException: java.lang.ArrayIndexOutOfBoundsException: 0 Any ideas on what the cause is? Can you please explain what args[0], args[1], args[2] should contain? – JustNatural Oct 14 '21 at 08:06
  • 1
    1. You can place the JSR223 Post Processor just below the Test Plan component. Then it will be applied to all samplers in the test plan. 2. Looks like you have not provided the arguments. Please see the parameters field in the screenshot. You may paste `${__P(ignore_ramping_time_results,true)} ${__P(testResultToIgnoreBeforeInMin,5)} ${__P(testResultToIgnoreAfterInMin,65)}` into the parameters section. – Janesh Kodikara Oct 14 '21 at 11:02
  • Thanks! So if I understand correctly, the script is ignoring any sampler error based on the time in the execution process. If by chance there are some errors before the time specified in testResultToIgnoreBeforeInMillis OR some errors after testResultToIgnoreAfterInMillis they will all be ignored regardless of what errors they are and they will not be be captured in the report. Good. But can there be a modification to ignore based on if the sampler results is a "java.net.SocketException: Socket closed" exception? – JustNatural Oct 14 '21 at 12:21
  • 1
    Nevermind, I found out. The answer is yes, it can be done, with this code: `def responseCode = prev.getResponseCode() if(responseCode.contains("java.net.SocketException")) { log.info("Encountered java.net.SocketException" + responseCode) prev.setIgnore() log.info("Removed exception from sampler log") }` – JustNatural Oct 14 '21 at 20:26
2

Just remove the ramp-up and ramp-down phases from the .jtl results file, the options are in:

  1. Filter Results Tool which provides --start-offset and --end-offset parameters so you can "cut" the ramp-up and ramp-down phases

  2. JMeterPluginsCMD Command Line Tool which you seem to be using already as you're mentioning Synthesis Report:

    JMeterPluginsCMD --generate-csv report.csv --input-jtl /path/to/your/result.jtl --start-offset your-ramp-up-period-in-seconds --end-offset your-ramp-down-period-in-seconds --plugin-type SynthesisReport 
    
Dmitri T
  • 159,985
  • 5
  • 83
  • 133