Skip to content

Commit 4fc6880

Browse files
committed
Starts a test case for rest-proxy
1 parent 8b1ddad commit 4fc6880

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

test/rest-curl.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
kind: ConfigMap
3+
metadata:
4+
name: rest-curl
5+
namespace: test-kafka
6+
apiVersion: v1
7+
data:
8+
9+
setup.sh: |-
10+
touch /tmp/testlog
11+
12+
# Don't complete startup until rest proxy is up and running
13+
curl --retry 10 --retry-delay 30 --retry-connrefused -I $REST;
14+
15+
16+
curl -H 'Accept: application/vnd.kafka.v2+json' $REST/topics;
17+
18+
curl --retry 10 -H 'Accept: application/vnd.kafka.v2+json' $REST/topics/test1;
19+
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;
20+
curl --retry 10 -H 'Accept: application/vnd.kafka.v2+json' $REST/topics/test2;
21+
22+
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;
23+
24+
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;
25+
26+
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;
27+
28+
curl -X GET -H "Accept: application/vnd.kafka.json.v2+json" $REST/consumers/my_json_consumer/instances/my_consumer_instance/records -v;
29+
30+
curl -X DELETE -H "Content-Type: application/vnd.kafka.v2+json" $REST/consumers/my_json_consumer/instances/my_consumer_instance -v;
31+
32+
tail -f /tmp/testlog
33+
34+
continue.sh: |-
35+
exit 0
36+
37+
run.sh: |-
38+
exec >> /tmp/testlog
39+
exec 2>&1
40+
41+
exit 0
42+
43+
---
44+
apiVersion: batch/v1
45+
kind: Job
46+
metadata:
47+
name: rest-curl
48+
namespace: test-kafka
49+
spec:
50+
template:
51+
spec:
52+
containers:
53+
- name: topic-create
54+
image: solsson/kafka:0.11.0.0@sha256:b27560de08d30ebf96d12e74f80afcaca503ad4ca3103e63b1fd43a2e4c976ce
55+
command:
56+
- ./bin/kafka-topics.sh
57+
- --zookeeper
58+
- zookeeper.kafka.svc.cluster.local:2181
59+
- --create
60+
- --if-not-exists
61+
- --topic
62+
- test-rest-curl
63+
- --partitions
64+
- "1"
65+
- --replication-factor
66+
- "1"
67+
restartPolicy: Never
68+
---
69+
apiVersion: apps/v1beta1
70+
kind: Deployment
71+
metadata:
72+
name: rest-curl
73+
namespace: test-kafka
74+
spec:
75+
replicas: 1
76+
template:
77+
metadata:
78+
labels:
79+
test-target: kafka
80+
test-type: readiness
81+
spec:
82+
containers:
83+
- name: testcase
84+
image: solsson/curl@sha256:8c0c5d669b3dd67932da934024252af59fb9d0fa0e5118b5a737b35c5e1487bf
85+
env:
86+
- name: REST
87+
value: http://rest.kafka.svc.cluster.local
88+
- name: TOPIC
89+
value: test-rest-curl
90+
# Test set up
91+
command:
92+
- /bin/bash
93+
- -e
94+
- /test/setup.sh
95+
# Test run, again and again
96+
readinessProbe:
97+
exec:
98+
command:
99+
- /bin/bash
100+
- -e
101+
- /test/run.sh
102+
# We haven't worked on timing
103+
periodSeconds: 60
104+
# Test quit on nonzero exit
105+
livenessProbe:
106+
exec:
107+
command:
108+
- /bin/bash
109+
- -e
110+
- /test/continue.sh
111+
volumeMounts:
112+
- name: config
113+
mountPath: /test
114+
volumes:
115+
- name: config
116+
configMap:
117+
name: rest-curl

0 commit comments

Comments
 (0)