Skip to content

Commit 3281932

Browse files
Stephen Parentewebmakersteve
Stephen Parente
authored andcommitted
Use confluent kafka images for e2e
1 parent 415f810 commit 3281932

File tree

3 files changed

+57
-14
lines changed

3 files changed

+57
-14
lines changed

.travis.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ sudo: required
44
node_js:
55
- '4'
66
- '6'
7-
# env:
8-
# - WITH_SASL=0
9-
# - WITH_SASL=1
107
cache:
118
directories:
129
- node_modules
1310
services:
1411
- docker
1512
before_install:
16-
- docker-compose up -d
13+
- ./run_docker.sh
1714
script:
1815
- make lint
1916
- make test

docker-compose.yml

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1+
---
12
zookeeper:
2-
image: wurstmeister/zookeeper
3+
image: confluentinc/cp-zookeeper
34
ports:
4-
- 2181:2181
5+
- "2181:2181"
6+
environment:
7+
ZOOKEEPER_CLIENT_PORT: 2181
8+
ZOOKEEPER_TICK_TIME: 2000
59
kafka:
6-
image: wurstmeister/kafka:0.10.2.1
7-
ports:
8-
- 9092:9092
10+
image: confluentinc/cp-kafka
911
links:
1012
- zookeeper
13+
ports:
14+
- "9092:9092"
1115
environment:
12-
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
13-
KAFKA_CREATE_TOPICS: "test2:1:3,test:1:1,test3:1:1,test4:1:1,test5:1:1,test6:1:1"
14-
KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1
15-
KAFKA_ADVERTISED_PORT: 9092
16-
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
16+
KAFKA_BROKER_ID: 1
17+
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
18+
KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://localhost:9092'
19+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
20+
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0

run_docker.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
COMPOSE_VERSION=$(docker-compose --version)
4+
DOCKER_VERSION=$(docker --version)
5+
6+
# Start the docker compose file
7+
echo "Running docker compose up. Docker version $DOCKER_VERSION. Compose version $COMPOSE_VERSION. "
8+
9+
docker-compose up -d
10+
11+
if [ "$?" == "1" ]; then
12+
echo "Failed to start docker images."
13+
exit 1
14+
fi
15+
16+
# List of topics to create in container
17+
topics=(
18+
"test"
19+
"test2"
20+
"test3"
21+
"test4"
22+
"test5"
23+
"test6"
24+
)
25+
26+
# Run docker-compose exec to make them
27+
for topic in "${topics[@]}"
28+
do
29+
echo "Making topic $topic"
30+
until docker-compose exec kafka \
31+
kafka-topics --create --topic $topic --partitions 1 --replication-factor 1 --if-not-exists --zookeeper zookeeper:2181
32+
do
33+
topic_result="$?"
34+
if [ "$topic_result" == "1" ]; then
35+
echo "Bad status code: $topic_result. Trying again."
36+
else
37+
# If it is some unknown status code, die.
38+
exit 1
39+
fi
40+
done
41+
42+
done

0 commit comments

Comments
 (0)