alexfernandez/loadtest

requestsPerSecond in the response of the Rest API is not correct.

LorenzoCorbella74 opened this issue · 2 comments

If I invoke a test during a request to a certain "test" endpoint the options object mutate in the response and the field requestsPerSecond is always 1 and in the response rps=1.

router.get('/loadtest', function (req, res) { const options = { url: http://localhost:3301${req.query.url ? /${req.query.url} : ''}, maxRequests: Number(req.query.n) || null, concurrency: Number(req.query.c) || null, requestsPerSecond: Number(req.query.rps) || null, maxSeconds: Number(req.query.t) || 10, } loadtest.loadTest(options, function (error, result) { if (error) { return console.error('Got an error: %s', error); } console.log('Tests run successfully'); res.json({options, result}) }); })

options is:
{ url: 'http://localhost:3301/pesante', maxRequests: null, concurrency: 10, requestsPerSecond: 10, maxSeconds: 5 }
When it can back with the response is:
{ "url": "http://localhost:3301/pesante", "maxRequests": null, "concurrency": 10, "requestsPerSecond": 1, "maxSeconds": 5, "quiet": true }
And the response is accordingly:
"result": { "totalRequests": 7, "totalErrors": 0, "totalTimeSeconds": 7.3343388009999995, "rps": 1, <-- as before "meanLatencyMs": 2452.9, "maxLatencyMs": 3957, "minLatencyMs": 662, "percentiles": { "50": 1982, "90": 3957, "95": 3957, "99": 3957 }, "errorCodes": {}, "instanceIndex": 0 } }

Hum, care to suggest a solution? PRs are welcome :)

This issue should be solved now in the upcoming 6.2.0 (to be released as soon as I fix a couple of issues) where the options object is not mutated any longer. Closing, please reopen if not the case.