3 IMAGE=juplo/endless-consumer:1.0-SNAPSHOT
5 if [ "$1" = "cleanup" ]
12 docker-compose up -d zookeeper kafka cli
15 $(docker image ls -q $IMAGE) == "" ||
21 echo "Using image existing images:"
22 docker image ls $IMAGE
25 echo "Waiting for the Kafka-Cluster to become ready..."
26 docker-compose exec cli cub kafka-ready -b kafka:9092 1 60 > /dev/null 2>&1 || exit 1
27 docker-compose up setup
30 while ! [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer-1..."; sleep 1; done
31 while ! [[ $(http 0:8082/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer-2..."; sleep 1; done
32 while ! [[ $(http 0:8083/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer-3..."; sleep 1; done
33 while ! [[ $(http 0:8084/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer-4..."; sleep 1; done
34 while ! [[ $(http 0:8085/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer-5..."; sleep 1; done
38 docker-compose exec -T cli bash << 'EOF'
39 echo "Writing poison pill into topic test..."
41 echo 'BOOM!' | kafkacat -P -b kafka:9092 -t test
45 while [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "consumer-1 is still running..."; sleep 1; done
46 while [[ $(http 0:8082/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "consumer-2 is still running..."; sleep 1; done
47 while [[ $(http 0:8083/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "consumer-3 is still running..."; sleep 1; done
48 while [[ $(http 0:8084/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "consumer-4 is still running..."; sleep 1; done
49 while [[ $(http 0:8085/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "consumer-5 is still running..."; sleep 1; done
51 http -v :8081/actuator/health
52 echo "Restarting consumer-1"
53 http -v post :8081/start
55 echo "Waiting for consumer-1 to come up"
56 while ! [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for consumer-1..."; sleep 1; done
57 http -v :8081/actuator/health
59 echo "Waiting for consumer-1 to crash"
60 while [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "consumer-1 is still running..."; sleep 1; done
61 http -v :8081/actuator/health
63 docker-compose stop producer
64 docker-compose logs --tail=10 consumer-1
65 docker-compose logs --tail=10 consumer-2
66 docker-compose logs --tail=10 consumer-3
67 docker-compose logs --tail=10 consumer-4
68 docker-compose logs --tail=10 consumer-5