aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStaffan Olsson <staffan@repos.se>2017-07-28 21:23:59 +0200
committerStaffan Olsson <staffan@repos.se>2017-07-28 21:24:11 +0200
commit48bd7c39af657db1338662cf99b5531aac929d1d (patch)
treea5882577cf1577c0413d25e5b5229d8abec257ea
parent454bea4ba2c82ca2e150d076f2355c1110c22136 (diff)
downloadkubernetes-kafka-48bd7c39af657db1338662cf99b5531aac929d1d.tar.gz
kubernetes-kafka-48bd7c39af657db1338662cf99b5531aac929d1d.tar.bz2
kubernetes-kafka-48bd7c39af657db1338662cf99b5531aac929d1d.zip
Now we're on par with the old tests, but automatedtest-driven-kubernetes-concept
-rw-r--r--test/11topic-create-test1.yml25
-rw-r--r--test/12topic-create-test2.yml27
-rw-r--r--test/21consumer-test1.yml24
-rw-r--r--test/31producer-test1.yml24
-rw-r--r--test/99testclient.yml15
-rw-r--r--test/basic-produce-consume.yml89
-rw-r--r--test/test.sh34
7 files changed, 89 insertions, 149 deletions
diff --git a/test/11topic-create-test1.yml b/test/11topic-create-test1.yml
deleted file mode 100644
index 321dc57..0000000
--- a/test/11topic-create-test1.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-apiVersion: batch/v1
-kind: Job
-metadata:
- name: topic-create-test1
- namespace: kafka
-spec:
- template:
- metadata:
- name: topic-create-test1
- spec:
- containers:
- - name: kafka
- image: solsson/kafka:0.11.0.0@sha256:b27560de08d30ebf96d12e74f80afcaca503ad4ca3103e63b1fd43a2e4c976ce
- command:
- - ./bin/kafka-topics.sh
- - --zookeeper
- - zookeeper:2181
- - --create
- - --topic
- - test1
- - --partitions
- - "1"
- - --replication-factor
- - "1"
- restartPolicy: Never
diff --git a/test/12topic-create-test2.yml b/test/12topic-create-test2.yml
deleted file mode 100644
index edbe1df..0000000
--- a/test/12topic-create-test2.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-apiVersion: batch/v1
-kind: Job
-metadata:
- name: topic-create-test2
- namespace: kafka
-spec:
- template:
- metadata:
- name: topic-create-test2
- spec:
- containers:
- - name: kafka
- image: solsson/kafka:0.11.0.0@sha256:b27560de08d30ebf96d12e74f80afcaca503ad4ca3103e63b1fd43a2e4c976ce
- command:
- - ./bin/kafka-topics.sh
- - --zookeeper
- - zookeeper:2181
- - --create
- - --topic
- - test2
- - --partitions
- - "1"
- - --replication-factor
- - "3"
- - --config
- - min.insync.replicas=2
- restartPolicy: Never
diff --git a/test/21consumer-test1.yml b/test/21consumer-test1.yml
deleted file mode 100644
index 43678f8..0000000
--- a/test/21consumer-test1.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-apiVersion: extensions/v1beta1
-kind: Deployment
-metadata:
- name: consumer-test1
- namespace: kafka
-spec:
- replicas: 1
- template:
- metadata:
- labels:
- app: consumer
- scope: test
- topic: test1
- spec:
- containers:
- - name: kafka
- image: solsson/kafka:0.11.0.0@sha256:b27560de08d30ebf96d12e74f80afcaca503ad4ca3103e63b1fd43a2e4c976ce
- command:
- - ./bin/kafka-console-consumer.sh
- - --bootstrap-server
- - kafka-0.broker.kafka.svc.cluster.local:9092,kafka-1.broker.kafka.svc.cluster.local:9092,kafka-2.broker.kafka.svc.cluster.local:9092
- - --topic
- - test1
- - --from-beginning
diff --git a/test/31producer-test1.yml b/test/31producer-test1.yml
deleted file mode 100644
index 354a16a..0000000
--- a/test/31producer-test1.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-apiVersion: batch/v1
-kind: Job
-metadata:
- name: producer-test1
- namespace: kafka
-spec:
- template:
- metadata:
- name: producer-test1
- spec:
- containers:
- - name: kafka
- image: solsson/kafka:0.11.0.0@sha256:b27560de08d30ebf96d12e74f80afcaca503ad4ca3103e63b1fd43a2e4c976ce
- command:
- - /bin/sh
- - -c
- - >
- echo "test1 $(date)"
- |
- ./bin/kafka-console-producer.sh
- --topic test1
- --broker-list kafka-0.broker.kafka.svc.cluster.local:9092,kafka-1.broker.kafka.svc.cluster.local:9092,kafka-2.broker.kafka.svc.cluster.local:9092
- ; sleep 1
- restartPolicy: Never
diff --git a/test/99testclient.yml b/test/99testclient.yml
deleted file mode 100644
index a367004..0000000
--- a/test/99testclient.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-# Kafka image without the service, so you can run ./bin/ stuff
-# kubectl exec -ti testclient -- /bin/bash
-apiVersion: v1
-kind: Pod
-metadata:
- name: testclient
- namespace: kafka
-spec:
- containers:
- - name: kafka
- image: solsson/kafka:0.11.0.0@sha256:b27560de08d30ebf96d12e74f80afcaca503ad4ca3103e63b1fd43a2e4c976ce
- command:
- - sh
- - -c
- - "exec tail -f /dev/null"
diff --git a/test/basic-produce-consume.yml b/test/basic-produce-consume.yml
new file mode 100644
index 0000000..f56a01f
--- /dev/null
+++ b/test/basic-produce-consume.yml
@@ -0,0 +1,89 @@
+---
+kind: ConfigMap
+metadata:
+ name: basic-produce-consume
+ namespace: test-kafka
+apiVersion: v1
+data:
+
+ setup.sh: |-
+ touch /tmp/testlog
+
+ ./bin/kafka-topics.sh --zookeeper $ZOOKEEPER \
+ --create --if-not-exists --topic test-basic-with-kafkacat \
+ --partitions 1 --replication-factor 1
+
+ # Despite the deprecation warning --zookeeper nothing is consumed when using --bootstrap-server
+ ./bin/kafka-console-consumer.sh --zookeeper $ZOOKEEPER --topic test-basic-produce-consume > /tmp/testconsumed &
+
+ tail -f /tmp/testlog
+
+ continue.sh: |-
+ exit 0
+
+ run.sh: |-
+ exec >> /tmp/testlog
+ exec 2>&1
+
+ unique=$(date -Ins)
+
+ echo "Test $unique" | ./bin/kafka-console-producer.sh --broker-list $BOOTSTRAP --topic test-basic-produce-consume
+ echo ""
+ tail -n 1 /tmp/testconsumed | grep $unique
+
+ # How to make this test fail:
+ #apt-get update && apt-get install -y --no-install-recommends procps
+ #pkill java
+
+ exit 0
+
+---
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+ name: basic-produce-consume
+ namespace: test-kafka
+spec:
+ replicas: 1
+ template:
+ metadata:
+ labels:
+ test-target: kafka
+ test-type: readiness
+ spec:
+ containers:
+ - name: testcase
+ image: solsson/kafka:0.11.0.0@sha256:b27560de08d30ebf96d12e74f80afcaca503ad4ca3103e63b1fd43a2e4c976ce
+ env:
+ - name: BOOTSTRAP
+ value: kafka-0.broker.kafka.svc.cluster.local:9092,kafka-1.broker.kafka.svc.cluster.local:9092,kafka-2.broker.kafka.svc.cluster.local:9092
+ - name: ZOOKEEPER
+ value: zookeeper.kafka.svc.cluster.local:2181
+ # Test set up
+ command:
+ - /bin/bash
+ - -e
+ - /test/setup.sh
+ # Test run, again and again
+ readinessProbe:
+ exec:
+ command:
+ - /bin/bash
+ - -e
+ - /test/run.sh
+ # JVM start is slow, can we keep producer started and restore the default preriod 10s?
+ periodSeconds: 30
+ # Test quit on nonzero exit
+ livenessProbe:
+ exec:
+ command:
+ - /bin/bash
+ - -e
+ - /test/continue.sh
+ volumeMounts:
+ - name: config
+ mountPath: /test
+ volumes:
+ - name: config
+ configMap:
+ name: basic-produce-consume
diff --git a/test/test.sh b/test/test.sh
deleted file mode 100644
index bfc4a8f..0000000
--- a/test/test.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-
-# List topics
-kubectl exec testclient -- ./bin/kafka-topics.sh --zookeeper zookeeper:2181 --list
-
-# Create topic
-kubectl exec testclient -- ./bin/kafka-topics.sh --zookeeper zookeeper:2181 --topic test1 --create --partitions 1 --replication-factor 1
-
-# Set one of your terminals to listen to messages on the test topic
-kubectl exec -ti testclient -- ./bin/kafka-console-consumer.sh --zookeeper zookeeper:2181 --topic test1 --from-beginning
-
-# Go ahead and produce messages
-echo "Write a message followed by enter, exit using Ctrl+C"
-kubectl exec -ti testclient -- ./bin/kafka-console-producer.sh --broker-list kafka-0.broker.kafka.svc.cluster.local:9092 --topic test1
-
-# Bootstrap even if two nodes are down (shorter name requires same namespace)
-kubectl exec -ti testclient -- ./bin/kafka-console-producer.sh --broker-list kafka-0.broker:9092,kafka-1.broker:9092,kafka-2.broker:9092 --topic test1
-
-# The following commands run in the pod
-kubectl exec -ti testclient -- /bin/bash
-
-# Topic 2, replicated
-./bin/kafka-topics.sh --zookeeper zookeeper:2181 --describe --topic test2
-
-./bin/kafka-verifiable-consumer.sh \
- --broker-list=kafka-0.broker.kafka.svc.cluster.local:9092,kafka-1.broker.kafka.svc.cluster.local:9092 \
- --topic=test2 --group-id=A --verbose
-
-# If a topic isn't available this producer will tell you
-# WARN Error while fetching metadata with correlation id X : {topicname=LEADER_NOT_AVAILABLE}
-# ... but with current config Kafka will auto-create the topic
-./bin/kafka-verifiable-producer.sh \
- --broker-list=kafka-0.broker.kafka.svc.cluster.local:9092,kafka-1.broker.kafka.svc.cluster.local:9092 \
- --value-prefix=1 --topic=test2 \
- --acks=1 --throughput=1 --max-messages=10