From: Mathieu Desnoyers Date: Wed, 22 Jan 2014 20:24:33 +0000 (-0500) Subject: Test health: add test_thread_ok X-Git-Tag: v2.5.0-rc1~255 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=de3f672bfce2f25c93b62f7c11f64ae27030c2ed;p=lttng-tools.git Test health: add test_thread_ok Tests sessiond, consumerd (UST+kernel) and relayd health "ok" case in simple scenarios. Signed-off-by: Mathieu Desnoyers Signed-off-by: David Goulet --- diff --git a/tests/regression/test_list.py b/tests/regression/test_list.py index 2a613b92b..21afa1c45 100755 --- a/tests/regression/test_list.py +++ b/tests/regression/test_list.py @@ -100,15 +100,21 @@ Tests = \ # Tools health check tests { + 'bin': "tools/health/health_thread_ok", 'daemon': "test", 'kern': True, + 'name': "Health check - Threads OK", + 'desc': "Verify that health check is OK when running lttng-sessiond, lttng-consumerd, and lttng-relayd", + 'success': 0, 'enabled': True + }, + { 'bin': "tools/health/health_thread_exit", 'daemon': "test", 'kern': True, 'name': "Health check - Thread exit", - 'desc': "Call exit in the various lttng-sessiond threads and ensure that health failure is detected", + 'desc': "Call exit in the various lttng-sessiond, lttng-consumerd, lttng-relayd threads and ensure that health failure is detected", 'success': 0, 'enabled': True }, { 'bin': "tools/health/health_thread_stall", 'daemon': "test", 'kern': True, 'name': "Health check - Thread stall", - 'desc': "Stall the various lttng-sessiond threads and ensure that health failure is detected", + 'desc': "Stall the various lttng-sessiond, lttng-consumerd, lttng-relayd threads and ensure that health failure is detected", 'success': 0, 'enabled': True }, { diff --git a/tests/regression/tools/health/test_thread_ok b/tests/regression/tools/health/test_thread_ok new file mode 100755 index 000000000..59b3f5764 --- /dev/null +++ b/tests/regression/tools/health/test_thread_ok @@ -0,0 +1,150 @@ +#!/bin/bash +# +# Copyright (C) - 2012 Christian Babeux +# Copyright (C) - 2014 Mathieu Desnoyers +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +TEST_DESC="Health check - Thread OK" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +LTTNG_BIN="lttng" +SESSION_NAME="health_thread_ok" +UST_EVENT_NAME="tp:tptest" +KERNEL_EVENT_NAME="sched_switch" +CHANNEL_NAME="testchan" +HEALTH_CHECK_BIN="health_check" +NUM_TESTS=17 +SLEEP_TIME=30 + +source $TESTDIR/utils/utils.sh + +function lttng_create_session_uri +{ + # Create session with default path + $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME \ + -U net://localhost >/dev/null 2>&1 + ok $? "Create session with default path" +} + +function report_errors +{ + # Report health errors + out=$(cat ${STDOUT_PATH} | wc -l) + if [ $out -ne 0 ]; then + fail "Validation failure" + diag "Health returned:" + diag "stdout:" + file=${STDOUT_PATH} + while read line ; do + diag "$line" + done < ${file} + + diag "stderr:" + file=${STDERR_PATH} + while read line ; do + diag "$line" + done < ${file} + else + pass "Validation OK" + fi +} + +function test_thread_ok +{ + diag "Test health OK" + + # Set the socket timeout to 5 so the health check delta is set to 25. + export LTTNG_NETWORK_SOCKET_TIMEOUT=5 + export LTTNG_RELAYD_HEALTH="${HEALTH_PATH}/test-health" + + diag "Only session daemon" + start_lttng_sessiond + + # Check health status + $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH} + report_errors + + diag "With UST consumer daemons" + create_lttng_session_no_output $SESSION_NAME + enable_ust_lttng_event $SESSION_NAME $UST_EVENT_NAME $CHANNEL_NAME + start_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Check health status + $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH} + report_errors + + skip $isroot "Root access is needed. Skipping kernel consumer health check test." "5" || + { + diag "With kernel consumer daemon" + create_lttng_session_no_output $SESSION_NAME + lttng_enable_kernel_event $SESSION_NAME $KERNEL_EVENT_NAME $CHANNEL_NAME + start_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Check health status + $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH} + report_errors + } + + diag "With relay daemon" + + start_lttng_relayd "-o $TRACE_PATH" + # Check health status + $CURDIR/$HEALTH_CHECK_BIN \ + --relayd-path="${LTTNG_RELAYD_HEALTH}" \ + > ${STDOUT_PATH} 2> ${STDERR_PATH} + report_errors + + # Wait + diag "Check after running for 30 seconds" + sleep ${SLEEP_TIME} + + # Check health status + $CURDIR/$HEALTH_CHECK_BIN \ + --relayd-path="${LTTNG_RELAYD_HEALTH}" \ + > ${STDOUT_PATH} 2> ${STDERR_PATH} + report_errors + + stop_lttng_relayd + stop_lttng_sessiond + + unset LTTNG_NETWORK_SOCKET_TIMEOUT + unset LTTNG_RELAYD_HEALTH +} + +plan_tests $NUM_TESTS + +print_test_banner "$TEST_DESC" + +STDOUT_PATH=$(mktemp) +STDERR_PATH=$(mktemp) +TRACE_PATH=$(mktemp -d) +HEALTH_PATH=$(mktemp -d) + +# The manage kernel thread is only spawned if we are root +if [ "$(id -u)" == "0" ]; then + isroot=1 +else + isroot=0 +fi + +test_thread_ok + +rm -rf ${HEALTH_PATH} +rm -rf ${TRACE_PATH} +rm -f ${STDOUT_PATH} +rm -f ${STDERR_PATH}