forked from dgzlopes/pulpocon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
34 lines (31 loc) · 855 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import http from "k6/http";
import {sleep} from "k6";
const BASE_URL = __ENV.BASE_URL || 'http://localhost:3333';
export let options = {
stages: [
{ duration: "5s", target: 10 },
{ duration: "10s", target: 10 },
{ duration: "5s", target: 0 },
],
thresholds: {
"http_req_duration": ["p(95)<1000"],
},
};
export default function () {
let restrictions = {
maxCaloriesPerSlice: 500,
mustBeVegetarian: false,
excludedIngredients: ["pepperoni"],
excludedTools: ["knife"],
maxNumberOfToppings: 6,
minNumberOfToppings: 2
}
let res = http.post(`${BASE_URL}/api/pizza`, JSON.stringify(restrictions), {
headers: {
'Content-Type': 'application/json',
'X-User-ID': 23423,
},
});
console.log(`${res.json().pizza.name} (${res.json().pizza.ingredients.length} ingredients)`);
sleep(1);
}