如何使用'loadtest'nodejs模块加载测试后API?

时间:2015-05-21 05:52:57

标签: json node.js post load-testing stress-testing

我正在使用loadtest nodejs模块来测试nodejs脚本中API的压力测试。 Get call语法正在运行,但不是后调用。代码如下。

function optionsObject() {
  return { 
  url: 'http://localhost:3000/api/v2/signup',
  maxRequests: 1,
  concurrency: 1,
  method: 'POST',
  contentType: 'applicaton/json',
  body: {
     password: 'test',
     email: 'testobject_1@signup2.com',
     name: 'kPYgJ6Rg5wnExt8hTXQIHDn2LaCMsytjhQzp' 
        }
   }

}

loadtest.loadTest(optionsObject(), function (error, result) {
            if (error) {
             console.log('Got an error: %s', error);
            } else {
             console.log(result);
              }
            });

            Results:
                {
                 totalRequests: 1,
                 totalErrors: 1,
                 totalTimeSeconds: 0.025545716,
                 rps: 39,
                 meanLatencyMs: 20,
                 maxLatencyMs: 20,
                 percentiles: { '50': 20, '90': 20, '95': 20, '99': 20 },
                 errorCodes: { '400': 1 } 
                 }

任何人都可以帮助我为什么我的错误请求错误400?

1 个答案:

答案 0 :(得分:4)

在Content-Type的声明中有一个拼写错误。 (第二个我不见了。)

使用

contentType: 'application/json',

相反,它可以工作。

相关问题