You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/data/markdown/docs/05 Examples/02 Tutorials/01 Get started with k6/200 Test for performance.md
+25-17Lines changed: 25 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ Thresholds are set in options.
29
29
30
30
```javascript
31
31
exportconstoptions= {
32
-
//define thresholds
32
+
//define thresholds
33
33
thresholds: {
34
34
http_req_failed: ['rate<0.01'], // http errors should be less than 1%
35
35
http_req_duration: ['p(99)<1000'], // 99% of requests should be below 1s
@@ -44,13 +44,13 @@ Add this [`options`](/using-k6/k6-options/) object with thresholds to your scrip
44
44
heightTogglers={[true]}>
45
45
46
46
```javascript
47
-
//Import necessary modules
47
+
//import necessary modules
48
48
import { check } from"k6";
49
49
importhttpfrom"k6/http";
50
50
51
-
//define configuration
51
+
//define configuration
52
52
exportconstoptions= {
53
-
//define thresholds
53
+
//define thresholds
54
54
thresholds: {
55
55
http_req_failed: ['rate<0.01'], // http errors should be less than 1%
56
56
http_req_duration: ["p(99)<1000"], // 99% of requests should be below 1s
@@ -75,7 +75,7 @@ export default function () {
75
75
76
76
// check that response is 200
77
77
check(res, {
78
-
"login response was 200": (res) =>res.status==200,
78
+
"response code was 200": (res) =>res.status==200,
79
79
});
80
80
}
81
81
@@ -133,9 +133,16 @@ Since this is a learning environment, the stages are still quite short.
133
133
Add the following _scenario_ to your options `object` and rerun the test.
134
134
Where the smoke test defined the load in terms of iterations, this configuration uses the [`ramping-vus` executor](/using-k6/scenarios/executors/ramping-vus/) to express load through virtual users and duration.
135
135
136
-
```json
136
+
```javascript
137
+
exportconstoptions= {
138
+
// define thresholds
139
+
thresholds: {
140
+
http_req_failed: ['rate<0.01'], // http errors should be less than 1%
141
+
http_req_duration: ['p(99)<1000'], // 99% of requests should be below 1s
142
+
},
143
+
// define scenarios
137
144
scenarios: {
138
-
//arbitrary name of scenario
145
+
//arbitrary name of scenario
139
146
average_load: {
140
147
executor:"ramping-vus",
141
148
stages: [
@@ -148,6 +155,7 @@ Where the smoke test defined the load in terms of iterations, this configuration
148
155
],
149
156
},
150
157
}
158
+
};
151
159
```
152
160
153
161
Run the test with no command-line flags:
@@ -191,7 +199,7 @@ To do this:
191
199
http_req_duration: ['p(99)<1000'],
192
200
},
193
201
scenarios: {
194
-
//arbitrary name of scenario:
202
+
// define scenarios
195
203
breaking: {
196
204
executor:"ramping-vus",
197
205
stages: [
@@ -217,14 +225,19 @@ Copy and run it with `k6 run api-test.js`.
0 commit comments