I Need to assign 1 source with 5 process and 1 Process with 5 sources using any controller jmeter
If this is a static list you can use csv as input
Related
Hello I do have a csv with the following format:
id,number,date
001,12345,2409
002,23456,2510
003,35432,2203
004,45432,2204
005,55432,2205
006,65432,2206
007,75432,2207
008,85432,2208
009,95432,2209
I want to have 3 Threads with 3 Iterations each and
each thread should peek an new random value on each iteration
How could I achieve this in Jmeter (version 5.4.3) with csv config elements?
Thank you in advance
With JMeter's default CSV Data Set Config you can only have new next value on each iteration of each thread.
If you need next random value - take a look Random CSV Data Set Config, it can be installed using JMeter Plugins Manager
Context: Want to generate unique and different value when the thread runs in loop.
Currently it is generating the same value.
Script Inside JSR223 Preprocessor,
String subscribeSchemaNamePreProcesser="agent-Perf-${__Random(1,99999,)}"
log.info("Schema Name --------------->"+subscribeSchemaNamePreProcesser)
vars.put("subscribeSchemaNamePreProcesser", subscribeSchemaNamePreProcesser)
When run with number of threads more than 1(i.e. 2 thread 1 loop), it is generating different value
When run with number of loops more than 1 (i.e. 1 thread 2 loop), it is generating the same value (want to fix it)
anything I missed
Don't inline JMeter Functions or Variables into Groovy scripts, they will be cached and only first occurrence will be used for subsequent calls.
You need to change this line:
String subscribeSchemaNamePreProcesser="agent-Perf-${__Random(1,99999,)}"
to this one:
String subscribeSchemaNamePreProcesser = "agent-Perf-" + org.apache.commons.lang3.RandomUtils.nextInt(1, 99999)
More information:
JSR223 Sampler
Apache Groovy - Why and How You Should Use It
I want to test file uploading using Jmeter.
I want to upload files using 5 threads concurrently.
1 Thread successfully uploads all the files but after that all threads says file exist (which makes sense)
Is there a way i can upload all files successfully from all 5 threads, may be generate new file name each time ?
This solution will work for the configurations that you shared, 5 concurrent users uploading 10 files each.
First of all, create separate files for each thread (you have 10 files, copy them into 50) and rename them as below
Thread1_file1_0
Thread1_file2_0
Thread1_file3_0
.
.
Thread1_file10_0
Thread2_file1_0
Thread2_file2_0
.
.
Thread5_file10_0
Then create a csv file and add file extensions in column A. Make sure that row 1 reflects the extension of Threadx_file1_0 and row 2 reflects the extension of Threadx_file2_0 file as below and save the csv file in the same folder of your jmx script
Now to the script configurations, add 2 counters before your POST request (which uploads the files) with below configurations
First counter
Start 0
Increment 1
Reference Name originalName
Track counter independently for each user Yes
Reset counter on each Thread Group Iteration No
Second counter
Start 1
Increment 1
Reference Name Iteration
Track counter independently for each user Yes
Reset counter on each Thread Group Iteration No
Now add a loop controller with loop count set to 10, then add another counter, OS Process Sampler and CSV Data Set Config as children of the loop controller with below configurations
Counter configurations
Start 1
Increment 1
Reference Name fileNumber
Track counter independently for each user Yes
Reset counter on each Thread Group Iteration Yes
CSV Data Set Config
Filename extensionsCSVFile.csv
Variable Names extension
OS Process Sampler configurations
Command cmd
Command parameters
/C
ren {path to your folder}\Thread${__threadNum}_file${fileNumber}_${originalName}.${extension} Thread${__threadNum}_file${fileNumber}_${Iteration}.${extension}
Each line as a separate parameter. Now use file name in your post request as below
{path}\Thread${__threadNum}_file1_${Iteration}.pdf
{path}\Thread${__threadNum}_file2_${Iteration}.pdf
.
.
{path}\Thread${__threadNum}_file10_${Iteration}.docx
This will do the job, but i suggest that you also add a way to revert the names back to Thread1_file1_0. You can do it by following the below steps
Add a BeanShell PostProcessor as a child of the OS Process Sampler with below code in the code area
props.put("lastIteration", vars.get("Iteration"));
Now add a tearDown Thread Group, then copy the loop controller with all its elements from previous above steps and paste into the tearDown Thread Group (except the BeanShell PostProcessor, remove it after you paste).
Now go the OS Process Sampler within the tearDown Thread Group and adjust the second parameter as below
ren {}\Thread${__threadNum}_file${fileNumber}_${__P(lastIteration)}.${extension} Thread${__threadNum}_file${fileNumber}_0.${extension}
Finally, just make sure that number of threads in both main thread group and tearDown Thread Group is the same, which in this case 5. The structure will be as below
I have a Jmeter test with multiple while controler, each looping through data in separate files
I want each while loop to loop through the end of that file.
Structure:
While controller 1
- CSV Data Config 1
- Http sampler 1
While Controller 2
- CSV Data Config 2
- http sampler 2
When I set as an end condition: ${__javaScript(${myVar}!="<EOF>")} with stop thread on end of file to true, it stops the whole test completly.
If I set stop on end of file to false it loops on the also, meaning it loops one time too many
Is there another way to do this?
Thanks
A possible solution would be use beanshell processor and find the number of records in each file. Use the number of lines as the condition to break out of the loop. Please note that you will have to use parseint in the while condition as discussed in this thread.
Another option could be changing your While Controller to do the infinite loop and control thread stopping via CSV Data Set Config.
As per Using CSV DATA SET CONFIG guide:
It is worth mentioning that every CSV Data Set Config is visible to all Thread Groups by default. If you need to use separate CSV Data Set Config for every Thread, you create a number of data files that you need and in every CSV Data Set Config set “Sharing mode” to “Current Thread”
So the following combination:
Recycle on EOF = false
Stop Thread on EOF = true
Sharing mode = Current Thread
Should do the trick for you.
My scenario is like,
1. Login by multiple users (100 users)
2. Select 50 items by id's specific to user
I have placed id's for each user in separate csv file say user1.csv, user2.csv, user3.csv and so on.
My result should be like Thread 1 should take user1.csv and process all 50 id's in loop controller.
Thread 2 should take user2.csv and so on.
I tried with below example, but still couldn't find the solution.
Eg. I used file path as C:\abc\user${_threadNum}.csv
Or
C:\abc\user${_threadNum}.csv
Variable name in csv file is user_id
Requeat will look like /home/abc/${user_id}
I want thread 1 to use the user1.csv file and substitiue the value of user_id in the request and thread 2 should use user2.csv and so on.
If I execute my above plan, I am getting error as /home/abc/EOF
How is this possible in JMeter? Or any other approach?
Please provide solution with an example, since I am new to JMeter.
Create your files like comman_name_1,comman_name_2,comman_name_3
etc. & select current thread option from dropdown list present in csv data config set.This will allow threads to use different files per thread or put values in a single file and select current thread option.
It's easy, just add CSV Data Set Config to each thread (user1.csv for thread1 and so forth). Configure CSV Data Set config, and select one of this values in Sharing mode field:
Current thread group - each file is opened once for each thread group
in which the element appears
Current thread - each file is opened separately for each thread
UPD: I have done it right now, it works
Script looks like this:
I selected 'Current thread' in each CSV Data Set Config
I was making the mistake of using single underscore in fetching the count of thread.
We need to use double - underscore like this : ${__threadNum}
Note :