Skip to content

Commit

Permalink
Merge pull request #4 from City-of-Helsinki/fix/test_workflow_kafka
Browse files Browse the repository at this point in the history
Fix Kafka configuration in test workflow
  • Loading branch information
laurigates committed Sep 21, 2023
2 parents 1600ba7 + 4dc1e9d commit 5f82814
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/test-endpoint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,39 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
tests:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11" ]
python-version: ["3.9", "3.10", "3.11"]
services:
# Label used to access the service container
kafka:
# Docker Hub image
image: bitnami/kafka:3.4
# Provide the password for postgres
env:
ALLOW_PLAINTEXT_LISTENER: "yes"
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "true"
# Kafka KRaft settings
KAFKA_CFG_NODE_ID: 0
KAFKA_CFG_PROCESS_ROLES: "controller,broker"
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: "0@kafka:9093"
# Listeners
KAFKA_CFG_LISTENERS: "PLAINTEXT://:9092,CONTROLLER://:9093"
KAFKA_CFG_ADVERTISED_LISTENERS: "PLAINTEXT://:9092"
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: "CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT"
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: "CONTROLLER"
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: "PLAINTEXT"
# Set health checks to wait until postgres has started
options: >-
--health-cmd "kafka-topics.sh --bootstrap-server kafka:9092 --topic hc --create --if-not-exists && kafka-topics.sh --bootstrap-server kafka:9092 --topic hc --describe" --health-interval 10s --health-timeout 5s --health-retries 5
--health-cmd "kafka-topics.sh --bootstrap-server kafka:9092 --topic hc --create --if-not-exists && kafka-topics.sh --bootstrap-server kafka:9092 --topic hc --describe"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Tests run directly on the runner so we have to map the port
- 9092:9092
Expand Down Expand Up @@ -71,6 +83,5 @@ jobs:
LOG_LEVEL: "DEBUG"
DEBUG: 1
run: |
uvicorn app:app --host 0.0.0.0 --port 8000 --proxy-headers &
sleep 10 &&
uvicorn app:app --host 0.0.0.0 --port 8000 --proxy-headers &&
pytest -v tests/test_api.py

0 comments on commit 5f82814

Please sign in to comment.