aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/00namespace.yml5
-rw-r--r--test/11topic-create-test1.yml25
-rw-r--r--test/12topic-create-test2.yml25
-rw-r--r--test/21consumer-test1.yml24
-rw-r--r--test/99testclient.yml15
-rw-r--r--test/basic-produce-consume.yml89
-rw-r--r--test/basic-with-kafkacat.yml103
-rw-r--r--test/test.sh34
8 files changed, 197 insertions, 123 deletions
diff --git a/test/00namespace.yml b/test/00namespace.yml
new file mode 100644
index 0000000..fbb6e0e
--- /dev/null
+++ b/test/00namespace.yml
@@ -0,0 +1,5 @@
+---
+apiVersion: v1
+kind: Namespace
+metadata:
+ name: test-kafka
diff --git a/test/11topic-create-test1.yml b/test/11topic-create-test1.yml
deleted file mode 100644
index fdb805e..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.10.0.1
- 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 45d9881..0000000
--- a/test/12topic-create-test2.yml
+++ /dev/null
@@ -1,25 +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.10.0.1
- command:
- - ./bin/kafka-topics.sh
- - --zookeeper
- - zookeeper:2181
- - --create
- - --topic
- - test2
- - --partitions
- - "1"
- - --replication-factor
- - "3"
- restartPolicy: Never
diff --git a/test/21consumer-test1.yml b/test/21consumer-test1.yml
deleted file mode 100644
index aff5944..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.10.0.1
- command:
- - ./bin/kafka-console-consumer.sh
- - --zookeeper
- - zookeeper:2181
- - --topic
- - test1
- - --from-beginning
diff --git a/test/99testclient.yml b/test/99testclient.yml
deleted file mode 100644
index 3ffa63a..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-persistent:0.10.1@sha256:0719b4688b666490abf4b32a3cc5c5da7bb2d6276b47377b35de5429f783e9c2
- 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..fdacea0
--- /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-produce-consume \
+ --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/basic-with-kafkacat.yml b/test/basic-with-kafkacat.yml
new file mode 100644
index 0000000..a8974e8
--- /dev/null
+++ b/test/basic-with-kafkacat.yml
@@ -0,0 +1,103 @@
+---
+kind: ConfigMap
+metadata:
+ name: basic-with-kafkacat
+ namespace: test-kafka
+apiVersion: v1
+data:
+
+ setup.sh: |-
+ touch /tmp/testlog
+ tail -f /tmp/testlog
+
+ continue.sh: |-
+ exit 0
+
+ run.sh: |-
+ exec >> /tmp/testlog
+ exec 2>&1
+
+ unique=$(date -Ins)
+
+ echo "Test $unique" | kafkacat -P -b $BOOTSTRAP -t test-basic-with-kafkacat -v
+ kafkacat -C -b $BOOTSTRAP -t test-basic-with-kafkacat -o -1 -e | grep $unique
+
+ exit 0
+
+---
+apiVersion: batch/v1
+kind: Job
+metadata:
+ name: basic-with-kafkacat
+ namespace: test-kafka
+spec:
+ template:
+ spec:
+ containers:
+ - name: topic-create
+ image: solsson/kafka:0.11.0.0@sha256:b27560de08d30ebf96d12e74f80afcaca503ad4ca3103e63b1fd43a2e4c976ce
+ command:
+ - ./bin/kafka-topics.sh
+ - --zookeeper
+ - zookeeper.kafka.svc.cluster.local:2181
+ - --create
+ - --if-not-exists
+ - --topic
+ - test-basic-with-kafkacat
+ - --partitions
+ - "1"
+ - --replication-factor
+ - "1"
+ restartPolicy: Never
+---
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+ name: basic-with-kafkacat
+ namespace: test-kafka
+spec:
+ replicas: 1
+ template:
+ metadata:
+ labels:
+ test-target: kafka
+ test-type: readiness
+ spec:
+ containers:
+ - name: testcase
+ # common test images
+ #image: solsson/curl@sha256:8b0927b81d10043e70f3e05e33e36fb9b3b0cbfcbccdb9f04fd53f67a270b874
+ image: solsson/kafkacat@sha256:1266d140c52cb39bf314b6f22b6d7a01c4c9084781bc779fdfade51214a713a8
+ #image: solsson/kubectl-kafkacat@sha256:3715a7ede3f168f677ee6faf311ff6887aff31f660cfeecad5d87b4f18516321
+ 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
+ value: kafka-0.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
+ # 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-with-kafkacat
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