loadtest 6.0.0 → 6.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 +108 -64
- package/bin/loadtest.js +3 -2
- package/lib/httpClient.js +21 -10
- package/lib/latency.js +18 -65
- package/lib/loadtest.js +44 -29
- package/lib/options.js +52 -100
- package/lib/result.js +68 -0
- package/lib/testserver.js +28 -23
- package/package.json +2 -2
- package/sample/request-generator.js +2 -2
- package/sample/request-generator.ts +2 -2
- package/test/body-generator.js +3 -2
- package/test/integration.js +40 -12
- package/test/latency.js +1 -1
- package/test/loadtest.js +43 -12
- package/test/request-generator.js +3 -2
- package/test/testserver.js +1 -0
package/test/loadtest.js
CHANGED
|
@@ -2,27 +2,22 @@ import testing from 'testing'
|
|
|
2
2
|
import {loadTest} from '../lib/loadtest.js'
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* A load test with max seconds.
|
|
7
|
-
*/
|
|
8
5
|
function testMaxSeconds(callback) {
|
|
9
6
|
const options = {
|
|
10
7
|
url: 'http://localhost:7357/',
|
|
11
8
|
maxSeconds: 0.1,
|
|
12
9
|
concurrency: 1,
|
|
10
|
+
quiet: true,
|
|
13
11
|
};
|
|
14
12
|
loadTest(options, callback);
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* A load test with max seconds.
|
|
20
|
-
*/
|
|
21
15
|
function testWSEcho(callback) {
|
|
22
16
|
const options = {
|
|
23
17
|
url: 'ws://localhost:7357/',
|
|
24
18
|
maxSeconds: 0.1,
|
|
25
19
|
concurrency: 1,
|
|
20
|
+
quiet: true,
|
|
26
21
|
};
|
|
27
22
|
loadTest(options, callback);
|
|
28
23
|
}
|
|
@@ -32,7 +27,8 @@ function testIndexParam(callback) {
|
|
|
32
27
|
url: 'http://localhost:7357/replace',
|
|
33
28
|
concurrency:1,
|
|
34
29
|
maxSeconds: 0.1,
|
|
35
|
-
indexParam: "replace"
|
|
30
|
+
indexParam: "replace",
|
|
31
|
+
quiet: true,
|
|
36
32
|
};
|
|
37
33
|
loadTest(options, callback);
|
|
38
34
|
}
|
|
@@ -43,7 +39,8 @@ function testIndexParamWithBody(callback) {
|
|
|
43
39
|
concurrency:1,
|
|
44
40
|
maxSeconds: 0.1,
|
|
45
41
|
indexParam: "replace",
|
|
46
|
-
body: '{"id": "replace"}'
|
|
42
|
+
body: '{"id": "replace"}',
|
|
43
|
+
quiet: true,
|
|
47
44
|
};
|
|
48
45
|
loadTest(options, callback);
|
|
49
46
|
}
|
|
@@ -57,7 +54,8 @@ function testIndexParamWithCallback(callback) {
|
|
|
57
54
|
indexParamCallback: function() {
|
|
58
55
|
//https://gist.github.com/6174/6062387
|
|
59
56
|
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
60
|
-
}
|
|
57
|
+
},
|
|
58
|
+
quiet: true,
|
|
61
59
|
};
|
|
62
60
|
loadTest(options, callback);
|
|
63
61
|
}
|
|
@@ -72,16 +70,49 @@ function testIndexParamWithCallbackAndBody(callback) {
|
|
|
72
70
|
indexParamCallback: function() {
|
|
73
71
|
//https://gist.github.com/6174/6062387
|
|
74
72
|
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
75
|
-
}
|
|
73
|
+
},
|
|
74
|
+
quiet: true,
|
|
76
75
|
};
|
|
77
76
|
loadTest(options, callback);
|
|
78
77
|
}
|
|
79
78
|
|
|
79
|
+
function testError(callback) {
|
|
80
|
+
const options = {
|
|
81
|
+
maxSeconds: 0.1,
|
|
82
|
+
concurrency: 1,
|
|
83
|
+
quiet: true,
|
|
84
|
+
};
|
|
85
|
+
loadTest(options, (error) => {
|
|
86
|
+
if (!error) {
|
|
87
|
+
return callback('Should error without URL')
|
|
88
|
+
}
|
|
89
|
+
return callback(false, 'OK')
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A load test with keep-alive.
|
|
95
|
+
*/
|
|
96
|
+
function testKeepAlive(callback) {
|
|
97
|
+
const options = {
|
|
98
|
+
url: 'http://localhost:7357/',
|
|
99
|
+
maxSeconds: 0.1,
|
|
100
|
+
concurrency: 1,
|
|
101
|
+
quiet: true,
|
|
102
|
+
keepalive: true,
|
|
103
|
+
};
|
|
104
|
+
loadTest(options, callback)
|
|
105
|
+
}
|
|
106
|
+
|
|
80
107
|
|
|
81
108
|
/**
|
|
82
109
|
* Run all tests.
|
|
83
110
|
*/
|
|
84
111
|
export function test(callback) {
|
|
85
|
-
testing.run([
|
|
112
|
+
testing.run([
|
|
113
|
+
testMaxSeconds, testWSEcho, testIndexParam, testIndexParamWithBody,
|
|
114
|
+
testIndexParamWithCallback, testIndexParamWithCallbackAndBody,
|
|
115
|
+
testError, testKeepAlive,
|
|
116
|
+
], callback);
|
|
86
117
|
}
|
|
87
118
|
|
|
@@ -6,14 +6,14 @@ const PORT = 10453;
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
function testRequestGenerator(callback) {
|
|
9
|
-
const server = startServer({port: PORT}, error => {
|
|
9
|
+
const server = startServer({port: PORT, quiet: true}, error => {
|
|
10
10
|
if (error) {
|
|
11
11
|
return callback('Could not start test server');
|
|
12
12
|
}
|
|
13
13
|
const options = {
|
|
14
14
|
url: 'http://localhost:' + PORT,
|
|
15
15
|
method: 'POST',
|
|
16
|
-
requestsPerSecond:
|
|
16
|
+
requestsPerSecond: 1000,
|
|
17
17
|
maxRequests: 100,
|
|
18
18
|
concurrency: 10,
|
|
19
19
|
requestGenerator: (params, options, client, callback) => {
|
|
@@ -24,6 +24,7 @@ function testRequestGenerator(callback) {
|
|
|
24
24
|
request.write(message);
|
|
25
25
|
return request;
|
|
26
26
|
},
|
|
27
|
+
quiet: true,
|
|
27
28
|
};
|
|
28
29
|
loadTest(options, (error, result) => {
|
|
29
30
|
if (error) {
|
package/test/testserver.js
CHANGED