-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Daniel González Lopes <[email protected]>
- Loading branch information
Showing
15 changed files
with
664 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,8 @@ build | |
# secrets | ||
.env | ||
|
||
bin | ||
bin | ||
|
||
summary.json | ||
screenshot.png | ||
screenshots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import http from "k6/http"; | ||
import { check, sleep } from "k6"; | ||
|
||
const BASE_URL = __ENV.BASE_URL || 'http://localhost:3333'; | ||
|
||
export const options = { | ||
vus: 5, | ||
duration: '10s', | ||
}; | ||
|
||
export default function () { | ||
let restrictions = { | ||
"maxCaloriesPerSlice": 1000, | ||
"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, | ||
}, | ||
}); | ||
check(res, { "status is 200": (res) => res.status === 200 }); | ||
console.log(`${res.json().pizza.name} (${res.json().pizza.ingredients.length} ingredients)`); | ||
sleep(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import http from "k6/http"; | ||
import { check, sleep } from "k6"; | ||
|
||
const BASE_URL = __ENV.BASE_URL || 'http://localhost:3333'; | ||
|
||
export const options = { | ||
stages: [ | ||
{ duration: '5s', target: 5 }, | ||
{ duration: '10s', target: 5 }, | ||
{ duration: '5s', target: 0 }, | ||
], | ||
}; | ||
|
||
export default function () { | ||
let restrictions = { | ||
"maxCaloriesPerSlice": 1000, | ||
"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, | ||
}, | ||
}); | ||
check(res, { "status is 200": (res) => res.status === 200 }); | ||
console.log(`${res.json().pizza.name} (${res.json().pizza.ingredients.length} ingredients)`); | ||
sleep(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import http from "k6/http"; | ||
import { check, sleep } from "k6"; | ||
|
||
const BASE_URL = __ENV.BASE_URL || 'http://localhost:3333'; | ||
|
||
export const options = { | ||
stages: [ | ||
{ duration: '5s', target: 5 }, | ||
{ duration: '10s', target: 5 }, | ||
{ duration: '5s', target: 0 }, | ||
], | ||
}; | ||
|
||
export function setup() { | ||
let res = http.get(BASE_URL) | ||
if (res.status !== 200) { | ||
throw new Error(`Got unexpected status code ${res.status} when trying to setup. Exiting.`) | ||
} | ||
} | ||
|
||
export default function () { | ||
let restrictions = { | ||
"maxCaloriesPerSlice": 1000, | ||
"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, | ||
}, | ||
}); | ||
check(res, { "status is 200": (res) => res.status === 200 }); | ||
console.log(`${res.json().pizza.name} (${res.json().pizza.ingredients.length} ingredients)`); | ||
sleep(1); | ||
} | ||
|
||
export function teardown(){ | ||
// TODO: Send notification to Slack | ||
console.log("That's all folks!") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import http from "k6/http"; | ||
import { check, sleep } from "k6"; | ||
import { Trend, Counter } from "k6/metrics"; | ||
|
||
const BASE_URL = __ENV.BASE_URL || 'http://localhost:3333'; | ||
|
||
export const options = { | ||
stages: [ | ||
{ duration: '5s', target: 5 }, | ||
{ duration: '10s', target: 5 }, | ||
{ duration: '5s', target: 0 }, | ||
], | ||
}; | ||
|
||
const pizzas = new Counter('quickpizza_number_of_pizzas'); | ||
const ingredients = new Trend('quickpizza_ingredients'); | ||
|
||
export function setup() { | ||
let res = http.get(BASE_URL) | ||
if (res.status !== 200) { | ||
throw new Error(`Got unexpected status code ${res.status} when trying to setup. Exiting.`) | ||
} | ||
} | ||
|
||
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, | ||
}, | ||
}); | ||
check(res, { "status is 200": (res) => res.status === 200 }); | ||
console.log(`${res.json().pizza.name} (${res.json().pizza.ingredients.length} ingredients)`); | ||
pizzas.add(1); | ||
ingredients.add(res.json().pizza.ingredients.length); | ||
sleep(1); | ||
} | ||
|
||
export function teardown(){ | ||
// TODO: Send notification to Slack | ||
console.log("That's all folks!") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import http from "k6/http"; | ||
import { check, sleep } from "k6"; | ||
import { Trend, Counter } from "k6/metrics"; | ||
|
||
const BASE_URL = __ENV.BASE_URL || 'http://localhost:3333'; | ||
|
||
export const options = { | ||
stages: [ | ||
{ duration: '5s', target: 5 }, | ||
{ duration: '10s', target: 5 }, | ||
{ duration: '5s', target: 0 }, | ||
], | ||
thresholds: { | ||
http_req_failed: ['rate<0.01'], | ||
http_req_duration: ['p(95)<500', 'p(99)<1000'], | ||
quickpizza_ingredients: [{ threshold: 'avg<6', abortOnFail: false }], | ||
}, | ||
}; | ||
|
||
const pizzas = new Counter('quickpizza_number_of_pizzas'); | ||
const ingredients = new Trend('quickpizza_ingredients'); | ||
|
||
export function setup() { | ||
let res = http.get(BASE_URL) | ||
if (res.status !== 200) { | ||
throw new Error(`Got unexpected status code ${res.status} when trying to setup. Exiting.`) | ||
} | ||
} | ||
|
||
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, | ||
}, | ||
}); | ||
check(res, { "status is 200": (res) => res.status === 200 }); | ||
console.log(`${res.json().pizza.name} (${res.json().pizza.ingredients.length} ingredients)`); | ||
pizzas.add(1); | ||
ingredients.add(res.json().pizza.ingredients.length); | ||
sleep(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import http from "k6/http"; | ||
import { check, sleep } from "k6"; | ||
import { Trend, Counter } from "k6/metrics"; | ||
|
||
const BASE_URL = __ENV.BASE_URL || 'http://localhost:3333'; | ||
|
||
export const options = { | ||
stages: [ | ||
{ duration: '5s', target: 5 }, | ||
{ duration: '10s', target: 5 }, | ||
{ duration: '5s', target: 0 }, | ||
], | ||
thresholds: { | ||
http_req_failed: ['rate<0.01'], | ||
http_req_duration: ['p(95)<500', 'p(99)<1000'], | ||
quickpizza_ingredients: [{ threshold: 'avg<6', abortOnFail: false }], | ||
}, | ||
}; | ||
|
||
const pizzas = new Counter('quickpizza_number_of_pizzas'); | ||
const ingredients = new Trend('quickpizza_ingredients'); | ||
|
||
export function setup() { | ||
let res = http.get(BASE_URL) | ||
if (res.status !== 200) { | ||
throw new Error(`Got unexpected status code ${res.status} when trying to setup. Exiting.`) | ||
} | ||
} | ||
|
||
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, | ||
}, | ||
}); | ||
check(res, { "status is 200": (res) => res.status === 200 }); | ||
console.log(`${res.json().pizza.name} (${res.json().pizza.ingredients.length} ingredients)`); | ||
pizzas.add(1); | ||
ingredients.add(res.json().pizza.ingredients.length); | ||
sleep(1); | ||
} | ||
|
||
export function handleSummary(data) { | ||
return { | ||
'summary.json': JSON.stringify(data, null, 2), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import http from "k6/http"; | ||
import { check, sleep } from "k6"; | ||
import { Trend, Counter } from "k6/metrics"; | ||
|
||
const BASE_URL = __ENV.BASE_URL || 'http://localhost:3333'; | ||
|
||
export const options = { | ||
scenarios: { | ||
smoke: { | ||
exec: "getPizza", | ||
executor: "constant-vus", | ||
vus: 1, | ||
duration: "10s", | ||
}, | ||
stress: { | ||
exec: "getPizza", | ||
executor: "ramping-vus", | ||
stages: [ | ||
{ duration: '5s', target: 5 }, | ||
{ duration: '10s', target: 5 }, | ||
{ duration: '5s', target: 0 }, | ||
], | ||
gracefulRampDown: "5s", | ||
startTime: "10s", | ||
}, | ||
}, | ||
thresholds: { | ||
http_req_failed: ['rate<0.01'], | ||
http_req_duration: ['p(95)<500', 'p(99)<1000'], | ||
quickpizza_ingredients: [{ threshold: 'avg<6', abortOnFail: false }], | ||
}, | ||
}; | ||
|
||
const pizzas = new Counter('quickpizza_number_of_pizzas'); | ||
const ingredients = new Trend('quickpizza_ingredients'); | ||
|
||
export function setup() { | ||
let res = http.get(BASE_URL) | ||
if (res.status !== 200) { | ||
throw new Error(`Got unexpected status code ${res.status} when trying to setup. Exiting.`) | ||
} | ||
} | ||
|
||
export function getPizza() { | ||
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, | ||
}, | ||
}); | ||
check(res, { "status is 200": (res) => res.status === 200 }); | ||
console.log(`${res.json().pizza.name} (${res.json().pizza.ingredients.length} ingredients)`); | ||
pizzas.add(1); | ||
ingredients.add(res.json().pizza.ingredients.length); | ||
sleep(1); | ||
} | ||
|
||
export function teardown(){ | ||
// TODO: Send notification to Slack | ||
console.log("That's all folks!") | ||
} | ||
|
||
export function handleSummary(data) { | ||
return { | ||
'summary.json': JSON.stringify(data, null, 2), | ||
} | ||
} |
Oops, something went wrong.