0
votes

I am using Apache JMeter to run a few performance tests against RESTFUL API for an application that we have developed. I have an end point "api/create/empListJob", which basically adds one or more employee records in the MongoDB. The payload for the POST call looks like this:

{
        "employeeList": [
            {
                "first_name": "josh",
                "last_name": "don",
                "age": "25",
                "address": {
                    "street1": "xyz",
                    "street2": "apt-10",
                    "city" : "def",
                    "state" : "CA",
                    "zip" : "95055"
                },
                "deptType": {
                    "deptID": "1",
                    "deptName": "R&D"
                }
            },
            {
                "first_name": "mary",
                "last_name": "jane",
                "age": "22",
                "address": {
                    "street1": "zzz",
                    "street2": "apt-15",
                    "city" : "yyy",
                    "state" : "CA",
                    "zip" : "95054"
                },
                "deptType": {
                    "deptID": "2",
                    "deptName": "HR"
                }
            }
        ]
    }

As you can see, the payload takes a list of employee data, and it should have atleast one employee record. I have a requirement in which i want JMeter thread group to have 10 threads and each of these threads should make a concurrent POST to "api/create/empListJob" such that the body has 10 unique employee records, thus creating a total of 100 records. What is the best way that i could parameterize the payload?

1

1 Answers

2
votes

Take a look at JMeter Functions, like:

So for example if you change your JSON payload to look like:

"employeeList": [
  {
      "first_name": "josh-${__threadNum}",
      "last_name": "don-${__threadNum}",
      "age": "25",
      "address": {
          "street1": "xyz",
          "street2": "apt-10",
          "city" : "def",
          "state" : "CA",
          "zip" : "95055"
      },
      "deptType": {
          "deptID": "1",
          "deptName": "R&D"
      }
  },
  {
      "first_name": "mary-${__threadNum}",
      "last_name": "jane-${__threadNum}",
      "age": "22",
      "address": {
          "street1": "zzz",
          "street2": "apt-15",
          "city" : "yyy",
          "state" : "CA",
          "zip" : "95054"
      },
      "deptType": {
          "deptID": "2",
          "deptName": "HR"
      }
  }
]
}

JMeter will create:

- `josh-1` for 1st virtual user
- `josh-2` for 2nd virtual usre
- etc.

See Apache JMeter Functions - An Introduction to get familiarized with JMeter Functions concept.