Skip to content

Commit

Permalink
feat(fvt): add healthcheck, depends_on and --wait
Browse files Browse the repository at this point in the history
Update the docker-compose.yml to include healthchecks for toxiproxy and
kafka and make the FV startup wait for them to become healthy.

Signed-off-by: Dominic Evans <[email protected]>
  • Loading branch information
dnwe committed Aug 17, 2023
1 parent d2dba29 commit 2514400
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/fvt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
- name: Test (Functional)
run: make test_functional
run: |
curl -sSL "https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-$(uname -s)-$(uname -m)" -o /tmp/docker-compose
sudo install -m755 /tmp/docker-compose "$(dirname $(which docker-compose))"
docker-compose --version
make test_functional
60 changes: 60 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ services:
args:
KAFKA_VERSION: ${KAFKA_VERSION:-3.5.1}
SCALA_VERSION: ${SCALA_VERSION:-2.13}
healthcheck:
test: ["CMD", "/opt/kafka-${KAFKA_VERSION:-3.5.1}/bin/kafka-broker-api-versions.sh", "--bootstrap-server=kafka-1:9091"]
interval: 6s
timeout: 5s
retries: 10
start_period: 30s
depends_on:
- zookeeper-1
- zookeeper-2
- zookeeper-3
- toxiproxy
restart: always
environment:
KAFKA_VERSION: ${KAFKA_VERSION:-3.5.1}
Expand All @@ -66,6 +77,17 @@ services:
args:
KAFKA_VERSION: ${KAFKA_VERSION:-3.5.1}
SCALA_VERSION: ${SCALA_VERSION:-2.13}
healthcheck:
test: ["CMD", "/opt/kafka-${KAFKA_VERSION:-3.5.1}/bin/kafka-broker-api-versions.sh", "--bootstrap-server=kafka-2:9091"]
interval: 6s
timeout: 5s
retries: 10
start_period: 30s
depends_on:
- zookeeper-1
- zookeeper-2
- zookeeper-3
- toxiproxy
restart: always
environment:
KAFKA_VERSION: ${KAFKA_VERSION:-3.5.1}
Expand All @@ -91,6 +113,17 @@ services:
args:
KAFKA_VERSION: ${KAFKA_VERSION:-3.5.1}
SCALA_VERSION: ${SCALA_VERSION:-2.13}
healthcheck:
test: ["CMD", "/opt/kafka-${KAFKA_VERSION:-3.5.1}/bin/kafka-broker-api-versions.sh", "--bootstrap-server=kafka-3:9091"]
interval: 6s
timeout: 5s
retries: 10
start_period: 30s
depends_on:
- zookeeper-1
- zookeeper-2
- zookeeper-3
- toxiproxy
restart: always
environment:
KAFKA_VERSION: ${KAFKA_VERSION:-3.5.1}
Expand All @@ -116,6 +149,17 @@ services:
args:
KAFKA_VERSION: ${KAFKA_VERSION:-3.5.1}
SCALA_VERSION: ${SCALA_VERSION:-2.13}
healthcheck:
test: ["CMD", "/opt/kafka-${KAFKA_VERSION:-3.5.1}/bin/kafka-broker-api-versions.sh", "--bootstrap-server=kafka-4:9091"]
interval: 6s
timeout: 5s
retries: 10
start_period: 30s
depends_on:
- zookeeper-1
- zookeeper-2
- zookeeper-3
- toxiproxy
restart: always
environment:
KAFKA_VERSION: ${KAFKA_VERSION:-3.5.1}
Expand All @@ -141,6 +185,17 @@ services:
args:
KAFKA_VERSION: ${KAFKA_VERSION:-3.5.1}
SCALA_VERSION: ${SCALA_VERSION:-2.13}
healthcheck:
test: ["CMD", "/opt/kafka-${KAFKA_VERSION:-3.5.1}/bin/kafka-broker-api-versions.sh", "--bootstrap-server=kafka-5:9091"]
interval: 6s
timeout: 5s
retries: 10
start_period: 30s
depends_on:
- zookeeper-1
- zookeeper-2
- zookeeper-3
- toxiproxy
restart: always
environment:
KAFKA_VERSION: ${KAFKA_VERSION:-3.5.1}
Expand All @@ -160,6 +215,11 @@ services:
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: 'false'
toxiproxy:
image: 'ghcr.io/shopify/toxiproxy:2.4.0'
healthcheck:
test: ["CMD", "/toxiproxy-cli", "l"]
interval: 5s
timeout: 5s
retries: 3
ports:
# The tests themselves actually start the proxies on these ports
- '29091:29091'
Expand Down
3 changes: 2 additions & 1 deletion functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ func prepareDockerTestEnvironment(ctx context.Context, env *testEnvironment) err
env.KafkaVersion = "3.5.1"
}

c := exec.Command("docker-compose", "up", "-d")
// docker-compose v2.17.0 or newer required for `--wait-timeout` support
c := exec.Command("docker-compose", "up", "-d", "--wait", "--wait-timeout", "60")
c.Stdout = os.Stdout
c.Stderr = os.Stderr
c.Env = append(os.Environ(), fmt.Sprintf("KAFKA_VERSION=%s", env.KafkaVersion))
Expand Down

0 comments on commit 2514400

Please sign in to comment.