From 4a49ab065e468e251db4c72da98376086a0c520e Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 1 Feb 2018 20:43:47 +0100 Subject: I guess this test could work, but consumer won't alternate for each message --- kafka/test/consumer-group.yml | 33 +++++---------------------------- 1 file 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: -- cgit v1.2.3