【问题标题】:How can i load test a post API using 'loadtest' nodejs module?如何使用“loadtest”nodejs 模块加载测试帖子 API?
【发布时间】:2015-08-02 15:20:10
【问题描述】:

我正在使用 loadtest nodejs 模块来测试 nodejs 脚本中 API 的压力测试。 Get 调用语法有效,但调用后无效。代码如下。

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?

【问题讨论】:

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


    【解决方案1】:

    Content-Type 的声明有错别字。 (第二个 i 不见了。)

    使用

    contentType: 'application/json',
    

    相反,它可以工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-04
      • 1970-01-01
      • 2017-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-08
      • 1970-01-01
      相关资源
      最近更新 更多