Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
# | ||
|
||
# Run builtin unittests | ||
# | ||
|
||
set -e | ||
source helpers.sh | ||
|
||
$KAFKACAT -U |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
# | ||
|
||
set -e | ||
|
||
source helpers.sh | ||
|
||
|
||
# | ||
# Verify that -e (exit on eof) works on both low-level and high-level consumer | ||
# | ||
|
||
|
||
topic=$(make_topic_name) | ||
|
||
# Produce some messages to topic | ||
info "Priming producer for $topic" | ||
seq 1 10 | $KAFKACAT -t $topic | ||
|
||
|
||
# Legacy: Consume messages without -e, should timeout. | ||
info "Legacy consumer without -e" | ||
timeout 5 $KAFKACAT -t $topic -o beginning && \ | ||
FAIL "Legacy consumer without -e should have timed out" | ||
|
||
|
||
# Balanced: Consume messages without -e, should timeout. | ||
info "Balanced consumer without -e" | ||
timeout 10 $KAFKACAT -G $topic -o beginning $topic && \ | ||
"Balanced consumer without -e should have timed out" | ||
|
||
|
||
# Legacy: Consume messages with -e, must not timeout | ||
info "Legacy consumer with -e" | ||
timeout 5 $KAFKACAT -t $topic -o beginning -e || \ | ||
FAIL "Legacy consumer with -e timed out" | ||
|
||
|
||
# Balanced: Consume messages without -e, should timeout. | ||
# FIXME: -e and -G doesn't currently work. | ||
if false; then | ||
info "Balanced consumer with -e" | ||
timeout 10 $KAFKACAT -G ${topic}_new -o beginning -e $topic || \ | ||
FAIL "Balanced consumer with -e timed out" | ||
fi | ||
|
||
PASS | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
# | ||
|
||
set -e | ||
source helpers.sh | ||
|
||
|
||
# | ||
# Verify that single and multi-byte delimiters work. | ||
# | ||
|
||
|
||
topic=$(make_topic_name) | ||
|
||
|
||
|
||
# Multi-byte delimiters, partition 0 | ||
|
||
echo -n "Key1;KeyDel;Value1:MyDilemma::MyDilemma:;KeyDel;Value2:MyDilemma:Key3;KeyDel;:MyDilemma:Value4" | | ||
$KAFKACAT -t $topic -p 0 -K ';KeyDel;' -D ':MyDilemma:' -Z | ||
|
||
|
||
output=$($KAFKACAT -C -t $topic -p 0 -o beginning -e -J | | ||
jq -r '.key + "=" + .payload') | ||
|
||
exp="Key1=Value1 | ||
=Value2 | ||
Key3= | ||
=Value4" | ||
|
||
if [[ $output != $exp ]]; then | ||
echo "FAIL: Expected '$exp', not '$output'" | ||
exit 1 | ||
fi | ||
|
||
|
||
# | ||
# Single-byte delimiters, partition 1 | ||
# | ||
|
||
echo "The First;Message1 | ||
Is The; | ||
;Greatest | ||
For sure" | | ||
$KAFKACAT -t $topic -p 1 -K ';' -Z | ||
|
||
|
||
output=$($KAFKACAT -C -t $topic -p 1 -o beginning -e -J | | ||
jq -r '.key + "=" + .payload') | ||
|
||
exp="The First=Message1 | ||
Is The= | ||
=Greatest | ||
=For sure" | ||
|
||
if [[ $output != $exp ]]; then | ||
echo "FAIL: Expected '$exp', not '$output'" | ||
exit 1 | ||
fi | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
|
||
all: run | ||
|
||
|
||
run: | ||
@(for test in 0[0-9][0-9][0-9]*.sh ; do \ | ||
( ./$$test && \ | ||
echo "=== Test $$test PASSED ===" ) || \ | ||
(echo "=== Test $$test FAILED ===" ; exit 1) ;\ | ||
done) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
These tests assume a cluster is running and the bootstrap.servers | ||
is set in the $BROKERS environment variable. | ||
|
||
The cluster is assumed to have auto topic creation enabled with | ||
a default partition count of at least 3. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
set -e | ||
|
||
CLR_BGRED="\033[37;41m" | ||
CLR_BGGREEN="\033[37;42m" | ||
CLR_INFO="\033[34m" | ||
CLR="\033[0m" | ||
|
||
if [[ -z "$BROKERS" ]]; then | ||
echo -e "${CLR_BGRED}kafkacat tests requires \$BROKERS to be set${CLR}" | ||
exit 1 | ||
fi | ||
|
||
KAFKACAT="../kafkacat -b $BROKERS" | ||
TEST_NAME=$(basename $0 | sed -e 's/\.sh$//') | ||
|
||
function make_topic_name { | ||
local name=$1 | ||
echo "kafkacat_test_$$_${RANDOM}_${TEST_NAME}name" | ||
} | ||
|
||
|
||
|
||
function info { | ||
local str=$1 | ||
echo -e "${CLR_INFO}${TEST_NAME} | $str${CLR}" | ||
} | ||
|
||
function FAIL { | ||
local str=$1 | ||
echo -e "${CLR_BGRED}${TEST_NAME} | TEST FAILED: $str${CLR}" | ||
exit 1 | ||
} | ||
|
||
function PASS { | ||
local str=$1 | ||
echo -e "${CLR_BGGREEN}${TEST_NAME} | TEST PASSED: $str${CLR}" | ||
} |