set -e
stop_docker() {
docker-compose down
}
start_docker() {
docker-compose pull
docker-compose build kafka
docker-compose up -d zookeeper kafka
./do_until_success "docker-compose logs kafka | grep 'Created topic \"kafka-rust-test\"'"
./do_until_success "docker-compose logs kafka | grep 'Created topic \"kafka-rust-test2\"'"
}
setup() {
(
cd "$(dirname $0)"
stop_docker
start_docker
)
}
teardown() {
(
cd "$(dirname $0)"
stop_docker
)
}
export RUST_TEST_THREADS=1
DEFAULT_VERS='0.8.2.2:0.9.0.1:0.10.2.1:0.11.0.1:1.0.0:3.1.0'
DEFAULT_COMPRESSIONS='NONE:SNAPPY:GZIP'
DEFAULT_SECURES=':secure'
declare SCALA_VERS_0_8_2_2='2.11'
declare SCALA_VERS_0_9_0_1='2.11'
declare SCALA_VERS_0_10_2_1='2.12'
declare SCALA_VERS_0_11_0_1='2.12'
declare SCALA_VERS_1_0_0='2.12'
declare SCALA_VERS_3_1_0='2.13'
scala_version_for_kafka() {
local kv=$(echo $1 | sed 's/\./_/g')
local sv="SCALA_VERS_${kv}"
printf '%s' "${!sv}"
}
vers=$@
if [[ -z "${vers}" ]]; then
vers=$DEFAULT_VERS
fi
if [[ -z "${COMPRESSIONS+x}" ]]; then
COMPRESSIONS=$DEFAULT_COMPRESSIONS
fi
if [[ -z "${SECURES+x}" ]]; then
SECURES=$DEFAULT_SECURES
elif [[ -z "${SECURES}" ]]; then
SECURES=':'
fi
IFS=':'
for ver in $vers; do
for compression in $COMPRESSIONS; do
for secure in $SECURES; do
if [[ ! -z "$secure" ]] && echo $ver | grep '^0.8'; then
echo "Skipping secure test for 0.8 -- unsupported"
continue
fi
export KAFKA_VER=$ver
export KAFKA_CLIENT_COMPRESSION=$compression
export KAFKA_CLIENT_SECURE=$secure
export SCALA_VER=$(scala_version_for_kafka "${ver}")
if [ "x$SCALA_VER" = "x" ] ; then
echo >&2 "Unknown Scala version for Kafka $KAFKA_VER"
exit 1
fi
echo -n "Running tests with KAFKA_VER=$KAFKA_VER, "
echo -n "SCALA_VER=$SCALA_VER, "
echo -n "KAFKA_CLIENT_COMPRESSION=$compression, "
echo "KAFKA_CLIENT_SECURE=$secure"
setup || {
teardown
exit 1
}
cargo test --features integration_tests || {
teardown
exit 1
}
teardown
done
done
done