loadtest 8.1.1 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/doc/api.md +15 -2
- package/lib/httpClient.js +6 -2
- package/lib/options.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -560,7 +560,8 @@ see [doc/api.md](doc/api.md) for the full explanations with examples.
|
|
|
560
560
|
* `requestGenerator`: custom request generator function.
|
|
561
561
|
* `agentKeepAlive`: if true, will use 'Connection: Keep-alive'.
|
|
562
562
|
* `quiet`: if true, do not show any messages.
|
|
563
|
-
* `indexParam`:
|
|
563
|
+
* `indexParam`: regexp to replace in URL and body with a unique index. The string specified in this parameter will be passed to `new Regexp(here, 'g')`. Do not use together with `indexParamLiteral`.
|
|
564
|
+
* `indexParamLiteral`: literal string to replace in URL and body with a unique index. Do not use together with `indexParam`.
|
|
564
565
|
* `indexParamCallback`: function to generate unique indexes.
|
|
565
566
|
* `insecure`: allow invalid and self-signed certificates over https.
|
|
566
567
|
* `secureProtocol`: TLS/SSL method to use.
|
|
@@ -623,7 +624,9 @@ The expected structure of the file is the following:
|
|
|
623
624
|
"agentKeepAlive": "Use a keep-alive http agent",
|
|
624
625
|
"proxy": "Use a proxy for requests",
|
|
625
626
|
"requestsPerSecond": "Specify the requests per second for each client",
|
|
626
|
-
"indexParam": "
|
|
627
|
+
"indexParam": "pattern to replace with a generated index in the URL",
|
|
628
|
+
"indexParamLiteral": "string to replace with a generated index in the URL",
|
|
629
|
+
"indexParamCallback": "function() {that generates ids to insert into the URL}"
|
|
627
630
|
}
|
|
628
631
|
```
|
|
629
632
|
|
package/doc/api.md
CHANGED
|
@@ -170,14 +170,27 @@ Do not show any messages.
|
|
|
170
170
|
|
|
171
171
|
#### `indexParam`
|
|
172
172
|
|
|
173
|
+
The given pattern will be replaced in the final URL with a unique index.
|
|
174
|
+
E.g.: if URL is `http://test.com/value` and `indexParam = '\bvalue\b'`, then the URL
|
|
175
|
+
will be:
|
|
176
|
+
|
|
177
|
+
* http://test.com/1
|
|
178
|
+
* http://test.com/2
|
|
179
|
+
* ...
|
|
180
|
+
* body will also be replaced `body:{ userid: value, othervalue: 123 }` will be `body:{ userid: 1, othervalue: 123 }`
|
|
181
|
+
|
|
182
|
+
#### `indexParamLiteral`
|
|
183
|
+
|
|
173
184
|
The given string will be replaced in the final URL with a unique index.
|
|
174
|
-
E.g.: if URL is `http://test.com/value` and `indexParam
|
|
185
|
+
E.g.: if URL is `http://test.com/value` and `indexParam: 'value'`, then the URL
|
|
175
186
|
will be:
|
|
176
187
|
|
|
177
188
|
* http://test.com/1
|
|
178
189
|
* http://test.com/2
|
|
179
190
|
* ...
|
|
180
|
-
* body will also be replaced `body:{ userid:
|
|
191
|
+
* body will also be replaced `body:{ userid: value, othervalue: 123 }` will be `body:{ userid: 1, other1: 123 }`
|
|
192
|
+
|
|
193
|
+
Use only indexParamLiteral or only indexParam. Not both at the same time!
|
|
181
194
|
|
|
182
195
|
#### `indexParamCallback`
|
|
183
196
|
|
package/lib/httpClient.js
CHANGED
|
@@ -85,8 +85,12 @@ export class HttpClient {
|
|
|
85
85
|
const agent = new HttpsProxyAgent(proxy);
|
|
86
86
|
this.params.agent = agent;
|
|
87
87
|
}
|
|
88
|
-
if (this.options.
|
|
89
|
-
this.params.indexParamFinder =
|
|
88
|
+
if (this.options.indexParamLiteral) {
|
|
89
|
+
this.params.indexParamFinder = this.options.indexParamLiteral;
|
|
90
|
+
this.params.indexParamCallback = this.options.indexParamCallback;
|
|
91
|
+
} else if (this.options.indexParam) {
|
|
92
|
+
this.params.indexParamFinder = (this.options.indexParam instanceof RegExp) ? this.options.indexParam : new RegExp(this.options.indexParam, 'g');
|
|
93
|
+
this.params.indexParamCallback = this.options.indexParamCallback;
|
|
90
94
|
}
|
|
91
95
|
// Disable certificate checking
|
|
92
96
|
if (this.options.insecure === true) {
|
package/lib/options.js
CHANGED
|
@@ -22,6 +22,8 @@ class Options {
|
|
|
22
22
|
this.requestsPerSecond = options.requestsPerSecond || rps || configuration.requestsPerSecond
|
|
23
23
|
this.agentKeepAlive = options.keepalive || options.agent || options.agentKeepAlive || configuration.agentKeepAlive;
|
|
24
24
|
this.indexParam = options.index || options.indexParam || configuration.indexParam;
|
|
25
|
+
this.indexParamLiteral = options.indexParamLiteral || configuration.indexParamLiteral;
|
|
26
|
+
this.indexParamCallback = options.indexParamCallback || configuration.indexParamCallback;
|
|
25
27
|
this.method = options.method || configuration.method || 'GET'
|
|
26
28
|
this.readBodyAndMethod(options, configuration)
|
|
27
29
|
this.key = null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loadtest",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"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.",
|
|
6
6
|
"homepage": "https://github.com/alexfernandez/loadtest",
|