1
votes

def index = [];
def randoms = [];
def size = new File("C:/Users/320027671/Desktop/JmeterPerformanceSuit/CompleteSuit/STU3/Post/index.csv").readLines().size();
File file = new File("C:/Users/320027671/Desktop/JmeterPerformanceSuit/CompleteSuit/STU3/Post/index.csv");
file.each { line ->
	index << line
	randoms << __Random(0,size,)
}

The script is giving error

the method does not exists

the scirpt is working uptil index << line, the problem is with random function

2

2 Answers

3
votes

I assume you use groovy as language (otherwise it won't work)

You can't use JMeter functions inside JSR223

You can randomize every line using for example RandomUtils:

org.apache.commons.lang3.RandomUtils.nextInt(0, size-1); 
0
votes

Your approach may fail to produce "random" numbers, especially on lesser file sizes you can get duplicate values in the randoms list so I would recommend doing something like:

1.upto(size, { i ->
    randoms.add(i)
})

Collections.shuffle(randoms)

This will populate randoms list with the numbers from 1 to the length of size and then calls Collection.shuffle() function in order to "randomise" the list.

Just in case check out Writing JMeter Functions in Groovy for more insights.