1
votes

I am new to JMeter. I have two scripts one script is web and another is a rest api call which posts metrics to server. Both the scripts are working fine. Now i wanted to implement a scenario.

Web Script should run first once the script is completed i need to capture test metrics like start time, end time, load rate (No.of threads), Pass or fail save to a variable and pass these values to the rest api call which will then run and post the metrics to the server.

Any help is appreciated

2

2 Answers

1
votes
  1. Start time - can be obtained as ${TESTSTART.MS} JMeter pre-defined variable
  2. End time - can be obtained via __time() function, if you call it somewhere in tearDown Thread Group it will report the time when all the main Thread Group(s) are done
  3. Number of threads - it's a kind of weird requirement because its you who define the number of virtual users. Anyway, you can obtain it at any moment of time using i.e. __groovy() function like:

    • ${__groovy(ctx.getThreadGroup().getNumberOfThreads(),)} - returns the number of threads which are active currently
    • ${__groovy(ctx.getThreadGroup().getNumThreads(),)} - returns the number of threads which are defined in the Thread Group
0
votes

As you are planning for the given scenarios you need to do following things.

1) You need to user jp@gc listeners to measure the results in (response time, threads per minute/seconds, hits per second and many more)

You can find the list of listeners here >> https://jmeter-plugins.org/wiki/GraphsGeneratorListener/

2) You need to implement the test plan using regular expression extractor for taking values from the response requests which you can store in the variables and later pass on to the dependent requests. for documentation visit https://jmeter.apache.org/usermanual/regular_expressions.html

For general understanding you can go through the jmeter official documentation https://jmeter.apache.org/usermanual/get-started.html

I hope it will help you