loadtest 6.3.0 → 6.3.2
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 +12 -38
- package/lib/testserver.js +5 -0
- package/package.json +1 -1
- package/cluster-error.js +0 -17
- package/cluster-works.cjs +0 -17
package/README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
[](http://travis-ci.org/alexfernandez/loadtest)
|
|
2
1
|
[](https://repl.it/github/alexfernandez/loadtest)
|
|
3
2
|
|
|
4
3
|
[](https://nodei.co/npm/loadtest/)
|
|
@@ -301,30 +300,9 @@ Setting this to 0 disables timeout (default).
|
|
|
301
300
|
|
|
302
301
|
#### `-R requestGeneratorModule.js`
|
|
303
302
|
|
|
304
|
-
Use custom request generator function from an external file.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
```javascript
|
|
309
|
-
module.exports = function(params, options, client, callback) {
|
|
310
|
-
generateMessageAsync(function(message) {
|
|
311
|
-
|
|
312
|
-
if (message)
|
|
313
|
-
{
|
|
314
|
-
options.headers['Content-Length'] = message.length;
|
|
315
|
-
options.headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
316
|
-
}
|
|
317
|
-
request = client(options, callback);
|
|
318
|
-
if (message){
|
|
319
|
-
request.write(message);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
return request;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
See [`sample/request-generator.js`](sample/request-generator.js) for some sample code including a body
|
|
303
|
+
Use a custom request generator function from an external file.
|
|
304
|
+
See an example of a request generator module in [`--requestGenerator`](#requestGenerator) below.
|
|
305
|
+
Also see [`sample/request-generator.js`](sample/request-generator.js) for some sample code including a body
|
|
328
306
|
(or [`sample/request-generator.ts`](sample/request-generator.ts) for ES6/TypeScript).
|
|
329
307
|
|
|
330
308
|
#### `--agent` (deprecated)
|
|
@@ -666,24 +644,20 @@ How many requests each client will send per second.
|
|
|
666
644
|
|
|
667
645
|
#### `requestGenerator`
|
|
668
646
|
|
|
669
|
-
|
|
647
|
+
Use a custom request generator function.
|
|
648
|
+
The request needs to be generated synchronously and returned when this function is invoked.
|
|
670
649
|
|
|
671
650
|
Example request generator function could look like this:
|
|
672
651
|
|
|
673
652
|
```javascript
|
|
674
653
|
function(params, options, client, callback) {
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
request.write(message);
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
request.end();
|
|
686
|
-
}
|
|
654
|
+
const message = generateMessage();
|
|
655
|
+
const request = client(options, callback);
|
|
656
|
+
options.headers['Content-Length'] = message.length;
|
|
657
|
+
options.headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
658
|
+
request.write(message);
|
|
659
|
+
request.end();
|
|
660
|
+
return request;
|
|
687
661
|
}
|
|
688
662
|
```
|
|
689
663
|
|
package/lib/testserver.js
CHANGED
|
@@ -106,6 +106,11 @@ class TestServer {
|
|
|
106
106
|
request.on('data', data => {
|
|
107
107
|
request.body += data.toString();
|
|
108
108
|
});
|
|
109
|
+
request.on('error', () => {
|
|
110
|
+
// ignore request
|
|
111
|
+
response.end()
|
|
112
|
+
this.latency.end(id, -1);
|
|
113
|
+
})
|
|
109
114
|
request.on('end', () => {
|
|
110
115
|
this.totalRequests += 1
|
|
111
116
|
const elapsedMs = Date.now() - this.debuggedTime
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loadtest",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.2",
|
|
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",
|
package/cluster-error.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
process.env.NODE_CLUSTER_SCHED_POLICY = 'none'
|
|
2
|
-
|
|
3
|
-
const cluster = await import('cluster')
|
|
4
|
-
console.log(cluster)
|
|
5
|
-
//import * as cluster from 'cluster'
|
|
6
|
-
|
|
7
|
-
if (cluster.isPrimary) {
|
|
8
|
-
console.log(`process.env.NODE_CLUSTER_SCHED_POLICY: ${process.env.NODE_CLUSTER_SCHED_POLICY}`)
|
|
9
|
-
for (let index = 0; index < 2; index++) {
|
|
10
|
-
cluster.fork()
|
|
11
|
-
setTimeout(() => console.log(`cluster.schedulingPolicy: ${cluster.schedulingPolicy}`), 1000)
|
|
12
|
-
}
|
|
13
|
-
} else {
|
|
14
|
-
setTimeout(() => null, 1000)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
package/cluster-works.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
process.env.NODE_CLUSTER_SCHED_POLICY = 'none'
|
|
2
|
-
|
|
3
|
-
const cluster = require('cluster')
|
|
4
|
-
console.log(cluster)
|
|
5
|
-
//import * as cluster from 'cluster'
|
|
6
|
-
|
|
7
|
-
if (cluster.isPrimary) {
|
|
8
|
-
console.log(`process.env.NODE_CLUSTER_SCHED_POLICY: ${process.env.NODE_CLUSTER_SCHED_POLICY}`)
|
|
9
|
-
for (let index = 0; index < 2; index++) {
|
|
10
|
-
cluster.fork()
|
|
11
|
-
setTimeout(() => console.log(`cluster.schedulingPolicy: ${cluster.schedulingPolicy}`), 1000)
|
|
12
|
-
}
|
|
13
|
-
} else {
|
|
14
|
-
setTimeout(() => null, 1000)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|