0

In Jmeter, I am using Concurrency Thread Group with ${__tstFeedback(ThroughputShapingTimer,1,10,10)} in combination with the Throughput Shaping Timer to dynamically change the target throughput throughout the test duration.

I want to have a JSR223 test element (Assertion or PostProcessor, does it matter?) in which to write custom logic to not log some specific error but only if it occurs near the end of the test script and I don't want to hardcode the time value.

For example if I get a java.net.SocketException in the last 2 minutes of the scheduled run time, I want to not log it, but I do want to log it in the rest of the time. For this, I suppose that I need some way to grab the date when the test is supposed to end since the beginning of the test, evaluate it and subtract 2 minutes from it and then compare the current time with that time and then if the current time is higher, then start doing some logic to exclude the result from the logging.

Update: In the "Normal" or "Default" Thread Group I noticed that I can do this to get the initial duration:

String groupDuration = ctx.getThreadGroup().getDuration();
log.info(groupDuration)

But for the Concurrency Thread Group it does not work the same.

I would appreciate any information to help me achieve this goal.

JustNatural
  • 375
  • 7
  • 19
  • 1
    In your scheduled feedback function the **max allowed threads** are set to 10. It would be better to set the **max allowed threads** to a higher value. (e.g 1000). JMeter will create the threads only when they are required to maintain the desired throughput. `${__tstFeedback(tst-name,1,1000,10)}`. [Documentation](https://jmeter-plugins.org/wiki/ThroughputShapingTimer/#Schedule-Feedback-Function) – Janesh Kodikara Oct 16 '21 at 05:12

3 Answers3

1

For dynamic thread groups and derivatives you can use the following function:

ctx.getThreadGroup().getHold()

If you need to determine whether it is in minutes or seconds you can use

ctx.getThreadGroup().getUnitStr()

Example:

enter image description here

More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
1

If your Concurrency Thread Group is configured with a Throughput Shaping Timer and Schedule Feedback Function the scheduled test duration is available through a property exposed by the Throughput Shaping Timer.

props.get('elementName_totalDuration')

The element will export the following propertyy that you can access through __P function or using in JSR223 Test Elements props.get("property name")

elementName_totalDuration - Total duration as sum of the "Duration,sec" column

elementName will be the name of your Throughput Shaping Timer

NOTE You should set Hold Target Rate Time to a value equal or greater than the total Duration specified in the Throughput Shaping Timer schedule. Hence set this value to a very high value to avoid test completing before scheduled duration in Throughput Shaping Timer. e.g Set Target Hold rate t0 1440 minutes.

Using concurrency Thread Group with Throughput Shaping Timer and the Feedback Function

When this thread group is used with Throughput Shaping Timer, you may replace Target Concurrency value with a call to the tstFeedback function to dynamically maintain thread count required to achieve target RPS. When using this approach, leave Concurrency Thread Group Ramp Up Time and Ramp-Up Steps Count fields blank, but be sure to set Hold Target Rate Time to a value equal or greater than the total Duration specified in the Throughput Shaping Timer schedule.

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

You can filter results after test with Filter Results Tool

If you want to remove the ramp-up phase, you could use offset filters

Using --end-offset 120 parameter (seconds)

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
  • If I understand correctly, this tool requires the existence of a .jtl input file for processing and afterwards it will spit out an edited version of the input file based on the parameters given in the command line. And then this new file can be used to generate the jmeter report. Can you please confirm that my understanding is correct? – JustNatural Oct 14 '21 at 18:53
  • 1
    @JustNatural basically yes, input and output can be csv – Ori Marko Oct 14 '21 at 19:19
  • So then this requires an extra manual step. Can the command to generate the updated log file be somehow called at the end of the test script for automating the initial file's transformation? If yes, how? – JustNatural Oct 14 '21 at 19:53
  • 1
    @JustNatural yes you can call both in batch file/script – Ori Marko Oct 14 '21 at 20:08
  • I'm a bit confused. Can you please tell me, from jmeter, what commands should I call to achieve this outcome and from where? can you give an example? – JustNatural Oct 14 '21 at 20:51
  • 1
    @JustNatural it's a different question you can google or ask new question – Ori Marko Oct 15 '21 at 06:07