From 4fc6880c4ef53690a16a63ac1157d0f073ddbb4c Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Sat, 29 Jul 2017 15:54:18 +0200 Subject: Starts a test case for rest-proxy --- test/rest-curl.yml | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 test/rest-curl.yml diff --git a/test/rest-curl.yml b/test/rest-curl.yml new file mode 100644 index 0000000..db5758a --- /dev/null +++ b/test/rest-curl.yml @@ -0,0 +1,117 @@ +--- +kind: ConfigMap +metadata: + name: rest-curl + namespace: test-kafka +apiVersion: v1 +data: + + setup.sh: |- + touch /tmp/testlog + + # Don't complete startup until rest proxy is up and running + curl --retry 10 --retry-delay 30 --retry-connrefused -I $REST; + + + curl -H 'Accept: application/vnd.kafka.v2+json' $REST/topics; + + curl --retry 10 -H 'Accept: application/vnd.kafka.v2+json' $REST/topics/test1; + curl -X POST -H "Content-Type: application/vnd.kafka.json.v2+json" -H "Accept: application/vnd.kafka.v2+json" --data "{\"records\":[{\"value\":\"Test from $HOSTNAME at $(date)\"}]}" $REST/topics/$TOPIC -v; + curl --retry 10 -H 'Accept: application/vnd.kafka.v2+json' $REST/topics/test2; + + curl -X POST -H "Content-Type: application/vnd.kafka.json.v2+json" -H "Accept: application/vnd.kafka.v2+json" --data '{"records":[{"value":{"foo":"bar"}}]}' $REST/topics/$TOPIC -v; + + curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" --data '{"name": "my_consumer_instance", "format": "json", "auto.offset.reset": "earliest"}' $REST/consumers/my_json_consumer -v; + + curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" --data "{\"topics\":[\"$TOPIC\"]}" $REST/consumers/my_json_consumer/instances/my_consumer_instance/subscription -v; + + curl -X GET -H "Accept: application/vnd.kafka.json.v2+json" $REST/consumers/my_json_consumer/instances/my_consumer_instance/records -v; + + curl -X DELETE -H "Content-Type: application/vnd.kafka.v2+json" $REST/consumers/my_json_consumer/instances/my_consumer_instance -v; + + tail -f /tmp/testlog + + continue.sh: |- + exit 0 + + run.sh: |- + exec >> /tmp/testlog + exec 2>&1 + + exit 0 + +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: rest-curl + 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-rest-curl + - --partitions + - "1" + - --replication-factor + - "1" + restartPolicy: Never +--- +apiVersion: apps/v1beta1 +kind: Deployment +metadata: + name: rest-curl + namespace: test-kafka +spec: + replicas: 1 + template: + metadata: + labels: + test-target: kafka + test-type: readiness + spec: + containers: + - name: testcase + image: solsson/curl@sha256:8c0c5d669b3dd67932da934024252af59fb9d0fa0e5118b5a737b35c5e1487bf + env: + - name: REST + value: http://rest.kafka.svc.cluster.local + - name: TOPIC + value: test-rest-curl + # Test set up + command: + - /bin/bash + - -e + - /test/setup.sh + # Test run, again and again + readinessProbe: + exec: + command: + - /bin/bash + - -e + - /test/run.sh + # We haven't worked on timing + periodSeconds: 60 + # Test quit on nonzero exit + livenessProbe: + exec: + command: + - /bin/bash + - -e + - /test/continue.sh + volumeMounts: + - name: config + mountPath: /test + volumes: + - name: config + configMap: + name: rest-curl -- cgit v1.2.3