From 0650324df67f06d8c60e74bf3998778aa55389eb Mon Sep 17 00:00:00 2001 From: KJ Tsanaktsidis Date: Thu, 16 Apr 2020 17:24:41 +1000 Subject: [PATCH] Use a docker-compose file to run the tests Also create the topics & other deps inside the test itself. --- docker-compose.yml | 183 +++++++++++++++++++++++++++++++++++++++++++++ functional_test.go | 116 ++++++++++++++++++++++++++++ 2 files changed, 299 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..d09c9676b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,183 @@ +version: '3.7' +services: + zookeeper-1: + image: 'zookeeper:3.6.0' + restart: always + depends_on: ['toxiproxy'] + environment: + ZOO_MY_ID: '1' + ZOO_SERVERS: 'server.1=zookeeper-1:2888:3888;2181 server.2=zookeeper-2:2888:3888;2181 server.3=zookeeper-3:2888:3888;2181 server.4=zookeeper-4:2888:3888;2181 server.5=zookeeper-5:2888:3888;2181' + ZOO_INIT_LIMIT: '10' + ZOO_SYNC_LIMIT: '5' + ZOO_MAX_CLIENT_CONNS: '0' + zookeeper-2: + image: 'zookeeper:3.6.0' + restart: always + depends_on: ['toxiproxy'] + environment: + ZOO_MY_ID: '2' + ZOO_SERVERS: 'server.1=zookeeper-1:2888:3888;2181 server.2=zookeeper-2:2888:3888;2181 server.3=zookeeper-3:2888:3888;2181 server.4=zookeeper-4:2888:3888;2181 server.5=zookeeper-5:2888:3888;2181' + ZOO_INIT_LIMIT: '10' + ZOO_SYNC_LIMIT: '5' + ZOO_MAX_CLIENT_CONNS: '0' + zookeeper-3: + image: 'zookeeper:3.6.0' + restart: always + depends_on: ['toxiproxy'] + environment: + ZOO_MY_ID: '3' + ZOO_SERVERS: 'server.1=zookeeper-1:2888:3888;2181 server.2=zookeeper-2:2888:3888;2181 server.3=zookeeper-3:2888:3888;2181 server.4=zookeeper-4:2888:3888;2181 server.5=zookeeper-5:2888:3888;2181' + ZOO_INIT_LIMIT: '10' + ZOO_SYNC_LIMIT: '5' + ZOO_MAX_CLIENT_CONNS: '0' + zookeeper-4: + image: 'zookeeper:3.6.0' + restart: always + depends_on: ['toxiproxy'] + environment: + ZOO_MY_ID: '4' + ZOO_SERVERS: 'server.1=zookeeper-1:2888:3888;2181 server.2=zookeeper-2:2888:3888;2181 server.3=zookeeper-3:2888:3888;2181 server.4=zookeeper-4:2888:3888;2181 server.5=zookeeper-5:2888:3888;2181' + ZOO_INIT_LIMIT: '10' + ZOO_SYNC_LIMIT: '5' + ZOO_MAX_CLIENT_CONNS: '0' + zookeeper-5: + image: 'zookeeper:3.6.0' + restart: always + depends_on: ['toxiproxy'] + environment: + ZOO_MY_ID: '5' + ZOO_SERVERS: 'server.1=zookeeper-1:2888:3888;2181 server.2=zookeeper-2:2888:3888;2181 server.3=zookeeper-3:2888:3888;2181 server.4=zookeeper-4:2888:3888;2181 server.5=zookeeper-5:2888:3888;2181' + ZOO_INIT_LIMIT: '10' + ZOO_SYNC_LIMIT: '5' + ZOO_MAX_CLIENT_CONNS: '0' + kafka-1: + image: 'bitnami/kafka:2.4.1' + restart: always + depends_on: ['toxiproxy', 'zookeeper-1', 'zookeeper-2', 'zookeeper-3', 'zookeeper-4', 'zookeeper-5'] + network_mode: 'service:toxiproxy' + environment: + KAFKA_CFG_ZOOKEEPER_CONNECT: 'toxiproxy:21801' + ALLOW_PLAINTEXT_LISTENER: 'yes' + KAFKA_CFG_DEFAULT_REPLICATION_FACTOR: '2' + KAFKA_CFG_BROKER_ID: '29091' + KAFKA_CFG_BROKER_RACK: '1' + KAFKA_CFG_LISTENERS: 'PLAINTEXT://:9091' + KAFKA_CFG_ADVERTISED_LISTENERS: 'PLAINTEXT://localhost:29091' + KAFKA_CFG_ZOOKEEPER_SESSION_TIMEOUT_MS: '3000' + KAFKA_CFG_ZOOKEEPER_CONNECTION_TIMEOUT_MS: '3000' + KAFKA_CFG_RESERVED_BROKER_MAX_ID: '100000' + KAFKA_CFG_REPLICA_SELECTOR_CLASS: 'org.apache.kafka.common.replica.RackAwareReplicaSelector' + KAFKA_CFG_DELETE_TOPIC_ENABLE: 'true' + KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: 'false' + kafka-2: + image: 'bitnami/kafka:2.4.1' + restart: always + depends_on: ['toxiproxy', 'zookeeper-1', 'zookeeper-2', 'zookeeper-3', 'zookeeper-4', 'zookeeper-5'] + network_mode: 'service:toxiproxy' + environment: + KAFKA_CFG_ZOOKEEPER_CONNECT: 'toxiproxy:21802' + ALLOW_PLAINTEXT_LISTENER: 'yes' + KAFKA_CFG_DEFAULT_REPLICATION_FACTOR: '2' + KAFKA_CFG_BROKER_ID: '29092' + KAFKA_CFG_BROKER_RACK: '2' + KAFKA_CFG_LISTENERS: 'PLAINTEXT://:9092' + KAFKA_CFG_ADVERTISED_LISTENERS: 'PLAINTEXT://localhost:29092' + KAFKA_CFG_ZOOKEEPER_SESSION_TIMEOUT_MS: '3000' + KAFKA_CFG_ZOOKEEPER_CONNECTION_TIMEOUT_MS: '3000' + KAFKA_CFG_RESERVED_BROKER_MAX_ID: '100000' + KAFKA_CFG_REPLICA_SELECTOR_CLASS: 'org.apache.kafka.common.replica.RackAwareReplicaSelector' + KAFKA_CFG_DELETE_TOPIC_ENABLE: 'true' + KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: 'false' + kafka-3: + image: 'bitnami/kafka:2.4.1' + restart: always + depends_on: ['toxiproxy', 'zookeeper-1', 'zookeeper-2', 'zookeeper-3', 'zookeeper-4', 'zookeeper-5'] + network_mode: 'service:toxiproxy' + environment: + KAFKA_CFG_ZOOKEEPER_CONNECT: 'toxiproxy:21803' + ALLOW_PLAINTEXT_LISTENER: 'yes' + KAFKA_CFG_DEFAULT_REPLICATION_FACTOR: '2' + KAFKA_CFG_BROKER_ID: '29093' + KAFKA_CFG_BROKER_RACK: '3' + KAFKA_CFG_LISTENERS: 'PLAINTEXT://:9093' + KAFKA_CFG_ADVERTISED_LISTENERS: 'PLAINTEXT://localhost:29093' + KAFKA_CFG_ZOOKEEPER_SESSION_TIMEOUT_MS: '3000' + KAFKA_CFG_ZOOKEEPER_CONNECTION_TIMEOUT_MS: '3000' + KAFKA_CFG_RESERVED_BROKER_MAX_ID: '100000' + KAFKA_CFG_REPLICA_SELECTOR_CLASS: 'org.apache.kafka.common.replica.RackAwareReplicaSelector' + KAFKA_CFG_DELETE_TOPIC_ENABLE: 'true' + KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: 'false' + kafka-4: + image: 'bitnami/kafka:2.4.1' + restart: always + depends_on: ['toxiproxy', 'zookeeper-1', 'zookeeper-2', 'zookeeper-3', 'zookeeper-4', 'zookeeper-5'] + network_mode: 'service:toxiproxy' + environment: + KAFKA_CFG_ZOOKEEPER_CONNECT: 'toxiproxy:21804' + ALLOW_PLAINTEXT_LISTENER: 'yes' + KAFKA_CFG_DEFAULT_REPLICATION_FACTOR: '2' + KAFKA_CFG_BROKER_ID: '29094' + KAFKA_CFG_BROKER_RACK: '4' + KAFKA_CFG_LISTENERS: 'PLAINTEXT://:9094' + KAFKA_CFG_ADVERTISED_LISTENERS: 'PLAINTEXT://localhost:29094' + KAFKA_CFG_ZOOKEEPER_SESSION_TIMEOUT_MS: '3000' + KAFKA_CFG_ZOOKEEPER_CONNECTION_TIMEOUT_MS: '3000' + KAFKA_CFG_RESERVED_BROKER_MAX_ID: '100000' + KAFKA_CFG_REPLICA_SELECTOR_CLASS: 'org.apache.kafka.common.replica.RackAwareReplicaSelector' + KAFKA_CFG_DELETE_TOPIC_ENABLE: 'true' + KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: 'false' + kafka-5: + image: 'bitnami/kafka:2.4.1' + restart: always + depends_on: ['toxiproxy', 'zookeeper-1', 'zookeeper-2', 'zookeeper-3', 'zookeeper-4', 'zookeeper-5'] + network_mode: 'service:toxiproxy' + environment: + KAFKA_CFG_ZOOKEEPER_CONNECT: 'toxiproxy:21805' + ALLOW_PLAINTEXT_LISTENER: 'yes' + KAFKA_CFG_DEFAULT_REPLICATION_FACTOR: '2' + KAFKA_CFG_BROKER_ID: '29095' + KAFKA_CFG_BROKER_RACK: '5' + KAFKA_CFG_LISTENERS: 'PLAINTEXT://:9095' + KAFKA_CFG_ADVERTISED_LISTENERS: 'PLAINTEXT://localhost:29095' + KAFKA_CFG_ZOOKEEPER_SESSION_TIMEOUT_MS: '3000' + KAFKA_CFG_ZOOKEEPER_CONNECTION_TIMEOUT_MS: '3000' + KAFKA_CFG_RESERVED_BROKER_MAX_ID: '100000' + KAFKA_CFG_REPLICA_SELECTOR_CLASS: 'org.apache.kafka.common.replica.RackAwareReplicaSelector' + KAFKA_CFG_DELETE_TOPIC_ENABLE: 'true' + KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: 'false' + toxiproxy: + image: 'shopify/toxiproxy:2.1.4' + restart: always + entrypoint: ['/bin/sh', '-c'] + ports: + - '21801:21801' + - '21802:21802' + - '21803:21803' + - '21804:21804' + - '21805:21805' + - '29091:29091' + - '29092:29092' + - '29093:29093' + - '29094:29094' + - '29095:29095' + - '8474:8474' + command: + - | + { + while ! nc -w 1 localhost 8474