loadtest
Advanced tools
Comparing version 5.1.2 to 5.2.0
@@ -260,2 +260,5 @@ 'use strict'; | ||
}; | ||
if (connection.req.labels) { | ||
result.labels = connection.req.labels | ||
} | ||
if (contentInspector) { | ||
@@ -262,0 +265,0 @@ contentInspector(result) |
{ | ||
"name": "loadtest", | ||
"version": "5.1.2", | ||
"version": "5.2.0", | ||
"description": "Run load tests for your web application. Mostly ab-compatible interface, with an option to force requests per second. Includes an API for automated load testing.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/alexfernandez/loadtest", |
@@ -654,3 +654,3 @@ [![Build Status](https://secure.travis-ci.org/alexfernandez/loadtest.svg)](http://travis-ci.org/alexfernandez/loadtest) | ||
Execution this function after every request operation completes. Provides immediate access to test results while the | ||
If present, this function executes after every request operation completes. Provides immediate access to test results while the | ||
test batch is still running. This can be used for more detailed custom logging or developing your own spreadsheet or | ||
@@ -696,2 +696,27 @@ statistical analysis of results. | ||
In some situations request data needs to be available in the statusCallBack. | ||
This data can be assigned to `request.labels` in the requestGenerator: | ||
```javascript | ||
const options = { | ||
// ... | ||
requestGenerator: (params, options, client, callback) => { | ||
// ... | ||
const randomInputData = Math.random().toString().substr(2, 8); | ||
const message = JSON.stringify({ randomInputData }) | ||
const request = client(options, callback); | ||
request.labels = randomInputData; | ||
request.write(message); | ||
return request; | ||
} | ||
}; | ||
``` | ||
Then in statusCallBack the labels can be accessed through `result.labels`: | ||
```javascript | ||
function statusCallback(error, result, latency) { | ||
console.log(result.labels); | ||
} | ||
``` | ||
**Warning**: The format for `statusCallback` has changed in version 2.0.0 onwards. | ||
@@ -698,0 +723,0 @@ It used to be `statusCallback(latency, result, error)`, |
94499
2198
883