Skip to content

Commit

Permalink
Drastically simplify approach
Browse files Browse the repository at this point in the history
  • Loading branch information
itadventurer committed Jun 24, 2019
1 parent cb67d6f commit b69ff5d
Show file tree
Hide file tree
Showing 23 changed files with 96 additions and 148 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
FROM strimzi/kafka:0.11.3-kafka-2.1.0
COPY bin /opt/kafka/bin
ENV KAFKA_VERSION=2.1.0
ENV KAFKA_CLI_DIR=/opt/kafka/bin
ENV PATH=/opt/kafka-toolbox:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
COPY bin /opt/kafka-toolbox
9 changes: 0 additions & 9 deletions bin/kafka-acls

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-acls
9 changes: 0 additions & 9 deletions bin/kafka-broker-api-versions

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-broker-api-versions
8 changes: 0 additions & 8 deletions bin/kafka-configs

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-configs
9 changes: 0 additions & 9 deletions bin/kafka-console-consumer

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-console-consumer
9 changes: 0 additions & 9 deletions bin/kafka-console-producer

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-console-producer
9 changes: 0 additions & 9 deletions bin/kafka-consumer-groups

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-consumer-groups
9 changes: 0 additions & 9 deletions bin/kafka-consumer-perf-test

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-consumer-perf-test
9 changes: 0 additions & 9 deletions bin/kafka-delegation-tokens

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-delegation-tokens
9 changes: 0 additions & 9 deletions bin/kafka-delete-records

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-delete-records
9 changes: 0 additions & 9 deletions bin/kafka-log-dirs

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-log-dirs
11 changes: 0 additions & 11 deletions bin/kafka-preferred-replica-election

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-preferred-replica-election
6 changes: 2 additions & 4 deletions bin/kafka-producer-perf-test
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
PARAMS="$@"
DIR=$( dirname "${BASH_SOURCE[0]}" )
source "$DIR/utils.sh"

PARAMS=$(add_config_from_env "$KAFKA_BOOTSTRAP_SERVERS" "--producer-props" "bootstrap.servers" "$PARAMS")
PARAMS=$(add_tls "$PARAMS" "--producer.config")

exec $KAFKA_CLI_DIR/$(basename $0).sh $PARAMS
TLS_CONFIG_PARAM="--producer.config"
source $(dirname $0)/run-kafka-cli-tool.sh
11 changes: 0 additions & 11 deletions bin/kafka-reassign-partitions

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-reassign-partitions
11 changes: 3 additions & 8 deletions bin/kafka-streams-application-reset
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#!/bin/bash
PARAMS="$@"
DIR=$( dirname "${BASH_SOURCE[0]}" )
source "$DIR/utils.sh"

PARAMS=$(add_bootstrap_servers "$PARAMS" "--broker-list")
PARAMS=$(add_tls "$PARAMS" "--config-file")

exec $KAFKA_CLI_DIR/$(basename $0).sh $PARAMS
BOOTSTRAP_SERVERS_PARAM="--bootstrap-servers"
TLS_CONFIG_PARAM="--command-config"
source $(dirname $0)/run-kafka-cli-tool.sh
3 changes: 0 additions & 3 deletions bin/kafka-topics

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-topics
9 changes: 0 additions & 9 deletions bin/kafka-verifiable-consumer

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-verifiable-consumer
9 changes: 0 additions & 9 deletions bin/kafka-verifiable-producer

This file was deleted.

1 change: 1 addition & 0 deletions bin/kafka-verifiable-producer
4 changes: 4 additions & 0 deletions bin/run-cli-tool-with-kafka-bootstrap-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
BOOTSTRAP_SERVERS_PARAM="--bootstrap-server"
TLS_CONFIG_PARAM="--command-config"
source $(dirname $0)/run-kafka-cli-tool.sh
5 changes: 2 additions & 3 deletions bin/run_kafka_cli_tool → bin/run-cli-tool-with-kafka-broker-list
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ PARAMS="$@"
DIR=$( dirname "${BASH_SOURCE[0]}" )
source "$DIR/utils.sh"

if [ ! -z "$ZOOKEEPER_PARAM" ] ; then
PARAMS=$(add_zookeeper "$PARAMS" "--zookeeper")
fi
PARAMS=$(add_bootstrap_servers "$PARAMS" "--broker-list")
PARAMS=$(add_tls "$PARAMS" "--config-file")

exec $KAFKA_CLI_DIR/$(basename $0).sh $PARAMS
3 changes: 3 additions & 0 deletions bin/run-cli-tool-with-zookeeper
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
ZOOKEEPER_PARAM="--zookeeper"
source $(dirname $0)/run-kafka-cli-tool.sh
24 changes: 24 additions & 0 deletions bin/run-kafka-cli-tool.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
if [ -z "$PARAMS" ] ; then
PARAMS="$@"
fi
DIR=$( dirname "${BASH_SOURCE[0]}" )
source "$DIR/utils.sh"

if [ ! -z "$ZOOKEEPER_PARAM" ] ; then
PARAMS=$(add_zookeeper "$PARAMS" "$ZOOKEEPER_PARAM")
fi

if [ ! -z "$BOOTSTRAP_SERVERS_PARAM" ] ; then
PARAMS=$(add_bootstrap_servers "$PARAMS" "$BOOTSTRAP_SERVERS_PARAM")
fi

if [ ! -z "$TLS_CONFIG_PARAM" ] ; then
PARAMS=$(add_tls "$PARAMS" "$TLS_CONFIG_PARAM")
fi

if [ ! -z "$DEBUG" ] ; then
echo "$KAFKA_CLI_DIR/$(basename $0).sh $PARAMS"
fi

exec $KAFKA_CLI_DIR/$(basename $0).sh $PARAMS
39 changes: 39 additions & 0 deletions bin/test-toolbox.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
red='\033[0;31m'
green='\033[0;32m'
normal='\e[0m'

function test_script {
echo -e -n "Testing $@"
$@ > /tmp/log 2>/tmp/err

echo -e -n "\b"

if [ -z "$(cat /tmp/err)" ] || [ "$(cat /tmp/err)" != "Processed a total of 2 messages\n" ] ; then
echo -e "${bold}${green}${normal}"
else
echo -e "${bold}${red}${normal}"
cat /tmp/err
fi
}

test_script kafka-acls --list
test_script kafka-broker-api-versions
test_script kafka-configs --entity-type topics --describe
test_script kafka-topics --create --topic kafka-toolbox-test --partitions 1 --replication-factor 1
echo -e "foo\nbar" | test_script kafka-console-producer --topic kafka-toolbox-test
test_script kafka-console-consumer --topic kafka-toolbox-test --offset 0 --partition 0 --max-messages 2
test_script kafka-consumer-groups --list
test_script kafka-consumer-perf-test --topic kafka-toolbox-test --messages 2
#test_script kafka-delegation-tokens
#test_script kafka-delete-records
test_script kafka-log-dirs --describe --broker-list 0
test_script kafka-preferred-replica-election
test_script kafka-producer-perf-test --topic kafka-toolbox-test --num-records 10 --record-size 10 --throughput 100
#test_script kafka-reassign-partitions
test_script kafka-streams-application-reset --application-id foo
test_script kafka-verifiable-producer --topic kafka-toolbox-test --max-messages 10
test_script kafka-verifiable-consumer --topic kafka-toolbox-test --max-messages 10 --group-id verifiable-consumer

test_script kafka-topics --delete --topic kafka-toolbox-test
#test_script zookeeper-shell

0 comments on commit b69ff5d

Please sign in to comment.