From bdc94ed5075d0a55d8e3b4bb286df0a065e0f33a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Ara=C3=BAjo=20Paes?= <38794747+ricardoapaes@users.noreply.github.com> Date: Wed, 12 May 2021 13:46:29 -0300 Subject: [PATCH] Issue #23 Fixing entrypoint-app (#24) --- .github/workflows/docker-publish-56.yml | 10 +++++++++ .github/workflows/docker-publish-73.yml | 10 +++++++++ .github/workflows/docker-publish-74.yml | 10 +++++++++ .github/workflows/docker-publish-80.yml | 12 +++++++++- k6/README.md | 12 ++++++++++ k6/index.js | 29 +++++++++++++++++++++++++ sh/entrypoint-app | 3 +-- 7 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 k6/README.md create mode 100644 k6/index.js diff --git a/.github/workflows/docker-publish-56.yml b/.github/workflows/docker-publish-56.yml index 49913af..a0a6968 100644 --- a/.github/workflows/docker-publish-56.yml +++ b/.github/workflows/docker-publish-56.yml @@ -57,6 +57,16 @@ jobs: --file docker-compose-56.yml \ down -v + - name: Run tests app + run: | + APP_RUN=$(docker-compose -f docker-compose-56.yml run -w /var/www/ --entrypoint entrypoint-app app echo) + echo "CHAMADA APP: ${APP_RUN}"; + + if [[ ! "${APP_RUN}" =~ "core|56" ]]; then + echo "Chamada APP retornou errado: ${APP_RUN}" + exit 1; + fi + - name: Run tests prod run: | docker-compose \ diff --git a/.github/workflows/docker-publish-73.yml b/.github/workflows/docker-publish-73.yml index 86e559e..c798cd2 100644 --- a/.github/workflows/docker-publish-73.yml +++ b/.github/workflows/docker-publish-73.yml @@ -56,6 +56,16 @@ jobs: --file docker-compose-73.yml \ down -v + - name: Run tests app + run: | + APP_RUN=$(docker-compose -f docker-compose-73.yml run -w /var/www/ --entrypoint entrypoint-app app echo) + echo "CHAMADA APP: ${APP_RUN}"; + + if [[ ! "${APP_RUN}" =~ "core|73" ]]; then + echo "Chamada APP retornou errado: ${APP_RUN}" + exit 1; + fi + - name: Run tests prod run: | docker-compose \ diff --git a/.github/workflows/docker-publish-74.yml b/.github/workflows/docker-publish-74.yml index bae989a..31bc344 100644 --- a/.github/workflows/docker-publish-74.yml +++ b/.github/workflows/docker-publish-74.yml @@ -52,6 +52,16 @@ jobs: docker-compose -f docker-compose-74.yml down -v + - name: Run tests app + run: | + APP_RUN=$(docker-compose -f docker-compose-74.yml run -w /var/www/ --entrypoint entrypoint-app app echo) + echo "CHAMADA APP: ${APP_RUN}"; + + if [[ ! "${APP_RUN}" =~ "core|74" ]]; then + echo "Chamada APP retornou errado: ${APP_RUN}" + exit 1; + fi + - name: Run tests prod run: | docker-compose -f docker-compose-74.yml -f docker-compose.prod.yml up --build -d diff --git a/.github/workflows/docker-publish-80.yml b/.github/workflows/docker-publish-80.yml index 9a968f3..1a203c9 100644 --- a/.github/workflows/docker-publish-80.yml +++ b/.github/workflows/docker-publish-80.yml @@ -51,7 +51,17 @@ jobs: fi docker-compose -f docker-compose-80.yml down -v - + + - name: Run tests app + run: | + APP_RUN=$(docker-compose -f docker-compose-80.yml run -w /var/www/ --entrypoint entrypoint-app app echo) + echo "CHAMADA APP: ${APP_RUN}"; + + if [[ ! "${APP_RUN}" =~ "core|80" ]]; then + echo "Chamada APP retornou errado: ${APP_RUN}" + exit 1; + fi + - name: Run tests prod run: | docker-compose -f docker-compose-80.yml up --build -d diff --git a/k6/README.md b/k6/README.md new file mode 100644 index 0000000..8ea7765 --- /dev/null +++ b/k6/README.md @@ -0,0 +1,12 @@ +# K6.io + +Para rodar os testes iniciar o PHP usando o docker-compose da versão escolhida e executar o k6 como o exemplo abaixo usando o PHP 7.3. + +```shell +docker-compose -f docker-compose-73.yml up --build -d +k6 run -e PHP_VERSION=73 --vus 40 --duration 30s index.js +``` + +Neste exemplo ele irá rodar com 40 conexões simultaneas por 30 segundos. + +Para instalar o k6 seguir os passos no próprio [site](https://k6.io/docs/getting-started/installation/). diff --git a/k6/index.js b/k6/index.js new file mode 100644 index 0000000..4d1fbb9 --- /dev/null +++ b/k6/index.js @@ -0,0 +1,29 @@ +import http from 'k6/http'; +import { check } from 'k6'; +import { Counter } from 'k6/metrics'; + +export const requests = new Counter('http_reqs'); + +export const urlbase = __ENV.URL != null ? __ENV.URL : "http://127.0.0.1/"; +export const phpVersion = __ENV.PHP_VERSION != null ? __ENV.PHP_VERSION : "73"; + +export const options = { + thresholds: { + http_req_duration: ['p(95)<200'], + }, +}; + +export default function () { + const ok = { + 'status is 200': (r) => r.status === 200, + 'response body': (r) => { + if(r.body === undefined || r.body === null) { + return false; + } + + return r.body.indexOf('core|'+phpVersion) !== -1; + }, + }; + + check(http.get(urlbase + ''), ok); +} \ No newline at end of file diff --git a/sh/entrypoint-app b/sh/entrypoint-app index ea4d3ff..ac7f6bf 100644 --- a/sh/entrypoint-app +++ b/sh/entrypoint-app @@ -1,4 +1,3 @@ #!/bin/bash set -e -start-core -"${APP_NAME}" "$@" \ No newline at end of file +start "cli" "${APP_NAME}" "$@" \ No newline at end of file