-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ performance 360 - workshop k6
- Loading branch information
1 parent
03684b5
commit 5f79bad
Showing
21 changed files
with
983 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Main Workflow | ||
on: [push] | ||
jobs: | ||
build: | ||
name: Run k6 test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Run k6 local test | ||
uses: grafana/k6-action@v0.3.1 | ||
with: | ||
filename: ./src/thresholds.js |
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,2 @@ | ||
*.html | ||
.vscode |
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 |
---|---|---|
@@ -1 +1,164 @@ | ||
# k6-performance-360 | ||
<p align="center"> | ||
<a href="https://www.twitch.tv/charlyautomatiza"><img alt="Twitch" src="https://img.shields.io/badge/CharlyAutomatiza-Twitch-9146FF.svg" style="max-height: 300px;"></a> | ||
<a href="https://discord.gg/wwM9GwxmRZ"><img alt="Discord" src="https://img.shields.io/discord/944608800361570315" style="max-height: 300px;"></a> | ||
<a href="http://twitter.com/char_automatiza"><img src="https://img.shields.io/badge/@char__automatiza-Twitter-1DA1F2.svg?style=flat" style="max-height: 300px;"></a> | ||
<a href="https://www.youtube.com/c/CharlyAutomatiza?sub_confirmation=1"><img src="https://img.shields.io/badge/CharlyAutomatiza-Youtube-FF0000.svg" style="max-height: 300px;" style="max-height: 300px;"></a> | ||
<a href="https://www.linkedin.com/in/gautocarlos/"><img src="https://img.shields.io/badge/Carlos%20 Gauto-LinkedIn-0077B5.svg" style="max-height: 300px;" style="max-height: 300px;"></a> | ||
</p> | ||
|
||
# Pruebas de Performance con K6 | ||
|
||
Este repositorio contiene scripts de pruebas de rendimiento desarrollados con K6 y una GitHub Actions para la ejecución continua de las pruebas en CI/CD. | ||
|
||
## Contenido | ||
|
||
- [Requisitos](#requisitos) | ||
- [Instalación](#instalación) | ||
- [Ejecución de Pruebas](#ejecución-de-pruebas) | ||
- [GitHub Actions](#github-actions) | ||
- [Licencia](#licencia) | ||
|
||
## Requisitos | ||
|
||
Antes de ejecutar las pruebas, asegúrate de tener [K6](https://grafana.com/docs/k6/latest/) instalado en tu sistema. | ||
Sigue las instrucciones en la [documentación oficial](https://grafana.com/docs/k6/latest/set-up/install-k6/). | ||
|
||
## Instalación | ||
|
||
1. Clone este repositorio en su máquina local: | ||
|
||
```bash | ||
git clone https://github.com/charlyautomatiza/k6-performance-360.git | ||
``` | ||
|
||
2. Navega hasta el directorio del proyecto: | ||
|
||
```bash | ||
cd k6-performance-360 | ||
``` | ||
|
||
## Ejecución de Pruebas | ||
|
||
Para realizar una ejecución local: | ||
|
||
```bash | ||
k6 run ./src/script.js | ||
``` | ||
|
||
Para usar K6 WebDashboard: | ||
|
||
```bash | ||
K6_WEB_DASHBOARD=true k6 run ./src/script.js | ||
``` | ||
|
||
Para guardar el reporte como un archivo HTML, podemos ejecutar el siguiente comando | ||
|
||
```bash | ||
K6_WEB_DASHBOARD=true K6_WEB_DASHBOARD_EXPORT=html-report.html k6 run ./src/script.js | ||
``` | ||
|
||
Para ejecutar un test de browser, podemos ejecutar el siguiente comando: | ||
|
||
```bash | ||
K6_BROWSER_HEADLESS=true k6 run ./src/browser.js | ||
``` | ||
|
||
Observe que la variable de ambiente `K6_BROWSER_HEADLESS` debe ser definida como `true` para ser ejecutada en herramientas de integración contínua. Para ejecución y depuración en local, es útil usar la variable con el valor definido como `false` para ejecutar el browser en primer plano. | ||
|
||
```bash | ||
K6_BROWSER_HEADLESS=false k6 run ./src/browser.js | ||
``` | ||
|
||
### Ejecución externa | ||
|
||
Para probar los ejemplos de ejecución externa deberás tener instalado un cliente http como por ejemplo [Postman](https://www.postman.com/) o [Insomnia](https://insomnia.rest/). | ||
|
||
**Importante**: todos los `cURLs` utilizados pueden ejecutarse desde la línea de comandos o también pueden importarse desde tu cliente de preferencia. | ||
|
||
#### Validar el estado de una ejecución | ||
|
||
Puedes utilizar una request de tipo GET mediante la API de K6 | ||
|
||
```powershell | ||
curl --request GET \ | ||
--url http://localhost:6565/v1/status \ | ||
--header 'Content-Type: application/json' | ||
``` | ||
|
||
#### Pausar una ejecución | ||
|
||
Puedes utilizar una request de tipo PATCH a la API de K6, similar a la siguiente | ||
|
||
```powershell | ||
curl --request PATCH \ | ||
--url http://localhost:6565/v1/status \ | ||
--header 'Content-Type: application/json' \ | ||
--data '{ | ||
"data": { | ||
"attributes": { | ||
"paused": true | ||
}, | ||
"id": "default", | ||
"type": "status" | ||
} | ||
}' | ||
``` | ||
|
||
Se destaca lo siguiente del paso anterior: | ||
|
||
- `paused: true` -> pausa la ejecución. | ||
|
||
#### Reanudar y escalar una ejecución | ||
|
||
Puedes utilizar una request de tipo PATCH a la API de K6, similar a la siguiente | ||
|
||
```powershell | ||
curl --request PATCH \ | ||
--url http://localhost:6565/v1/status \ | ||
--header 'Content-Type: application/json' \ | ||
--data '{ | ||
"data": { | ||
"attributes": { | ||
"paused": false, | ||
"vus": 40 | ||
}, | ||
"id": "default", | ||
"type": "status" | ||
} | ||
}' | ||
``` | ||
|
||
Se destaca lo siguiente del paso anterior: | ||
|
||
- `paused: false` -> Reanuda la ejecución. | ||
- `vus: 40` -> tiene que ser un valor mayor a la cantidad de VUs actual y menor o igual a la cantidad máxima de VUs definida en el script. | ||
|
||
#### Recomendaciones | ||
|
||
Este tipo de ejecución es una opción para simular carga distribuida desde múltiples generadores de , la API de K6 no proporcionará versatilidad para gestionar este tipo de ejecución desde una máquina host. | ||
|
||
Para el caso de que se cuente con infra propia puede ser una opción a ser considerada en combinación, por ejemplo, con el uso e implementación de herramientas como [NGROK](https://ngrok.com/) | ||
|
||
## GitHub Actions | ||
|
||
Este repositorio incluye una GitHub Actions configurada para ejecutar pruebas continuamente en el branch principal. La acción está definida en el archivo [k6-runner.yml](.github/workflows/k6-runner.yml). | ||
|
||
## Extensiones VSCode recomendadas | ||
|
||
- [Conventional Commits for VSCode](https://marketplace.visualstudio.com/items?itemName=vivaxy.vscode-conventional-commits) | ||
|
||
- [GitHub Pull Requests](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github) | ||
|
||
- [Codeium: AI Coding](https://marketplace.visualstudio.com/items?itemName=Codeium.codeium) | ||
|
||
- [SonarLint](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarlint-vscode) | ||
|
||
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) | ||
|
||
- [Thunder Client](https://marketplace.visualstudio.com/items?itemName=rangav.vscode-thunder-client) | ||
|
||
- [Postman](https://marketplace.visualstudio.com/items?itemName=Postman.postman-for-vscode) | ||
|
||
## Licencia | ||
|
||
Este proyecto está bajo la licencia Creative Commons CC0 1.0 Universal. |
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,101 @@ | ||
username | ||
jlidington0 | ||
ashapcott1 | ||
acharnock2 | ||
zbeggin3 | ||
bvivyan4 | ||
pportugal5 | ||
ltoft6 | ||
jfochs7 | ||
eshilliday8 | ||
mstandishbrooks9 | ||
jgotobeda | ||
dcreaseb | ||
ggrahamec | ||
dbarkerd | ||
egartenfelde | ||
srobusf | ||
rtodarog | ||
khatrickh | ||
lgetheni | ||
rheamsj | ||
eblasiakk | ||
slanglandl | ||
sdeardsm | ||
ulabatn | ||
nosanneo | ||
frufflip | ||
jluneyq | ||
tmarchellor | ||
egees | ||
jwalakt | ||
khardimanu | ||
ballingtonv | ||
nbunfordw | ||
ghinkensenx | ||
bmclaey | ||
falansz | ||
sdenziloe10 | ||
sgiuron11 | ||
klarver12 | ||
bskellorne13 | ||
schilde14 | ||
bpanton15 | ||
hbrownlea16 | ||
ageist17 | ||
tjahndel18 | ||
rseabon19 | ||
kclifford1a | ||
rlarkings1b | ||
afenty1c | ||
gtrythall1d | ||
hcristofalo1e | ||
btenwick1f | ||
cwiggans1g | ||
keasby1h | ||
gcubbino1i | ||
rbartul1j | ||
dseverwright1k | ||
ojeans1l | ||
jlagne1m | ||
jrichardes1n | ||
zpaolinelli1o | ||
jgavin1p | ||
dthresher1q | ||
dsaiz1r | ||
falmack1s | ||
mhedau1t | ||
bsawart1u | ||
cczadla1v | ||
dtullis1w | ||
ksemon1x | ||
rvannikov1y | ||
imapston1z | ||
bmacturlough20 | ||
egillani21 | ||
acoffee22 | ||
cvial23 | ||
semmot24 | ||
mbuffy25 | ||
bwarmington26 | ||
sbonsul27 | ||
aodocherty28 | ||
ababar29 | ||
ipasmore2a | ||
tkolodziej2b | ||
cdaintree2c | ||
cbeyne2d | ||
tmatiebe2e | ||
elearmouth2f | ||
apaye2g | ||
mbrunstan2h | ||
fthomassen2i | ||
kcoltman2j | ||
tharkin2k | ||
nlutton2l | ||
lburker2m | ||
lwarby2n | ||
wcoats2o | ||
zrooper2p | ||
vblaker2q | ||
aduguid2r |
Oops, something went wrong.