Tests for metadata regenerate
authorJulien Desfossez <jdesfossez@efficios.com>
Sun, 30 Aug 2015 00:26:36 +0000 (20:26 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 14 Mar 2016 16:53:39 +0000 (12:53 -0400)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
tests/fast_regression
tests/regression/tools/Makefile.am
tests/regression/tools/metadata-regen/Makefile.am [new file with mode: 0644]
tests/regression/tools/metadata-regen/test_kernel [new file with mode: 0755]
tests/regression/tools/metadata-regen/test_ust [new file with mode: 0755]
tests/root_regression
tests/utils/utils.sh

index 693c456a620d482e38d28bb84c1b74f43afc490d..425f536dc2062d79c39a62584c78f68f7cb28ced 100644 (file)
@@ -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
index 7731f5c0c008c52a96e84fa0cc2d0c0c5ce5f31b..aa0c0433633819d8561948651f199ba924388ccd 100644 (file)
@@ -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
index bae5b909deb8528700c307a8c9e9983c527460f8..6c39c9f18c68c5f783177bac2e04f8e745c0927f 100644 (file)
@@ -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 (file)
index 0000000..d4a92eb
--- /dev/null
@@ -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 (executable)
index 0000000..fb9940a
--- /dev/null
@@ -0,0 +1,109 @@
+#!/bin/bash
+#
+# Copyright (C) - 2015 Julien Desfossez <jdesfossez@efficios.com>
+#
+# 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 (executable)
index 0000000..fe6ffd8
--- /dev/null
@@ -0,0 +1,208 @@
+#!/bin/bash
+#
+# Copyright (C) - 2015 Julien Desfossez <jdesfossez@efficios.com>
+#
+# 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
index 71365759d2fb3a0a28736616791f094e353a076e..869c560cfdb12c159de94b74023698a15419b0a4 100644 (file)
@@ -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
index fe834cfaf47b1b2c3e394a20e880c987a4f15276..854bae5d2bac49f81fba140e4903e39c3deee1c8 100644 (file)
@@ -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 "$@"
+}
This page took 0.032663 seconds and 4 git commands to generate.