I was doing one of the performance tests for my current project and I realized that indexParam is not dynamically replaced in the body after the initial concurrency number of requests. Look at the following code of loadTestScript.js
var loadtest = require('loadtest')
function statusCallback (error, result, latency) {
console.log('Request index: %j, totalError %j, errorcode frequency %j error %j and RPS %j', result ? result.requestIndex : 'NOT FOUND', latency.totalErrors, latency.errorCodes, error, latency.rps)
}
let counter = 0
function optionsObject() {
return {
url: 'http://localhost:3000?name=value',
maxRequests: 10 ,
concurrency: 3,
method: 'POST',
contentType: 'application/json',
headers: {
'Content-Type': 'application/json'
},
indexParam: "value",
body: {
id: "value"
},
statusCallback: statusCallback,
indexParamCallback: function () {
return ++counter
}}
}
loadtest.loadTest(optionsObject(), function (error, result) {
// This blocks gets called when whole test is finished
if (error) {
console.log('Got an error: %s', error)
}
console.log('Got the following result from the test>>\n', result)
})
To check if values are dynamically received in the server, I ran a local express server on localhost:3000 with the following code
let reqCount = 0
app.post('/', function (req, res) {
console.log('------------------------------------')
console.log(`Received req for count ${++reqCount}`)
console.log(`Query params: `, req.query)
console.log(`Req body: `, req.body)
res.send('hello world')
})
and then I ran the loadTestScript.js script with the node loadTestScript.js command and the following is the output that I got
If you look at the request numbers 1, 2 and 3 everything looks good. But from request count 4 you will notice the value received in the body is static (last value of the request) while the name's value received through the query parameter is still dynamic. FYI if I increase the concurrency to 5 then the body will be dynamic till the 5th requests but later that it will stick to a static value. I believe the purpose of indexParam in the body is to provide dynamic values in the body irrespective of a number of concurrencies, currently, it's not serving that purpose.
I was doing one of the performance tests for my current project and I realized that indexParam is not dynamically replaced in the body after the initial concurrency number of requests. Look at the following code of
loadTestScript.js
To check if values are dynamically received in the server, I ran a local express server on localhost:3000 with the following code
and then I ran the
loadTestScript.js
script with thenode loadTestScript.js
command and the following is the output that I gotIf you look at the request numbers 1, 2 and 3 everything looks good. But from request count 4 you will notice the value received in the body is static (last value of the request) while the name's value received through the query parameter is still dynamic. FYI if I increase the concurrency to 5 then the body will be dynamic till the 5th requests but later that it will stick to a static value. I believe the purpose of indexParam in the body is to provide dynamic values in the body irrespective of a number of concurrencies, currently, it's not serving that purpose.
cc: @alexfernandez