2021-03-03 18:00:03 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
HBASE_HOST="127.0.0.1"
|
2021-03-04 20:00:10 +00:00
|
|
|
HBASE_PORT=16020
|
2021-03-03 18:24:18 +00:00
|
|
|
ZK_HOST="$HBASE_HOST"
|
2021-03-03 18:00:03 +00:00
|
|
|
ZK_PORT=2181
|
2021-03-04 20:00:10 +00:00
|
|
|
HBASE_TIME_STARTUP=15
|
2021-03-04 23:03:33 +00:00
|
|
|
HBASE_EXPORTER_TIME_STARTUP=60
|
2021-03-03 18:00:03 +00:00
|
|
|
HBASE_VERSION="2.4.1"
|
|
|
|
|
2021-03-03 21:16:55 +00:00
|
|
|
setup_suite() {
|
|
|
|
export JAVA_HOME=${JAVA_HOME:-"/usr/local"}
|
2021-03-04 20:00:10 +00:00
|
|
|
|
|
|
|
# Setup HBase
|
2021-03-03 21:16:55 +00:00
|
|
|
./hbase-setup.sh
|
|
|
|
|
2021-03-04 20:00:10 +00:00
|
|
|
# Run HBase
|
|
|
|
cd hbase
|
|
|
|
printf "Starting HBase in pseudo-distributed mode\n"
|
|
|
|
./bin/hbase-daemon.sh --config conf start master
|
2021-03-03 18:00:03 +00:00
|
|
|
sleep ${HBASE_TIME_STARTUP}
|
2021-03-04 20:00:10 +00:00
|
|
|
|
|
|
|
# Run exporter
|
2021-03-04 23:03:33 +00:00
|
|
|
cd ../../
|
2021-03-04 20:00:10 +00:00
|
|
|
printf "Starting hbase-exporter\n"
|
2021-03-04 23:03:33 +00:00
|
|
|
./hbase-exporter --zookeeper-server=${ZK_SERVER:-"127.0.0.1"} \
|
2021-03-05 00:01:03 +00:00
|
|
|
--hbase-pseudo-distributed=True \
|
|
|
|
--hbase-table="foo" 2>&1 > /dev/null &
|
2021-03-04 20:00:10 +00:00
|
|
|
PID=$!
|
2021-03-03 18:00:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test_hbase_running() {
|
2021-03-04 20:00:10 +00:00
|
|
|
nc -n -w1 ${1:-"127.0.0.1"} ${2:-"16200"}
|
2021-03-03 18:00:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test_hbase_zk_running() {
|
2021-03-04 20:00:10 +00:00
|
|
|
r=`nc -n -w1 ${1:-"127.0.0.1"} ${2:-"2181"} <<END
|
2021-03-03 18:00:03 +00:00
|
|
|
"ruok"
|
|
|
|
END
|
2021-03-04 20:00:10 +00:00
|
|
|
`
|
|
|
|
printf "$r"
|
|
|
|
}
|
|
|
|
|
|
|
|
test_hbase_exporter_up() {
|
|
|
|
nc -nu -w1 ${1:-"127.0.0.1"} ${2:-"9010"} 2>&1 > /dev/null &
|
|
|
|
curl -s http://127.0.0.1:9010 > /dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
test_hbase_exporter_export_zk_live() {
|
2021-03-04 23:03:33 +00:00
|
|
|
sleep $HBASE_EXPORTER_TIME_STARTUP
|
2021-03-04 20:00:10 +00:00
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
2021-03-05 00:01:03 +00:00
|
|
|
test_hbase_exporter_export_hbase_up() {
|
|
|
|
r=$(curl -s http://127.0.0.1:9010 | grep '^hbase_up' | cut -d " " -f2)
|
|
|
|
assert_not_equals "0.0" "$r" "HBase down"
|
|
|
|
}
|
|
|
|
|
|
|
|
test_hbase_exporter_export_zk_connection_count() {
|
|
|
|
r=$(curl -s http://127.0.0.1:9010 | grep '^zookeeper_num_connections' | cut -d " " -f2)
|
|
|
|
assert_not_equals "0.0" "$r" "Zookeeper has no connections"
|
|
|
|
}
|
|
|
|
|
2021-03-04 20:00:10 +00:00
|
|
|
teardown_suite() {
|
|
|
|
kill $PID
|
2021-03-05 00:13:18 +00:00
|
|
|
./tests/hbase/bin/hbase-daemon.sh stop master
|
2021-03-03 18:00:03 +00:00
|
|
|
}
|