From 74648738324c6ed1ea93246670101eb34c936d8b Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sat, 8 Jun 2024 10:30:03 -0700 Subject: [PATCH] Cleaning up a bit and removing the load pieces --- .github/workflows/load.yml | 25 ------ Makefile | 10 ++- config/tarmac-data-manager.json | 40 +++++++++ .../{tarmac-basic.json => tarmac-lookup.json} | 0 config/{tarmac.json => tarmac-monolith.json} | 0 docker-compose.yml | 4 +- load-compose.yml | 4 +- monolith-compose.yml | 86 +++++++++++++++++++ 8 files changed, 139 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/load.yml create mode 100644 config/tarmac-data-manager.json rename config/{tarmac-basic.json => tarmac-lookup.json} (100%) rename config/{tarmac.json => tarmac-monolith.json} (100%) create mode 100644 monolith-compose.yml diff --git a/.github/workflows/load.yml b/.github/workflows/load.yml deleted file mode 100644 index c635e72..0000000 --- a/.github/workflows/load.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: load - -on: - push: - tags: - - v* - branches: - - main - pull_request: -jobs: - load-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup Data Manager - run: | - make build loadtest-setup - - name: Wait for the Service to be ready - run: | - while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/ready)" != "200" ]]; do sleep 5; done - - name: Run Stress Tests - uses: grafana/k6-action@v0.3.1 - with: - filename: tests/k6/script.js - flags: --config tests/k6/stress.json diff --git a/Makefile b/Makefile index afe806f..6424792 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,11 @@ docker-compose: sleep 15 docker compose up data-manager lookup +docker-compose-background: + docker compose up -d mysql redis + sleep 15 + docker compose up -d data-manager lookup + loadtest-setup: docker compose -f load-compose.yml up -d mysql sleep 15 @@ -35,10 +40,13 @@ run: build docker-compose run-nobuild: docker-compose run-background: build docker-compose-background run-stress: build loadtest-setup + sleep 600 k6 run --config tests/k6/stress.json tests/k6/script.js run-soak: build loadtest-setup + sleep 600 k6 run --config tests/k6/soak.json tests/k6/script.js -run-steady: build loadtest-setup +run-steady: build docker-compose-background + sleep 600 k6 run --config tests/k6/steady.json tests/k6/script.js diff --git a/config/tarmac-data-manager.json b/config/tarmac-data-manager.json new file mode 100644 index 0000000..7ebe423 --- /dev/null +++ b/config/tarmac-data-manager.json @@ -0,0 +1,40 @@ +{ + "services": { + "airport-lookup": { + "name": "airport-lookup", + "functions": { + "init": { + "filepath": "/functions/data/init.wasm", + "pool_size": 1 + }, + "load": { + "filepath": "/functions/data/load.wasm", + "pool_size": 1 + }, + "fetch": { + "filepath": "/functions/data/fetch.wasm", + "pool_size": 1 + } + }, + "routes": [ + { + "type": "init", + "function": "init" + }, + { + "type": "scheduled_task", + "function": "load", + "frequency": 300 + }, + { + "type": "function", + "function": "load" + }, + { + "type": "function", + "function": "fetch" + } + ] + } + } +} diff --git a/config/tarmac-basic.json b/config/tarmac-lookup.json similarity index 100% rename from config/tarmac-basic.json rename to config/tarmac-lookup.json diff --git a/config/tarmac.json b/config/tarmac-monolith.json similarity index 100% rename from config/tarmac.json rename to config/tarmac-monolith.json diff --git a/docker-compose.yml b/docker-compose.yml index 6c029f5..6a3c09e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: - "APP_LISTEN_ADDR=0.0.0.0:8080" - "APP_DEBUG=false" - "APP_TRACE=false" - - "APP_WASM_FUNCTION_CONFIG=/config/tarmac-basic.json" + - "APP_WASM_FUNCTION_CONFIG=/config/tarmac-lookup.json" - "APP_ENABLE_SQL=true" - "APP_SQL_TYPE=mysql" - "APP_SQL_DSN=root:example@tcp(mysql:3306)/example" @@ -45,7 +45,7 @@ services: - "APP_LISTEN_ADDR=0.0.0.0:8080" - "APP_DEBUG=false" - "APP_TRACE=false" - - "APP_WASM_FUNCTION_CONFIG=/config/tarmac.json" + - "APP_WASM_FUNCTION_CONFIG=/config/tarmaci-data-manager.json" - "APP_ENABLE_SQL=true" - "APP_SQL_TYPE=mysql" - "APP_SQL_DSN=root:example@tcp(mysql:3306)/example" diff --git a/load-compose.yml b/load-compose.yml index 4a1f593..57f14b0 100644 --- a/load-compose.yml +++ b/load-compose.yml @@ -15,7 +15,7 @@ services: - "APP_LISTEN_ADDR=0.0.0.0:8080" - "APP_DEBUG=false" - "APP_TRACE=false" - - "APP_WASM_FUNCTION_CONFIG=/config/tarmac-basic.json" + - "APP_WASM_FUNCTION_CONFIG=/config/tarmac-lookup.json" - "APP_ENABLE_SQL=true" - "APP_SQL_TYPE=mysql" - "APP_SQL_DSN=root:example@tcp(mysql:3306)/example" @@ -43,7 +43,7 @@ services: - "APP_LISTEN_ADDR=0.0.0.0:8080" - "APP_DEBUG=false" - "APP_TRACE=false" - - "APP_WASM_FUNCTION_CONFIG=/config/tarmac.json" + - "APP_WASM_FUNCTION_CONFIG=/config/tarmac-data-manager.json" - "APP_ENABLE_SQL=true" - "APP_SQL_TYPE=mysql" - "APP_SQL_DSN=root:example@tcp(mysql:3306)/example" diff --git a/monolith-compose.yml b/monolith-compose.yml new file mode 100644 index 0000000..762a518 --- /dev/null +++ b/monolith-compose.yml @@ -0,0 +1,86 @@ +version: '3.8' +services: + lookup: + container_name: lookup + image: madflojo/tarmac:unstable + ports: + - 80:8080 + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/ready"] + interval: 10s + timeout: 5s + retries: 3 + environment: + - "APP_ENABLE_TLS=false" + - "APP_LISTEN_ADDR=0.0.0.0:8080" + - "APP_DEBUG=false" + - "APP_TRACE=false" + - "APP_WASM_FUNCTION_CONFIG=/config/tarmac-monolith.json" + - "APP_ENABLE_SQL=true" + - "APP_SQL_TYPE=mysql" + - "APP_SQL_DSN=root:example@tcp(mysql:3306)/example" + - "APP_ENABLE_KVSTORE=true" + - "APP_KVSTORE_TYPE=redis" + - "APP_REDIS_SERVER=redis:6379" + volumes: + - "./config:/config" + - "./functions/build:/functions" + depends_on: + - mysql + - redis + - grafana + + # Dependencies + mysql: + container_name: mysql + image: bitnami/mysql:latest + restart: unless-stopped + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + interval: 10s + timeout: 5s + retries: 3 + environment: + MYSQL_ROOT_PASSWORD: example + MYSQL_DATABASE: example + ports: + - 3306:3306 + redis: + container_name: redis + image: bitnami/redis:latest + restart: unless-stopped + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 3 + environment: + - ALLOW_EMPTY_PASSWORD=yes + prometheus: + image: prom/prometheus + container_name: prometheus + command: + - '--config.file=/config/prometheus.yml' + ports: + - 9090:9090 + restart: unless-stopped + volumes: + - ./config:/config + - prom_data:/prometheus + grafana: + image: grafana/grafana + container_name: grafana + ports: + - 3000:3000 + restart: unless-stopped + environment: + - GF_SECURITY_ADMIN_PASSWORD=example + volumes: + - ./config/grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml + - ./config/grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml + - ./config/grafana/dashboards:/var/lib/grafana/dashboards + depends_on: + - prometheus + +volumes: + prom_data: