Skip to content

Commit 593a838

Browse files
committed
Don't fail the test if bootstrap fails ...
but only if producers and consumers (which must maintain a broker list) fail
1 parent 8a3338a commit 593a838

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

test/basic-with-kafkacat.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ data:
1515
exec >> /tmp/testlog
1616
exec 2>&1
1717
18-
PRODUCE_WAIT=.1
18+
PC_WAIT=.2
1919
MAX_AGE=5
2020
2121
UNIQUE="${HOSTNAME}@$(date -u -Ins)"
2222
2323
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)
24+
sleep $PC_WAIT
25+
LAST=$(tail -n 1 /shared/consumed.tmp)
2626
27-
LAST_TS=$(echo $LAST | awk -F'= ' '{print $1}')
28-
LAST_MSG=$(echo $LAST | awk -F'= ' '{print $2}')
27+
LAST_TS=$(echo $LAST | awk -F';' '{print $1}')
28+
LAST_MSG=$(echo $LAST | awk -F';' '{print $4}')
2929
NOW=$(date -u +%s%3N)
3030
DIFF_S=$((($NOW - $LAST_TS)/1000))
3131
DIFF_MS=$((($NOW - $LAST_TS)%1000))
@@ -45,7 +45,9 @@ data:
4545
fi
4646
4747
# get info about this message
48-
kafkacat -Q -b $BOOTSTRAP -t test-basic-with-kafkacat:0:$LAST_TS
48+
kafkacat -Q -b $BOOTSTRAP -t test-basic-with-kafkacat:0:$LAST_TS || \
49+
echo "At $(date +%FT%H:%M:%S.%3N) bootstrap broker might be down"
50+
# but don't fail the test; producer and consumer should keep going if there are other brokers
4951
5052
# We haven't asserted that the consumer works, so we'll just have to assume that it will exit if it fails
5153
@@ -113,9 +115,11 @@ spec:
113115
- /bin/bash
114116
- -cex
115117
- >
116-
echo "--- start $HOSTNAME $(date --iso-8601='ns' -u) ---" >> /shared/produce.tmp;
118+
echo "--- start $HOSTNAME $(date --iso-8601='ns' -u) ---" >> /shared/produce.tmp
119+
;
117120
tail -f /shared/produce.tmp |
118-
kafkacat -P -b $BOOTSTRAP -t test-basic-with-kafkacat -v -T -d broker;
121+
kafkacat -P -b $BOOTSTRAP -t test-basic-with-kafkacat -v -T -d broker
122+
;
119123
volumeMounts:
120124
- name: config
121125
mountPath: /test
@@ -130,7 +134,9 @@ spec:
130134
- /bin/bash
131135
- -cex
132136
- >
133-
kafkacat -C -b $BOOTSTRAP -t test-basic-with-kafkacat -o -1 -f '[%p,%o] %s\n' -u -d broker;
137+
kafkacat -C -b $BOOTSTRAP -t test-basic-with-kafkacat -o -1 -f '%T;%p;%o;%s\n' -u -d broker |
138+
tee /shared/consumed.tmp
139+
;
134140
volumeMounts:
135141
- name: config
136142
mountPath: /test

0 commit comments

Comments
 (0)