From 801236b0becd8aac71d606a5842f060f1fb308ad Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Sat, 29 Aug 2015 20:26:36 -0400 Subject: [PATCH] Tests for metadata regenerate MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- configure.ac | 1 + tests/fast_regression | 1 + tests/regression/tools/Makefile.am | 2 +- .../tools/metadata-regen/Makefile.am | 16 ++ .../tools/metadata-regen/test_kernel | 109 +++++++++ .../regression/tools/metadata-regen/test_ust | 208 ++++++++++++++++++ tests/root_regression | 1 + tests/utils/utils.sh | 25 +++ 8 files changed, 362 insertions(+), 1 deletion(-) create mode 100644 tests/regression/tools/metadata-regen/Makefile.am create mode 100755 tests/regression/tools/metadata-regen/test_kernel create mode 100755 tests/regression/tools/metadata-regen/test_ust diff --git a/configure.ac b/configure.ac index 693c456a6..425f536dc 100644 --- a/configure.ac +++ b/configure.ac @@ -821,6 +821,7 @@ AC_CONFIG_FILES([ tests/regression/tools/mi/Makefile tests/regression/tools/wildcard/Makefile tests/regression/tools/crash/Makefile + tests/regression/tools/metadata-regen/Makefile tests/regression/ust/Makefile tests/regression/ust/nprocesses/Makefile tests/regression/ust/high-throughput/Makefile diff --git a/tests/fast_regression b/tests/fast_regression index 7731f5c0c..aa0c04336 100644 --- a/tests/fast_regression +++ b/tests/fast_regression @@ -16,6 +16,7 @@ regression/tools/save-load/test_load regression/tools/mi/test_mi regression/tools/wildcard/test_event_wildcard regression/tools/crash/test_crash +regression/tools/metadata-regen/test_ust regression/ust/before-after/test_before_after regression/ust/buffers-pid/test_buffers_pid regression/ust/multi-session/test_multi_session diff --git a/tests/regression/tools/Makefile.am b/tests/regression/tools/Makefile.am index bae5b909d..6c39c9f18 100644 --- a/tests/regression/tools/Makefile.am +++ b/tests/regression/tools/Makefile.am @@ -1,2 +1,2 @@ SUBDIRS = streaming filtering health tracefile-limits snapshots live exclusion save-load mi \ - wildcard crash + wildcard crash metadata-regen diff --git a/tests/regression/tools/metadata-regen/Makefile.am b/tests/regression/tools/metadata-regen/Makefile.am new file mode 100644 index 000000000..d4a92ebe4 --- /dev/null +++ b/tests/regression/tools/metadata-regen/Makefile.am @@ -0,0 +1,16 @@ +noinst_SCRIPTS = test_ust test_kernel +EXTRA_DIST = test_ust test_kernel + +all-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + cp -f $(srcdir)/$$script $(builddir); \ + done; \ + fi + +clean-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + rm -f $(builddir)/$$script; \ + done; \ + fi diff --git a/tests/regression/tools/metadata-regen/test_kernel b/tests/regression/tools/metadata-regen/test_kernel new file mode 100755 index 000000000..fb9940a82 --- /dev/null +++ b/tests/regression/tools/metadata-regen/test_kernel @@ -0,0 +1,109 @@ +#!/bin/bash +# +# Copyright (C) - 2015 Julien Desfossez +# +# This library is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the Free +# Software Foundation; version 2.1 of the License. +# +# This library 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 Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +TEST_DESC="Streaming - Kernel tracing" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +EVENT_NAME="lttng_test_filter_event" +PID_RELAYD=0 +SESSION_NAME="" + +TRACE_PATH=$(mktemp -d) + +NUM_TESTS=18 + +source $TESTDIR/utils/utils.sh + +# LTTng kernel modules check +out=`ls /lib/modules/$(uname -r)/extra | grep lttng` +if [ -z "$out" ]; then + BAIL_OUT "LTTng modules not detected." +fi + +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 $SESSION_NAME" +} + +function test_kernel_streaming () +{ + diag "Test kernel streaming with metadata regeneration" + lttng_create_session_uri + lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing_ok $SESSION_NAME + echo -n "100" > /proc/lttng-test-filter-event + metadata_regenerate_ok $SESSION_NAME + stop_lttng_tracing_ok $SESSION_NAME + # Validate test + validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* + if [ $? -eq 0 ]; then + # Only delete if successful + rm -rf $TRACE_PATH + else + break + fi + destroy_lttng_session_ok $SESSION_NAME +} + +function test_kernel_local () +{ + diag "Test kernel local with metadata regeneration" + create_lttng_session_ok $SESSION_NAME $TRACE_PATH + lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing_ok $SESSION_NAME + echo -n "100" > /proc/lttng-test-filter-event + metadata_regenerate_ok $SESSION_NAME + stop_lttng_tracing_ok $SESSION_NAME + validate_trace $EVENT_NAME $TRACE_PATH + if [ $? -eq 0 ]; then + # Only delete if successful + rm -rf $TRACE_PATH + fi + destroy_lttng_session_ok $SESSION_NAME +} + +plan_tests $NUM_TESTS + +print_test_banner "$TEST_DESC" + +if [ "$(id -u)" == "0" ]; then + isroot=1 +else + isroot=0 +fi + +skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS || +{ + start_lttng_relayd "-o $TRACE_PATH" + start_lttng_sessiond + modprobe lttng-test + + tests=( test_kernel_streaming test_kernel_local ) + + for fct_test in ${tests[@]}; + do + SESSION_NAME=$(randstring 16 0) + ${fct_test} + done + + rmmod lttng-test + stop_lttng_sessiond + stop_lttng_relayd +} diff --git a/tests/regression/tools/metadata-regen/test_ust b/tests/regression/tools/metadata-regen/test_ust new file mode 100755 index 000000000..fe6ffd8f5 --- /dev/null +++ b/tests/regression/tools/metadata-regen/test_ust @@ -0,0 +1,208 @@ +#!/bin/bash +# +# Copyright (C) - 2015 Julien Desfossez +# +# This library is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the Free +# Software Foundation; version 2.1 of the License. +# +# This library 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 Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +TEST_DESC="Streaming - User space tracing" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +NR_ITER=1 +NR_USEC_WAIT=0 +TESTAPP_PATH="$TESTDIR/utils/testapp" +TESTAPP_NAME="gen-ust-events" +TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" +SESSION_NAME="stream" +EVENT_NAME="tp:tptest" +PID_RELAYD=0 + +TRACE_PATH=$(mktemp -d) + +NUM_TESTS=33 + +source $TESTDIR/utils/utils.sh + +if [ ! -x "$TESTAPP_BIN" ]; then + BAIL_OUT "No UST events binary detected." +fi + +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 lttng_create_session_uri_live +{ + # Create session with default path + $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --live -U net://localhost >/dev/null 2>&1 + ok $? "Create live session" +} + +function enable_channel_per_pid() +{ + sess_name=$1 + channel_name=$2 + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-pid -u $channel_name -s $sess_name >/dev/null 2>&1 + ok $? "Enable channel $channel_name per PID for session $sess_name" +} + +# MUST set TESTDIR before calling those functions + +function test_ust_streaming () +{ + local file_sync_after_first=$(mktemp -u) + local file_sync_before_last=$(mktemp -u) + + diag "Test UST streaming with metadata regeneration" + lttng_create_session_uri + enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME + + $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 & + + start_lttng_tracing_ok $SESSION_NAME + + touch ${file_sync_before_last} + + # Wait for the applications started in background + wait + metadata_regenerate_ok $SESSION_NAME + + stop_lttng_tracing_ok $SESSION_NAME + destroy_lttng_session_ok $SESSION_NAME + # Validate test + validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* + if [ $? -eq 0 ]; then + # Only delete if successful + rm -rf $TRACE_PATH + fi + rm -f ${file_sync_after_first} + rm -f ${file_sync_before_last} +} + +function test_ust_local () +{ + local file_sync_after_first=$(mktemp -u) + local file_sync_before_last=$(mktemp -u) + + diag "Test UST local with metadata regeneration" + create_lttng_session_ok $SESSION_NAME $TRACE_PATH + enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME + + $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 & + + start_lttng_tracing_ok $SESSION_NAME + + touch ${file_sync_before_last} + + # Wait for the applications started in background + wait + metadata_regenerate_ok $SESSION_NAME + + stop_lttng_tracing_ok $SESSION_NAME + destroy_lttng_session_ok $SESSION_NAME + # Validate test + validate_trace $EVENT_NAME $TRACE_PATH + if [ $? -eq 0 ]; then + # Only delete if successful + rm -rf $TRACE_PATH + fi + rm -f ${file_sync_after_first} + rm -f ${file_sync_before_last} +} + +function test_ust_pid () +{ + local file_sync_after_first=$(mktemp -u) + local file_sync_before_last=$(mktemp -u) + + diag "Test UST per-pid with metadata regeneration (expect failure)" + create_lttng_session_ok $SESSION_NAME $TRACE_PATH + enable_channel_per_pid $SESSION_NAME "channel0" + enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0" + + $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 & + + start_lttng_tracing_ok $SESSION_NAME + + touch ${file_sync_before_last} + + # Wait for the applications started in background + wait + metadata_regenerate_fail $SESSION_NAME + + stop_lttng_tracing_ok $SESSION_NAME + destroy_lttng_session_ok $SESSION_NAME + # Validate test + validate_trace $EVENT_NAME $TRACE_PATH + if [ $? -eq 0 ]; then + # Only delete if successful + rm -rf $TRACE_PATH + fi + rm -f ${file_sync_after_first} + rm -f ${file_sync_before_last} +} + +function test_ust_live () +{ + local file_sync_after_first=$(mktemp -u) + local file_sync_before_last=$(mktemp -u) + + diag "Test UST live with metadata regeneration (expect failure)" + lttng_create_session_uri_live $SESSION_NAME $TRACE_PATH + enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME + + $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 & + + start_lttng_tracing_ok $SESSION_NAME + + touch ${file_sync_before_last} + + # Wait for the applications started in background + wait + metadata_regenerate_fail $SESSION_NAME + + stop_lttng_tracing_ok $SESSION_NAME + destroy_lttng_session_ok $SESSION_NAME + # Validate test + validate_trace $EVENT_NAME $TRACE_PATH + if [ $? -eq 0 ]; then + # Only delete if successful + rm -rf $TRACE_PATH + fi + rm -f ${file_sync_after_first} + rm -f ${file_sync_before_last} +} + +plan_tests $NUM_TESTS + +print_test_banner "$TEST_DESC" + +start_lttng_relayd "-o $TRACE_PATH" +start_lttng_sessiond + +tests=( test_ust_streaming test_ust_local test_ust_pid test_ust_live ) + +for fct_test in ${tests[@]}; +do + SESSION_NAME=$(randstring 16 0) + ${fct_test} +done + +stop_lttng_sessiond +stop_lttng_relayd + +exit $out diff --git a/tests/root_regression b/tests/root_regression index 71365759d..869c560cf 100644 --- a/tests/root_regression +++ b/tests/root_regression @@ -12,4 +12,5 @@ regression/tools/filtering/test_invalid_filter regression/tools/filtering/test_unsupported_op regression/tools/filtering/test_valid_filter regression/tools/wildcard/test_event_wildcard +regression/tools/metadata-regen/test_kernel regression/ust/test_event_perf diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index fe834cfaf..854bae5d2 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -1309,3 +1309,28 @@ function validate_trace_empty() ret=$? return $ret } + +function metadata_regenerate () +{ + local expected_to_fail=$1 + local sess_name=$2 + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN metadata regenerate -s $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST + ret=$? + if [[ $expected_to_fail -eq "1" ]]; then + test "$ret" -ne "0" + ok $? "Expected fail on regenerate $sess_name" + else + ok $ret "Metadata regenerate $sess_name" + fi +} + +function metadata_regenerate_ok () +{ + metadata_regenerate 0 "$@" +} + +function metadata_regenerate_fail () +{ + metadata_regenerate 1 "$@" +} -- 2.34.1