Test health: add test_thread_ok
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 22 Jan 2014 20:24:33 +0000 (15:24 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 28 Jan 2014 21:20:40 +0000 (16:20 -0500)
Tests sessiond, consumerd (UST+kernel) and relayd health "ok" case in
simple scenarios.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
tests/regression/test_list.py
tests/regression/tools/health/test_thread_ok [new file with mode: 0755]

index 2a613b92bc3337cb8f0513e2a626a5b47107ee3b..21afa1c45d8d17a2de342eb5293d0dc32bb7123c 100755 (executable)
@@ -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 (executable)
index 0000000..59b3f57
--- /dev/null
@@ -0,0 +1,150 @@
+#!/bin/bash
+#
+# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
+# Copyright (C) - 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+#
+# 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}
This page took 0.027895 seconds and 4 git commands to generate.