@@ -15,15 +15,39 @@ data:
15
15
exec >> /tmp/testlog
16
16
exec 2>&1
17
17
18
- LAST_TS=$(kafkacat -C -b $BOOTSTRAP -t test-basic-with-kafkacat -o -1 -f '%T\n' -c 1 -u)
18
+ PRODUCE_WAIT=.1
19
+ MAX_AGE=5
20
+
21
+ UNIQUE="${HOSTNAME}@$(date -u -Ins)"
22
+
23
+ echo "Test $UNIQUE" >> /shared/produce.tmp
24
+ sleep $PRODUCE_WAIT
25
+ LAST=$(kafkacat -C -b $BOOTSTRAP -t test-basic-with-kafkacat -o -1 -f '%T= %s' -c 1 -u)
26
+
27
+ LAST_TS=$(echo $LAST | awk -F'= ' '{print $1}')
28
+ LAST_MSG=$(echo $LAST | awk -F'= ' '{print $2}')
19
29
NOW=$(date -u +%s%3N)
20
- echo "$NOW ($(date +%FT%H:%M:%S.%3N)):"
21
- echo "$LAST_TS"
22
- echo "$((($NOW - $LAST_TS)/1000)) seconds old"
30
+ DIFF_S=$((($NOW - $LAST_TS)/1000))
31
+ DIFF_MS=$((($NOW - $LAST_TS)%1000))
32
+ #echo "$NOW ($(date +%FT%H:%M:%S.%3N)):"
33
+ #echo "$LAST_TS"
34
+
35
+ if [ $DIFF_S -gt $MAX_AGE ]; then
36
+ echo "Last message is $DIFF_S.$DIFF_MS old:"
37
+ echo "$LAST_MSG"
38
+ exit 10
39
+ fi
23
40
24
- #Q_TS=$(date -u +%s%3N)
25
- Q_TS=$LAST_TS
26
- kafkacat -Q -b $BOOTSTRAP -t test-basic-with-kafkacat:0:$Q_TS
41
+ if [[ "$LAST_MSG" != *"$UNIQUE" ]]; then
42
+ echo "Last message (at $LAST_TS) isn't from this test run ($UNIQUE):"
43
+ echo "$LAST_MSG"
44
+ exit 11
45
+ fi
46
+
47
+ # get info about this message
48
+ kafkacat -Q -b $BOOTSTRAP -t test-basic-with-kafkacat:0:$LAST_TS
49
+
50
+ # We haven't asserted that the consumer works, so we'll just have to assume that it will exit if it fails
27
51
28
52
exit 0
29
53
91
115
- >
92
116
echo "--- start $HOSTNAME $(date --iso-8601='ns' -u) ---" >> /shared/produce.tmp;
93
117
tail -f /shared/produce.tmp |
94
- kafkacat -P -b $BOOTSTRAP -t test-basic-with-kafkacat -v -T;
118
+ kafkacat -P -b $BOOTSTRAP -t test-basic-with-kafkacat -v -T -d broker ;
95
119
volumeMounts :
96
120
- name : config
97
121
mountPath : /test
@@ -106,7 +130,7 @@ spec:
106
130
- /bin/bash
107
131
- -cex
108
132
- >
109
- kafkacat -C -b $BOOTSTRAP -t test-basic-with-kafkacat -o -1 -f '[%p,%o] %s\n' -u
133
+ kafkacat -C -b $BOOTSTRAP -t test-basic-with-kafkacat -o -1 -f '[%p,%o] %s\n' -u -d broker;
110
134
volumeMounts :
111
135
- name : config
112
136
mountPath : /test
@@ -116,7 +140,6 @@ spec:
116
140
image : solsson/kafkacat@sha256:ebebf47061300b14a4b4c2e1e4303ab29f65e4b95d34af1b14bb8f7ec6da7cef
117
141
env :
118
142
- name : BOOTSTRAP
119
- # 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
120
143
value : kafka-0.broker.kafka.svc.cluster.local:9092
121
144
command :
122
145
- /bin/bash
@@ -139,6 +162,8 @@ spec:
139
162
volumeMounts :
140
163
- name : config
141
164
mountPath : /test
165
+ - name : shared
166
+ mountPath : /shared
142
167
volumes :
143
168
- name : config
144
169
configMap :
0 commit comments