aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStaffan Olsson <staffan@repos.se>2018-02-01 20:43:47 +0100
committerStaffan Olsson <staffan@repos.se>2018-02-01 20:43:47 +0100
commit4a49ab065e468e251db4c72da98376086a0c520e (patch)
tree46669b3a65ded6598621e947e4b5ef4537535a1d
parent0217312134af922ae16571f737cef5ec3e27cc5e (diff)
downloadkubernetes-kafka-4a49ab065e468e251db4c72da98376086a0c520e.tar.gz
kubernetes-kafka-4a49ab065e468e251db4c72da98376086a0c520e.tar.bz2
kubernetes-kafka-4a49ab065e468e251db4c72da98376086a0c520e.zip
I guess this test could work, but consumer won't alternate for each message
-rw-r--r--kafka/test/consumer-group.yml33
1 files changed, 5 insertions, 28 deletions
diff --git a/kafka/test/consumer-group.yml b/kafka/test/consumer-group.yml
index 4b494eb..e19268e 100644
--- a/kafka/test/consumer-group.yml
+++ b/kafka/test/consumer-group.yml
@@ -16,44 +16,21 @@ data:
exec 2>&1
PC_WAIT=.2
- MAX_AGE=5
UNIQUE="${HOSTNAME}@$(date -u -Ins)"
+ PREVIOUS=$(tail -n 1 /shared/consumed.tmp)
echo "${UNIQUE: -41:5}:Test $UNIQUE" >> /shared/produce.tmp
sleep $PC_WAIT
LAST=$(tail -n 1 /shared/consumed.tmp)
[ -z "$LAST" ] && echo "Nothing consumed" && exit 1
- LAST_TS=$(echo $LAST | awk -F';' '{print $1}')
- [ -z "$LAST_TS" ] && echo "Failed to get timestamp for message: $LAST" && exit 1
- LAST_MSG=$(echo $LAST | awk -F';' '{print $4}')
- NOW=$(date -u +%s%3N)
- DIFF_S=$((($NOW - $LAST_TS)/1000))
- DIFF_MS=$((($NOW - $LAST_TS)%1000))
- #echo "$NOW ($(date +%FT%H:%M:%S.%3N)):"
- #echo "$LAST_TS"
-
- if [ $DIFF_S -gt $MAX_AGE ]; then
- echo "Last message is $DIFF_S.$DIFF_MS old:"
- echo "$LAST_MSG"
+ # should fail if the test has only one replica
+ if (( (N + 1) > M )); then
+ echo "Consumed offset increased from $PREVIOUS to $LAST. Diff should be >1 when there's more than 1 replica in the consumer group."
exit 10
fi
- if [[ "$LAST_MSG" != *"$UNIQUE" ]]; then
- echo "Last message (at $LAST_TS) isn't from this test run ($UNIQUE):"
- echo "$LAST_MSG"
- exit 11
- fi
-
- # get info about this message
- kafkacat -Q -b $BOOTSTRAP -t test-kafkacat-consumergroup:0:$LAST_TS \
- -X socket.timeout.ms=600 -X session.timeout.ms=300 -X request.timeout.ms=50 -X metadata.request.timeout.ms=600
- [ $? -eq 0 ] || echo "At $(date +%FT%H:%M:%S.%3N) bootstrap broker(s) might be down"
- # but don't fail the test; producer and consumer should keep going if there are other brokers
-
- # We haven't asserted that the consumer works, so we'll just have to assume that it will exit if it fails
-
exit 0
quit-on-nonzero-exit.sh: |-
@@ -137,7 +114,7 @@ spec:
- /bin/bash
- -cex
- >
- kafkacat -b $BOOTSTRAP -G test-kafkacat-consumergroup test-kafkacat-consumergroup -f '%T;%k:%p;%o;%s\n' -u -d broker |
+ kafkacat -b $BOOTSTRAP -G test-kafkacat-consumergroup test-kafkacat-consumergroup -f '%o\n' -u -d broker |
tee /shared/consumed.tmp
;
volumeMounts: