Problem with generate radom Date


To have a visibility of the behavior of the application in Production I launched a simulation of “validation of a day of sale”. This functionality requires to regenerate different dates, if users are going to execute this request simultaneously by passing the same date, we will have 1 request will succeed and the others will fail.

I used a function which returns random dates by simulating 50 virtual users, I obtained 47 OK and 3 KO (error 400).

fucntion of randomDate.PNG

the failure error of these 3 requests is because of using the same date. Do you have any idea how to solve this. Is there is other method of not falling on the same date?

Ghazouani Nada


You need to be sure that generated dates will not overlap.

One solution is to use a feeder.
You can generate a unique date (by checking the random date is not already used)
You can prepare a list of unique dates ( (1 to 900).map(now.plusMonth _ ).shuffle) and pick in it in order (as the list is only composed from unique date and the list is shuffled, you should be ok with that)
You can pregenerate dates and put them in a file.

Your choice ^^

fucntion of randomDate.PNG

Thank you very much Sébastien for your help. It works now. I generated several dates and saved them in a .csv file then I used feeder to retrieve them from the file

but the problem now in the response times, I launched the same scenario 2 times by adding 1 virtual user with:
1-a simulation which generates a random date, in this case the response time = 1.9 s

2-another simulation which retrieves the date through the .csv file the response time is different from the previous simulation, response time equal 2.3 scan

Can you please explain to me why this difference betwwen response times.
Thanks in advance

1 user and 1 request is not significant.

try again multiple times (before and after)
and look the different results


Thanks for your response, but I didn’t understand what you mean by “1 user and 1 request is not significant” ?
I checked this scenario via GUI by inspecting the requests, I found that the response time = 1.49s