0
votes

i'm testing an API service using OAuth tokens. we have to divide the load per api service, therefore i seperated all services in different thread groups (also to make requests in parallel). since extracted OAUTH tokens (you need the acces token to make request to api) are only local to thread groups, i used a small beanshell script to write all tokens to a CSV file. later on, these tokens are used when doing the API calls.

the problem i'm facing is that the 'CSV Dataset Config' element is pre-loaded in memory (correct me if wrong), and because the tokens arent received yet at that point my API calls are failing with regex EOF. this happens only a few times where after the request succeed. i implemented a once only controller for the api requests to implement some thinktime, but this does only helps waiting for all users to get authenticated and receive the tokens.

question 1: how can i read token values in realtime from the CSV file for each api call (using custom code/beanshell)?

question 2: how can i make my beanshell script (see below) REWRITE the whole csv file each time the oauth2 sequence is run (now it keeps on appending to it..) ?

situation:

enter image description here

1
note: threads are set to NOT run consecutively (we want the API's to request in parallel). - DMC
IMO you could change a design to 1 thread group and have Throughput controllers control how many and which threads you run in parallel. I.e. say, if now you have 10 groups x 100 users each, it's like having 1 group x 1000 users, and instruct each of 10 Throughput controllers to use 10% of the load. That way the whole need for excel, and so on will go away. - Kiril S.
i just tested this, but requests within troughput controllers are not kicked off at the same time (Sample start time) like thread groups... - DMC
Do you have Ramp-Up period set to something other than 0? - Kiril S.
no, i do not use rampup. - DMC

1 Answers

0
votes

Issue fixed using 2 seperate testplans;

plan A) do one iteration with X amount of needed concurrent users to generate needed tokens + write tokens to CSV file.

plan B) call all API services divided in Throughput Controllers using CSV dataset (OAUTH sequence not needed).