k6-cucumber-steps 1.0.4 → 1.0.6
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/.env +1 -1
- package/bin/k6-cucumber-runner.js +4 -6
- package/lib/index.js +5 -0
- package/package.json +4 -4
- package/reports/load-results.html +8 -1
- package/reports/load-results.json +231 -0
- package/step_definitions/load_test_steps.js +4 -4
- package/tmp/k6_script_47e2a318-0613-4ef5-a53b-834b50f52790.js +44 -0
- package/tmp/k6_script_4b8eec2f-49ea-4f44-bc8b-075a37784d1a.js +44 -0
- package/tmp/k6_script_8b3bbfa7-4fa6-4116-81ff-db61d60bafd3.js +44 -0
- package/libs/index.js +0 -21
- /package/{libs → lib}/helpers/buildK6Script.js +0 -0
- /package/{libs → lib}/helpers/generateHeaders.js +0 -0
- /package/{libs → lib}/helpers/resolveBody.js +0 -0
- /package/{libs → lib}/utils/k6Runner.js +0 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"description": "",
|
|
4
|
+
"elements": [
|
|
5
|
+
{
|
|
6
|
+
"description": "",
|
|
7
|
+
"id": "run-load-tests-with-dynamic-get-and-post-body-from-environment-variables-and-json-files;i-run-the-k6-script-for-load-testing-with-dynamic-get-requests",
|
|
8
|
+
"keyword": "Scenario Outline",
|
|
9
|
+
"line": 47,
|
|
10
|
+
"name": "I run the k6 script for load testing with dynamic GET requests",
|
|
11
|
+
"steps": [
|
|
12
|
+
{
|
|
13
|
+
"arguments": [],
|
|
14
|
+
"keyword": "Given ",
|
|
15
|
+
"line": 33,
|
|
16
|
+
"name": "I have a k6 script for GET testing",
|
|
17
|
+
"match": {
|
|
18
|
+
"location": "step_definitions/load_test_steps.js:21"
|
|
19
|
+
},
|
|
20
|
+
"result": {
|
|
21
|
+
"status": "passed",
|
|
22
|
+
"duration": 525166
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"arguments": [
|
|
27
|
+
{
|
|
28
|
+
"rows": [
|
|
29
|
+
{
|
|
30
|
+
"cells": [
|
|
31
|
+
"virtual_users",
|
|
32
|
+
"duration",
|
|
33
|
+
"http_req_failed",
|
|
34
|
+
"http_req_duration",
|
|
35
|
+
"error_rate"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"cells": [
|
|
40
|
+
"10",
|
|
41
|
+
"5",
|
|
42
|
+
"rate<0.05",
|
|
43
|
+
"p(95)<3000",
|
|
44
|
+
"<error_rate>"
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"keyword": "When ",
|
|
51
|
+
"line": 34,
|
|
52
|
+
"name": "I run the k6 script with the following configurations:",
|
|
53
|
+
"match": {
|
|
54
|
+
"location": "step_definitions/load_test_steps.js:25"
|
|
55
|
+
},
|
|
56
|
+
"result": {
|
|
57
|
+
"status": "passed",
|
|
58
|
+
"duration": 228541
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"arguments": [
|
|
63
|
+
{
|
|
64
|
+
"content": "/api/users?page=2\nhttps://simple-books-api.glitch.me/books",
|
|
65
|
+
"line": 38
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"keyword": "And ",
|
|
69
|
+
"line": 37,
|
|
70
|
+
"name": "the following endpoint(s) is/are used:",
|
|
71
|
+
"match": {
|
|
72
|
+
"location": "step_definitions/load_test_steps.js:83"
|
|
73
|
+
},
|
|
74
|
+
"result": {
|
|
75
|
+
"status": "passed",
|
|
76
|
+
"duration": 48999
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"arguments": [],
|
|
81
|
+
"keyword": "When ",
|
|
82
|
+
"line": 42,
|
|
83
|
+
"name": "the authentication type is \"none\"",
|
|
84
|
+
"match": {
|
|
85
|
+
"location": "step_definitions/load_test_steps.js:99"
|
|
86
|
+
},
|
|
87
|
+
"result": {
|
|
88
|
+
"status": "passed",
|
|
89
|
+
"duration": 78249
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"arguments": [],
|
|
94
|
+
"keyword": "Then ",
|
|
95
|
+
"line": 43,
|
|
96
|
+
"name": "the API should handle the GET request successfully",
|
|
97
|
+
"match": {
|
|
98
|
+
"location": "step_definitions/load_test_steps.js:134"
|
|
99
|
+
},
|
|
100
|
+
"result": {
|
|
101
|
+
"status": "passed",
|
|
102
|
+
"duration": 5869350583
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"tags": [
|
|
107
|
+
{
|
|
108
|
+
"name": "@loadTest",
|
|
109
|
+
"line": 31
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"type": "scenario"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"description": "",
|
|
116
|
+
"id": "run-load-tests-with-dynamic-get-and-post-body-from-environment-variables-and-json-files;i-run-the-k6-script-for-load-testing-with-dynamic-get-requests",
|
|
117
|
+
"keyword": "Scenario Outline",
|
|
118
|
+
"line": 48,
|
|
119
|
+
"name": "I run the k6 script for load testing with dynamic GET requests",
|
|
120
|
+
"steps": [
|
|
121
|
+
{
|
|
122
|
+
"arguments": [],
|
|
123
|
+
"keyword": "Given ",
|
|
124
|
+
"line": 33,
|
|
125
|
+
"name": "I have a k6 script for GET testing",
|
|
126
|
+
"match": {
|
|
127
|
+
"location": "step_definitions/load_test_steps.js:21"
|
|
128
|
+
},
|
|
129
|
+
"result": {
|
|
130
|
+
"status": "passed",
|
|
131
|
+
"duration": 70459
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"arguments": [
|
|
136
|
+
{
|
|
137
|
+
"rows": [
|
|
138
|
+
{
|
|
139
|
+
"cells": [
|
|
140
|
+
"virtual_users",
|
|
141
|
+
"duration",
|
|
142
|
+
"http_req_failed",
|
|
143
|
+
"http_req_duration",
|
|
144
|
+
"error_rate"
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"cells": [
|
|
149
|
+
"50",
|
|
150
|
+
"10",
|
|
151
|
+
"rate<0.05",
|
|
152
|
+
"p(95)<3000",
|
|
153
|
+
"<error_rate>"
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
"keyword": "When ",
|
|
160
|
+
"line": 34,
|
|
161
|
+
"name": "I run the k6 script with the following configurations:",
|
|
162
|
+
"match": {
|
|
163
|
+
"location": "step_definitions/load_test_steps.js:25"
|
|
164
|
+
},
|
|
165
|
+
"result": {
|
|
166
|
+
"status": "passed",
|
|
167
|
+
"duration": 51750
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"arguments": [
|
|
172
|
+
{
|
|
173
|
+
"content": "/api/users?page=2\nhttps://simple-books-api.glitch.me/books",
|
|
174
|
+
"line": 38
|
|
175
|
+
}
|
|
176
|
+
],
|
|
177
|
+
"keyword": "And ",
|
|
178
|
+
"line": 37,
|
|
179
|
+
"name": "the following endpoint(s) is/are used:",
|
|
180
|
+
"match": {
|
|
181
|
+
"location": "step_definitions/load_test_steps.js:83"
|
|
182
|
+
},
|
|
183
|
+
"result": {
|
|
184
|
+
"status": "passed",
|
|
185
|
+
"duration": 29375
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"arguments": [],
|
|
190
|
+
"keyword": "When ",
|
|
191
|
+
"line": 42,
|
|
192
|
+
"name": "the authentication type is \"none\"",
|
|
193
|
+
"match": {
|
|
194
|
+
"location": "step_definitions/load_test_steps.js:99"
|
|
195
|
+
},
|
|
196
|
+
"result": {
|
|
197
|
+
"status": "passed",
|
|
198
|
+
"duration": 106124
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"arguments": [],
|
|
203
|
+
"keyword": "Then ",
|
|
204
|
+
"line": 43,
|
|
205
|
+
"name": "the API should handle the GET request successfully",
|
|
206
|
+
"match": {
|
|
207
|
+
"location": "step_definitions/load_test_steps.js:134"
|
|
208
|
+
},
|
|
209
|
+
"result": {
|
|
210
|
+
"status": "passed",
|
|
211
|
+
"duration": 11204749374
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
"tags": [
|
|
216
|
+
{
|
|
217
|
+
"name": "@loadTest",
|
|
218
|
+
"line": 31
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
"type": "scenario"
|
|
222
|
+
}
|
|
223
|
+
],
|
|
224
|
+
"id": "run-load-tests-with-dynamic-get-and-post-body-from-environment-variables-and-json-files",
|
|
225
|
+
"line": 1,
|
|
226
|
+
"keyword": "Feature",
|
|
227
|
+
"name": "Run load tests with dynamic GET and POST body from environment variables and JSON files",
|
|
228
|
+
"tags": [],
|
|
229
|
+
"uri": "src/examples/features/loadTestTemplate.feature"
|
|
230
|
+
}
|
|
231
|
+
]
|
|
@@ -4,10 +4,10 @@ const { Given, When, Then } = require("@cucumber/cucumber");
|
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const { execSync } = require("child_process");
|
|
7
|
-
const resolveBody = require("../
|
|
8
|
-
const buildK6Script = require("../
|
|
9
|
-
const generateHeaders = require("../
|
|
10
|
-
const { generateK6Script, runK6Script } = require("../
|
|
7
|
+
const resolveBody = require("../lib/helpers/resolveBody.js");
|
|
8
|
+
const buildK6Script = require("../lib/helpers/buildK6Script.js");
|
|
9
|
+
const generateHeaders = require("../lib/helpers/generateHeaders.js");
|
|
10
|
+
const { generateK6Script, runK6Script } = require("../lib/utils/k6Runner.js");
|
|
11
11
|
require("dotenv").config();
|
|
12
12
|
|
|
13
13
|
// Validate thresholds (e.g., "rate<0.01")
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
import http from 'k6/http';
|
|
3
|
+
import { check } from 'k6';
|
|
4
|
+
|
|
5
|
+
export const options = {
|
|
6
|
+
"vus": 10,
|
|
7
|
+
"duration": "5s",
|
|
8
|
+
"thresholds": {
|
|
9
|
+
"http_req_failed": [
|
|
10
|
+
"rate<0.05"
|
|
11
|
+
],
|
|
12
|
+
"http_req_duration": [
|
|
13
|
+
"p(95)<3000"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default function () {
|
|
19
|
+
|
|
20
|
+
const resolvedUrl0 = "https://grafana.com/api/profile";
|
|
21
|
+
const res0 = http.request("GET", resolvedUrl0, null, {
|
|
22
|
+
headers: {
|
|
23
|
+
"Content-Type": "application/json"
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
console.log(`Response Body for ${resolvedUrl0}: ${res0.body}`);
|
|
27
|
+
check(res0, {
|
|
28
|
+
"status is 2xx": (r) => r.status >= 200 && r.status < 300
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const resolvedUrl1 = "https://reqres.in/api/users?page=2";
|
|
33
|
+
const res1 = http.request("GET", resolvedUrl1, null, {
|
|
34
|
+
headers: {
|
|
35
|
+
"Content-Type": "application/json"
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
console.log(`Response Body for ${resolvedUrl1}: ${res1.body}`);
|
|
39
|
+
check(res1, {
|
|
40
|
+
"status is 2xx": (r) => r.status >= 200 && r.status < 300
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
import http from 'k6/http';
|
|
3
|
+
import { check } from 'k6';
|
|
4
|
+
|
|
5
|
+
export const options = {
|
|
6
|
+
"vus": 10,
|
|
7
|
+
"duration": "5s",
|
|
8
|
+
"thresholds": {
|
|
9
|
+
"http_req_failed": [
|
|
10
|
+
"rate<0.05"
|
|
11
|
+
],
|
|
12
|
+
"http_req_duration": [
|
|
13
|
+
"p(95)<3000"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default function () {
|
|
19
|
+
|
|
20
|
+
const resolvedUrl0 = "https://grafana.com/api/profile";
|
|
21
|
+
const res0 = http.request("GET", resolvedUrl0, null, {
|
|
22
|
+
headers: {
|
|
23
|
+
"Content-Type": "application/json"
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
console.log(`Response Body for ${resolvedUrl0}: ${res0.body}`);
|
|
27
|
+
check(res0, {
|
|
28
|
+
"status is 2xx": (r) => r.status >= 200 && r.status < 300
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const resolvedUrl1 = "https://reqres.in/api/users?page=2";
|
|
33
|
+
const res1 = http.request("GET", resolvedUrl1, null, {
|
|
34
|
+
headers: {
|
|
35
|
+
"Content-Type": "application/json"
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
console.log(`Response Body for ${resolvedUrl1}: ${res1.body}`);
|
|
39
|
+
check(res1, {
|
|
40
|
+
"status is 2xx": (r) => r.status >= 200 && r.status < 300
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
import http from 'k6/http';
|
|
3
|
+
import { check } from 'k6';
|
|
4
|
+
|
|
5
|
+
export const options = {
|
|
6
|
+
"vus": 50,
|
|
7
|
+
"duration": "10s",
|
|
8
|
+
"thresholds": {
|
|
9
|
+
"http_req_failed": [
|
|
10
|
+
"rate<0.05"
|
|
11
|
+
],
|
|
12
|
+
"http_req_duration": [
|
|
13
|
+
"p(95)<3000"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default function () {
|
|
19
|
+
|
|
20
|
+
const resolvedUrl0 = "https://grafana.com/api/profile";
|
|
21
|
+
const res0 = http.request("GET", resolvedUrl0, null, {
|
|
22
|
+
headers: {
|
|
23
|
+
"Content-Type": "application/json"
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
console.log(`Response Body for ${resolvedUrl0}: ${res0.body}`);
|
|
27
|
+
check(res0, {
|
|
28
|
+
"status is 2xx": (r) => r.status >= 200 && r.status < 300
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const resolvedUrl1 = "https://reqres.in/api/users?page=2";
|
|
33
|
+
const res1 = http.request("GET", resolvedUrl1, null, {
|
|
34
|
+
headers: {
|
|
35
|
+
"Content-Type": "application/json"
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
console.log(`Response Body for ${resolvedUrl1}: ${res1.body}`);
|
|
39
|
+
check(res1, {
|
|
40
|
+
"status is 2xx": (r) => r.status >= 200 && r.status < 300
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
package/libs/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// lib/index.js (example with JavaScript)
|
|
2
|
-
const path = require("path");
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Registers the k6-cucumber-steps step definitions with the Cucumber runner.
|
|
6
|
-
* @param projectRootDir The absolute path to the root directory of the user's project.
|
|
7
|
-
*/
|
|
8
|
-
function registerSteps(projectRootDir) {
|
|
9
|
-
// Construct the path to your package's step definitions
|
|
10
|
-
const packageStepsPath = path.resolve(__dirname, "../step_definitions");
|
|
11
|
-
|
|
12
|
-
return [packageStepsPath];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
module.exports = {
|
|
16
|
-
registerSteps,
|
|
17
|
-
buildK6Script: require("./helpers/buildK6Script"),
|
|
18
|
-
generateHeaders: require("./helpers/generateHeaders"),
|
|
19
|
-
resolveBody: require("./helpers/resolveBody"),
|
|
20
|
-
k6Runner: require("./utils/k6Runner"),
|
|
21
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|