testingjmeterload

Need to generate unique users when I start load test for Sign up


I need to create unique users with (firstname, lastname, email, password) values each time I run load test (Sign Up).

I have already an empty CSV set config with firstname, lastname, email, password values. The problem is that Jmeter tries to create a new user with email that was used before. My goal is to run a load test for 10.000 unique users that I need to generate.

Please help!

enter image description here

enter image description here


Solution

  • You can try below solution:

    1. Add JSR223 PreProcessor to your "Sign Up" request. enter image description here

    2. Add the following groovy code to the JSR223 PreProcessor for the 5 fields.

    import org.apache.commons.lang3.RandomStringUtils
    
    // Get the current Thread Number and Iteration Count
    def threadNumber = ctx.getThreadNum()
    def iterationCount = ctx.getVariables().getIteration()
    
    // Generate random data
    def firstName = RandomStringUtils.randomAlphabetic(5)
    def lastName = RandomStringUtils.randomAlphabetic(5)
    def email = "${firstName}_${lastName}_${threadNumber}_${iterationCount}" + "@email.com"
    def password = RandomStringUtils.randomAlphanumeric(8)
    def confirmPassword = password
    
    // Set variables to be used in the test
    vars.put("P_FirstName", firstName)
    vars.put("P_LastName", lastName)
    vars.put("P_Email", email)
    vars.put("P_Password", password)
    vars.put("P_ConfirmPassword", confirmPassword)
    

    enter image description here

    3. Add the variables' names in the POST request enter image description here

    4. Now, before every request, the PreProcessor will generate unique values for the respective fields. Example:

    enter image description here enter image description here

    Hope this helps!