Reputation: 154
My scenario is to pass different time (15 mins gap) till the script runs for each sampler run. I am using preprocessor and postprocessor in the same step and now i want to use the the variable changed in postprocessor step, in side post processor step. Below is the screenshot of code and script.
Upvotes: 1
Views: 1789
Reputation: 11
Like mentioned above vars.put("","") wont work from post to preprocessor. There is way to sending the values from from post to pre processor by using Property in Jmeter using BeanShell
Inside the PostProcess
props.put("property_name", extractedValue);
and in the preprocessor
String value = props.getProperty("pageNumber");
if (value != null) {
vars.put("my_variable", String.valueOf(retrievedValue));
}
Upvotes: 0
Reputation: 168157
There is __timeShift() function which can generate the date in the given format with the given offset, for example you can add 15 minutes to current time as simple as:
${__timeShift(yyyy-MM-dd'T'HH:mm:ss.SSS'Z',,PT15M,,)}
There is no need to use these SimpleDateFormat/Calendar in Groovy, there is TimeCategory class which makes dates manipulation very easy. Moreover, Groovy's Date class provides format() function therefore you can add 15 minutes to the current date like:
use(groovy.time.TimeCategory) {
15.minutes.from.now.format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
}
Demo:
Upvotes: 1
Reputation: 154
Just found out the solution. I don't need to add preprocessor here. instead just using jsr223 sampler will work fine with onceonly controller. preprocessor was resetting the starttime and endtime value here.
Upvotes: 0