diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:19:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:19:22 +0000 |
commit | c21c3b0befeb46a51b6bf3758ffa30813bea0ff0 (patch) | |
tree | 9754ff1ca740f6346cf8483ec915d4054bc5da2d /fluent-bit/lib/librdkafka-2.1.0/tests/delete-test-topics.sh | |
parent | Adding upstream version 1.43.2. (diff) | |
download | netdata-c21c3b0befeb46a51b6bf3758ffa30813bea0ff0.tar.xz netdata-c21c3b0befeb46a51b6bf3758ffa30813bea0ff0.zip |
Adding upstream version 1.44.3.upstream/1.44.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'fluent-bit/lib/librdkafka-2.1.0/tests/delete-test-topics.sh')
-rwxr-xr-x | fluent-bit/lib/librdkafka-2.1.0/tests/delete-test-topics.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/fluent-bit/lib/librdkafka-2.1.0/tests/delete-test-topics.sh b/fluent-bit/lib/librdkafka-2.1.0/tests/delete-test-topics.sh new file mode 100755 index 000000000..bc40bf65d --- /dev/null +++ b/fluent-bit/lib/librdkafka-2.1.0/tests/delete-test-topics.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# + +set -e + +if [[ "$1" == "-n" ]]; then + DO_DELETE=0 + shift +else + DO_DELETE=1 +fi + +ZK=$1 +KATOPS=$2 +RE=$3 + +if [[ -z "$ZK" ]]; then + ZK="$ZK_ADDRESS" +fi + +if [[ -z "$KATOPS" ]]; then + if [[ -d "$KAFKA_PATH" ]]; then + KATOPS="$KAFKA_PATH/bin/kafka-topics.sh" + fi +fi + +if [[ -z "$RE" ]]; then + RE="^rdkafkatest_" +fi + +if [[ -z "$KATOPS" ]]; then + echo "Usage: $0 [-n] <zookeeper-address> <kafka-topics.sh> [<topic-name-regex>]" + echo "" + echo "Deletes all topics matching regex $RE" + echo "" + echo " -n - Just collect, dont actually delete anything" + exit 1 +fi + +set -u +echo -n "Collecting list of matching topics... " +TOPICS=$($KATOPS --zookeeper $ZK --list 2>/dev/null | grep "$RE") || true +N_TOPICS=$(echo "$TOPICS" | wc -w) +echo "$N_TOPICS topics found" + + +for t in $TOPICS; do + if [[ $DO_DELETE == 1 ]]; then + echo -n "Deleting topic $t... " + ($KATOPS --zookeeper $ZK --delete --topic "$t" 2>/dev/null && echo "deleted") || echo "failed" + else + echo "Topic $t" + fi +done + +echo "Done" |