views:

106

answers:

2

Hi, I'm writing a jmeter script and I have a huge csv file with a bunch of data which I use in my requests, is it possible to start not from first entry but from 5th or nth entry?

+3  A: 

Looking at the CSVDataSet, it doesn't seem to directly support skipping to a given row. However, you can emulate the same effect by first executing N loops where you just read from the data set and do nothing with the data. This is then followed by a loop containing your actual tests. It's been a while since I've used JMeter - for this approach to work, you must share the same CVSDataSet between both loops.

If that's not possible, then there is an alternative. In your main test loop, use a Counter and a If Controller. The Counter counts up from 1. The If controller contains your tests, with the condition $(Counter>N) where N is the number to skip. ("Counter" In the expression is whatever you set the "reference name" property" to in the counter.)

mdma
+2  A: 

mdma's 2nd idea is a clean way to do it, but here are two other options that are simple, but annoying to do:

  1. Easiest: Create separate CSV files for where you want to start the file, deleting the rows your don't need. I would create separate CSV data config elements for each CSV file, and then just disable the ones you don't want to run.

  2. Less Easy: Create a new column in your CSV file, called "ignore". In the rows you want to skip, enter the value "True". In your test plan, create an IF controller that is parent to your requests. Make the If condition: "${ignore}"!="True" (include the quotes and note that 'true' is case sensitive). This will skip the requests if the 'ignore' column has a value of 'true'.

Both methods require modifying the CSV file, but method two has other applications (like excluding a header row) and can be fast if you're using Open Office, Excel, etc.

BlackGaff
+1 the 2nd method makes a lot of sense and is very clean
Diadistis
Of note, the 2nd method impacts the Loop Count if you're trying to control the total number of rows read from the CSV. For example, if you want 10 loops, but your CSV has "ignore == TRUE" for two rows, you will only get 8 executions. You end up with a fun equation that reads Actual Loop Count == Desired Loop Count + Ceiling of (Desired Loop Count/Rows in CSV File)
BlackGaff