0
votes

newbie to jmeter.

i am trying to test the file upload portion of my site

I need to test multiple upload file types.

so for i have working

-- http request sampler to login

-- http request sampler to upload the file using "Send files with the request" (This is where i have the absolute path tothe upload file. where i would like to put a variable)

-- another http sampler to validate the upload

This all works fine. Now i want to loop through different scenarios based on the the thread count

int idx = ctx.getThreadNum();

I load some values for that loop based on idx

the part i can not get working is uploading a file specific to the thread idx

to hack this to get it working i have Swith controllers for each thread id that uploads a different file. this is problematic as each thread i want to add, i will have to add a new switch controller. This can not be the correct way to do it.

I appreciate any help

1

1 Answers

1
votes

Just use __threadNum() function in the "File Path" input like:

File Path ThreadNum

The function returns current thread number (starting with 1) so you will be able to upload different files with different threads.

By the way, int idx = ctx.getThreadNum(); returns thread numbers starting from 0, maybe that's why your test doesn't work as expected.

Beanshell versus function

See How to Use JMeter Functions articles series for comprehensive information on above and other useful JMeter functions.