diff --git a/Makefile b/Makefile index e297b19..83a0bf0 100644 --- a/Makefile +++ b/Makefile @@ -17,9 +17,10 @@ all: protoc -I=/usr/local/include/ --proto_path=. --python_out=$(bindings_path) server/zookeeper/*.proto test: - ./hbase-setup.sh + ./tests/install_bash_unit.sh ./bash_unit ./bash_unit tests/test_hbase_up.sh + ./bash_unit tests/test_hbase_exporter_up.sh clean: rm -rf $(hbase_tmp_path) diff --git a/tests/install_bash_unit.sh b/tests/install_bash_unit.sh old mode 100644 new mode 100755 diff --git a/tests/test_hbase_exporter_up.sh b/tests/test_hbase_exporter_up.sh new file mode 100644 index 0000000..27a4c5f --- /dev/null +++ b/tests/test_hbase_exporter_up.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +setup() { + cd ../ + ./hbase-exporter --zookeeper-server ${ZK_SERVER:-"127.0.0.1:2181"} 2>&1 > /dev/null & + PID=$! + sleep 5 +} + +test_hbase_exporter_up() { + nc -znu -w1 ${1:-"127.0.0.1"} ${2:-"9010"} + curl -s http://127.0.0.1:9010 +} + +test_hbase_exporter_zk_connection() { + r=$(curl -s http://127.0.0.1:9010 | grep '^zookeeper_num_live' | cut -d " " -f2) + assert_not_equals "0.0" "$r" "Zookeeper not live" +} + +teardown() { + kill "$PID" +} diff --git a/tests/test_hbase_up.sh b/tests/test_hbase_up.sh index 583ef5e..2361ce9 100644 --- a/tests/test_hbase_up.sh +++ b/tests/test_hbase_up.sh @@ -7,8 +7,17 @@ ZK_PORT=2181 HBASE_TIME_STARTUP=8 HBASE_VERSION="2.4.1" + +setup_suite() { + export JAVA_HOME=${JAVA_HOME:-"/usr/local"} + PWD=$(pwd) + cd ../ + ./hbase-setup.sh + cd $PWD +} + test_run_hbase() { - cd "../hbase-${HBASE_VERSION}" + cd "hbase-${HBASE_VERSION}" ./bin/hbase-daemon.sh --config conf start $1 sleep ${HBASE_TIME_STARTUP} } @@ -22,5 +31,3 @@ test_hbase_zk_running() { "ruok" END } - -export JAVA_HOME=${JAVA_HOME:-"/usr/local"}