我正在使用Apache为我们开发的应用程序运行一些针对RESTFUL的性能测试。我有一个端点“api/create/empList作业”,它基本上在MongoDB中添加了一个或多个雇员记录。POST调用的有效负载如下所示:
{
"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"
}
}
]
}如您所见,有效负载接收员工数据列表,并且至少应该有一条员工记录。我有一个要求,希望JMeter线程组有10个线程,每个线程都应该并发发布到“api/create/empList作业”,这样主体就有10个唯一的员工记录,从而总共创建了100个记录。我能参数化有效载荷的最好方法是什么?
发布于 2017-08-24 09:00:07
看看JMeter函数,比如:
因此,例如,如果您将JSON有效负载更改为:
"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将创建:
- `josh-1` for 1st virtual user
- `josh-2` for 2nd virtual usre
- etc.请参阅Apache JMeter函数-简介以熟悉JMeter函数的概念。
https://stackoverflow.com/questions/45856518
复制相似问题