tests: Improve tests
This commit is contained in:
parent
bc06db7095
commit
b34e813950
@ -20,57 +20,63 @@ setup_suite() {
|
|||||||
printf "Starting hbase-exporter\n"
|
printf "Starting hbase-exporter\n"
|
||||||
./hbase-exporter --zookeeper-server="${ZK_SERVER:-"127.0.0.1"}" \
|
./hbase-exporter --zookeeper-server="${ZK_SERVER:-"127.0.0.1"}" \
|
||||||
--hbase-pseudo-distributed=True \
|
--hbase-pseudo-distributed=True \
|
||||||
--hbase-table="foo" > /dev/null 2>&1
|
--hbase-table="foo" > /dev/null 2>&1 &
|
||||||
PID=$!
|
PID=$!
|
||||||
printf "Waiting %ss to gather exporter values\n" ${HBASE_EXPORTER_TIME_STARTUP}
|
printf "Waiting %ss to gather exporter values\n" ${HBASE_EXPORTER_TIME_STARTUP}
|
||||||
sleep $HBASE_EXPORTER_TIME_STARTUP
|
sleep $HBASE_EXPORTER_TIME_STARTUP
|
||||||
}
|
}
|
||||||
|
|
||||||
test_hbase_running() {
|
test_hbase_running() {
|
||||||
nc -n -w1 "${1:-"127.0.0.1"}" "${2:-"16010"}"
|
assert "nc -n -w1 \"${1:-\"127.0.0.1\"}\" \"${2:-\"16010\"}\""
|
||||||
}
|
}
|
||||||
|
|
||||||
test_hbase_zk_running() {
|
test_hbase_zk_running() {
|
||||||
r=$(echo ruok | nc -n -w1 "${1:-"127.0.0.1"}" "${2:-"2181"}")
|
r=$(echo ruok | nc -n -w1 "${1:-"127.0.0.1"}" "${2:-"2181"}")
|
||||||
printf "%s" "$r"
|
assert_equals "imok" "$r" "Zookeeper: Unhealthy"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_hbase_exporter_up() {
|
test_hbase_exporter_up() {
|
||||||
nc -nu -w1 "${1:-"127.0.0.1"} ${2:-"9010"}" > /dev/null 2>&1
|
assert "curl -s http://127.0.0.1:9010 > /dev/null" "exporter: Could not GET export via Curl"
|
||||||
curl -s http://127.0.0.1:9010 > /dev/null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test_hbase_exporter_export_zk_live() {
|
test_hbase_exporter_export_zk_live() {
|
||||||
r=$(curl -s http://127.0.0.1:9010 | grep '^zookeeper_num_live' | cut -d " " -f2)
|
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"
|
assert_not_equals "0.0" "$r" "exporter: Zookeeper not live"
|
||||||
|
assert_not_equals "" "$r" "exporter: Zookeeper not live"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_hbase_exporter_export_hbase_up() {
|
test_hbase_exporter_export_hbase_up() {
|
||||||
r=$(curl -s http://127.0.0.1:9010 | grep '^hbase_up' | cut -d " " -f2)
|
r=$(curl -s http://127.0.0.1:9010 | grep '^hbase_up' | cut -d " " -f2)
|
||||||
assert_not_equals "0.0" "$r" "HBase down"
|
assert_not_equals "0.0" "$r" "exporter: HBase down"
|
||||||
|
assert_not_equals "" "$r" "exporter: HBase down"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_hbase_exporter_export_zk_connection_count() {
|
test_hbase_exporter_export_zk_connection_count() {
|
||||||
r=$(curl -s http://127.0.0.1:9010 | grep '^zookeeper_num_connections' | cut -d " " -f2)
|
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"
|
assert_not_equals "0.0" "$r" "exporter: Zookeeper has no connections"
|
||||||
|
assert_not_equals "" "$r" "exporter: Zookeeper has no connections"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_hbase_exporter_export_zk_has_leader() {
|
test_hbase_exporter_export_zk_has_leader() {
|
||||||
r=$(curl -s http://127.0.0.1:9010 | grep '^zookeeper_has_leader' | cut -d " " -f2)
|
r=$(curl -s http://127.0.0.1:9010 | grep '^zookeeper_has_leader' | cut -d " " -f2)
|
||||||
assert_not_equals "0.0" "$r" "Zookeeper has no leader"
|
assert_not_equals "0.0" "$r" "exporer: Zookeeper has no leader"
|
||||||
|
assert_not_equals "" "$r" "exporer: Zookeeper has no leader"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_hbase_exporter_export_regionserver_live() {
|
test_hbase_exporter_export_regionserver_live() {
|
||||||
r=$(curl -s http://127.0.0.1:9010 | grep '^hbase_regionservers_live' | cut -d " " -f2)
|
r=$(curl -s http://127.0.0.1:9010 | grep '^hbase_regionservers_live' | cut -d " " -f2)
|
||||||
assert_not_equals "0.0" "$r" "HBase: No regionservers"
|
assert_not_equals "0.0" "$r" "exporter: HBase - No regionservers"
|
||||||
|
assert_not_equals "" "$r" "exporter: HBase - No regionservers"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_hbase_exporter_export_regionserver_dead() {
|
test_hbase_exporter_export_regionserver_dead() {
|
||||||
r=$(curl -s http://127.0.0.1:9010 | grep '^hbase_regionservers_dead' | cut -d " " -f2)
|
r=$(curl -s http://127.0.0.1:9010 | grep '^hbase_regionservers_dead' | cut -d " " -f2)
|
||||||
assert_equals "0.0" "$r" "HBase: Dead regionservers"
|
assert_equals "0.0" "$r" "exporter: HBase - Dead regionservers"
|
||||||
|
assert_not_equals "" "$r" "exporter: HBase - Dead regionservers"
|
||||||
}
|
}
|
||||||
|
|
||||||
teardown_suite() {
|
teardown_suite() {
|
||||||
|
printf "Stopping hbase-exporter (%s)\n" "$PID"
|
||||||
kill $PID
|
kill $PID
|
||||||
./tests/hbase/bin/hbase-daemon.sh stop master
|
./tests/hbase/bin/hbase-daemon.sh stop master
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user