如何使用Node测试框架实现ElasticSearch的自动化测试?
我想将ElasticSearch实现到我的nodejs项目中以获得高效的搜索能力,这是使用Express框架,frisby,Socket.io等.ElasticSearch nodejs实现很容易在谷歌上获得,但不是它的自动化测试.需要建议.
我正在使用 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'
}
}
Run Code Online (Sandbox Code Playgroud)
}
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: …
Run Code Online (Sandbox Code Playgroud)