How to print iteration number in Pepper-Box plain text config? - jmeter

I want to print iteration number in pepper-box plain text config and i tried Counter config element of jmeter but during execution it is not replacing iteration number. Like if i am using ${counter} so in execution it is printing ${counter}.
I am using counter config element because i need iteration number in some format like 00001,00002,00003 etc.
I also tried to use function like Counter(TRUE,) but it is just replacing first iteration number and not increasing it. Only first iteration number printing in all next iteration.

In Pepper-Box sampler you can only use a limited subset of built-in template functions having different syntax.
You can try doing something like:
{{org.apache.jmeter.threads.JMeterContextService.getContext().getVariables().get("counter")}}
or if you want to share your script with others you can consider implementing a custom function
Check out Apache Kafka - How to Load Test with JMeter article for more information on building a Kakfa test plan using JMeter

Related

Jmeter timestamp in jssrpreprocessor is same for multiple requests

We have script, jssr preprocess which will copy the file from one bucket and paste it to another bucket in Amazon s3and http request which will take the file and do further processing.
Before copying file we do renaming filename with timestamp(function help builder). Everytime we do performance testing it has to pick unique file name.
But when I run send requests for 5 minutes, timestamp remain same, it's taking first timestamp through there is some second difference between each request. Is there any way each request to generate unique timestamp within jssr preprocessor
It's not very possible to come up with the solution without seeing your "script".
Blind shot: if you're using __time() function inside the JSR223 PreProcessor only first occurrence will be evaluated, on subsequent executions the same value will be used.
If this is the case either move the __time() function to the Parameters input field or use System.currentTimeMillis() function instead
Demo:
More information:
JSR223 Sampler Documentation
Apache Groovy - Why and How You Should Use It

Jmeter reading input parameters from dynamically appending file

Please tell me, is it possible to read data into Jmeter from a dynamically changing file? I have a file with parameters, which will be appended during the test itself. Is it possible to somehow define a global counter that will allow each thread to read its own line every iteration? User Defined Variables are reset every iteration as i understood.
In theory, I can read a specific line using File.readLines().get(counter) in JSR223 Sampler but problem is how to define correctly this counter.
I believe __counter() function is what you're looking for. If you invoke it like ${__counter(FALSE,)} it will return an incremented value each time it will be called.
Example usage:
More information: How to Use a Counter in a JMeter Test

jMeter how to re-execute CSV Data Set Config

Using jMeter to set up a soak / load test that needs to run each request with different data. The structure I currently have is
Thread Group (2 Users, 2 Loops)
- Simple controller
-- Java Sampler (Custom Plugin) to convert CSV Formula data into NewThreadData.csv (as variable)
-- Java Sampler (Custom Plugin) to create directory of files created with NewThreadData.csv merged into a template
-- While Controller Condition - js NewThreadData column not = EOF
--- CSV Data Set Config NewThreadData.csv (Recycle False / Stop of EOF False) - filename passed as variable
--- JMS PUblisher with the FileName a variable using the filename column from within NewThreadData.csv
My problem is the on the second loop, the data is updated in NewThreadData.csv, but the CSV in the while loop never runs again.
Appears that the CSV Data Set Config "knows" it has been run, regardless of the actual CSV data.
Questions
How can I get the CSV Data Set Config to be rerun / re executed in this scenario?
Are there undocumented variables or means of getting the config to reprocess?
Is there a way to spawn a new thread on each iteration rather than reusing the existing thread, as the CSV does execute once for each "User"[thread]. I also tried Stop on EOF : True, but that stopped the second loop.
Aim is to eventually ramp up the user count and the number of loops (changing to forever); with there being about about 100 different combinations of data to be inserted on each loop. The formula I am using has time and thread number to give me data uniqueness along with other data that is dynamically created from a formula. Recycle on EOF is not feasible as I need to regenerate the csv contents on each loop. A super-csv I don't think is feasible to cover the load and soak scenarios.
Thanks in anticipation. Andrew
I don't think it's possible to "reset" the CSV Data Set Config, it's a configuration element hence once it reads the file in its current state it will "stick" to its content.
If you're manipulating file content dynamically I would rather recommend going for __CSVRead() function instead which is evaluated in the runtime just where it's placed therefore it doesn't reserve file and it "rewinds" to the beginning of the file when the last line is read.
More information: How to Pick Different CSV Files at JMeter Runtime
CSV Data Set Config element is executed first and only once even though you have placed it within the while controller. Hence CSV Data Set Config element is not suitable for your requirement.
You could use JSSR223 Pre-processor to work with the dynamic CSV files using a supported programming language/script (Java , Groovy)

Jmeter random number generation

I have a requirement to generate a random number and use it in subsequent requests. So, before using this newly generated random number in first subsequent request, i need to check if this random number generated is already exists in the application or not by comparing with newly generated response number. So for this validation i am thinking to use an extractor to get the count and eventually verify this is >1 and make it run until this condition is invalid. So in case of random number already exists, i need to generate a new random value since the previous one is already exist in the application. Any snippet i can use here?
An easier option would be going for __time() function which produces an Unix timestamp in milliseconds from 1st of Jan 1970. To be on the safe side you can add current thread number to it so even in case of concurrency you would get unique values (incrementing each millisecond):
More information on JMeter Functions concept: Apache JMeter Functions - An Introduction

JMeter: response assertion for each line in CSV file

I am learning JMeter and trying to do the following:
0) I only use 1 thread and only 1 loop
1) I have a CSV Data Set Config that loads a file with a bunch of strings (I am required to use CSV Data Set config)
2) I have a http request that responds with a web page. I need to make an assertion to it to verify if every string from the CSV is present on the page
I figured out that JMeter iterates to the next line in CSV file either for each thread or for each thread or loop.
But I only use 1 thread and 1 loop, and I don't want to repeat the whole test plan multiple times to verify if it contains multiple strings (it also does other stuff than this). How do I do this?
The CSV Data Set Config only increments to the next line on the next iteration. If you want access to all(or several) values in the CSV file in the same iteration, you should probably use the __CSVRead() function. Or possibly even the __StringFromFile() function.
If you're just doing this as a one of exercise, you can also put all the values you need to check in 1 CSV line and read them as different columns.
Lastly you can use a while controller to read the next line from CSV Data Set Config as explained here.

Resources