tests: Run relayd-grouping tests by grouping type
[lttng-tools.git] / tests / regression / tools / relayd-grouping / test_ust
index 85d7197e6633e562d52e9139d8d3eb212aff87cc..8e2dca9cccef08696623a5bfcd1c5314d2cdefdf 100755 (executable)
@@ -1,19 +1,8 @@
 #!/bin/bash
 #
-# Copyright (C) 2018 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+# Copyright (C) 2018 Jonathan Rajotte <jonathan.rajotte-julien@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
+# SPDX-License-Identifier: LGPL-2.1-only
 
 TEST_DESC="LTTng relayd filesystem grouping - Userspace tracing"
 
@@ -27,16 +16,10 @@ TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
 EVENT_NAME="tp:tptest"
 CHANNEL_NAME="my_channel"
 
-XSD_PATH=$TESTDIR/../src/common/mi-lttng-3.0.xsd
-
-XML_VALIDATE="$TESTDIR/regression/tools/mi/validate_xml $XSD_PATH"
-XML_EXTRACT="$TESTDIR/regression/tools/mi/extract_xml"
-
 XPATH_CMD_OUTPUT="//lttng:command/lttng:output"
 XPATH_SESSION="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session"
 
-
-NUM_TESTS=688
+NUM_TESTS=254
 
 source "$TESTDIR/utils/utils.sh"
 
@@ -51,14 +34,15 @@ function get_auto_session_name ()
        local lttng_bin=$LTTNG_BIN
 
        LTTNG_BIN="${lttng_bin} --mi xml"
-       OUTPUT_DEST=$(mktemp)
+       OUTPUT_DEST=$(mktemp -t "tmp.${FUNCNAME[0]}_output.XXXXXX")
 
-       list_lttng_with_opts
-       $XML_VALIDATE "$OUTPUT_DEST"
+       list_lttng_ok
+       $MI_VALIDATE "$OUTPUT_DEST"
        ok $? "Valid lttng list XML"
 
        value=$($XML_EXTRACT "$OUTPUT_DEST" ${XPATH_SESSION}/lttng:name/text\(\))
        ok $? "Extraction of session name"
+       rm -f $OUTPUT_DEST
        OUTPUT_DEST=/dev/null
        LTTNG_BIN=$lttng_bin
 
@@ -70,18 +54,10 @@ function test_ust_uid_live ()
 {
        local session_name="$1"
        local grouping="$2"
-       local is_automatic_session=false
-
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
 
-       diag "Test UST uid buffer live [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST uid buffer live [$grouping][${session_name}]"
 
        create_lttng_session_uri "$session_name" net://localhost --live
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -90,7 +66,7 @@ function test_ust_uid_live ()
        $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
                validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
@@ -109,18 +85,10 @@ function test_ust_pid_live ()
 {
        local session_name="$1"
        local grouping="$2"
-       local is_automatic_session=false
-
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
 
-       diag "Test UST pid buffer live [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST pid buffer live [$grouping][${session_name}]"
 
        create_lttng_session_uri "$session_name" net://localhost --live
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-pid"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -129,7 +97,7 @@ function test_ust_pid_live ()
        $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
                validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
@@ -149,18 +117,10 @@ function test_ust_uid_live_custom_output ()
        local session_name="$1"
        local grouping="$2"
        local custom_output="my_live_custom_output"
-       local is_automatic_session=false
 
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
-
-       diag "Test UST uid buffer live, custom output [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST uid buffer live, custom output [$grouping][${session_name}]"
 
        create_lttng_session_uri "$session_name" net://localhost/$custom_output --live
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -169,7 +129,7 @@ function test_ust_uid_live_custom_output ()
        $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
                validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$custom_output"
@@ -188,18 +148,10 @@ function test_ust_uid_streaming ()
 {
        local session_name="$1"
        local grouping="$2"
-       local is_automatic_session=false
 
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
-
-       diag "Test UST uid buffer streaming [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST uid buffer streaming [$grouping][${session_name}]"
 
        create_lttng_session_uri "$session_name" net://localhost
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -208,7 +160,7 @@ function test_ust_uid_streaming ()
        $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
                validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
@@ -227,18 +179,9 @@ function test_ust_pid_streaming ()
 {
        local session_name="$1"
        local grouping="$2"
-       local is_automatic_session=false
-
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
-
-       diag "Test UST pid buffer streaming [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST pid buffer streaming [$grouping][${session_name}]"
 
        create_lttng_session_uri "$session_name" net://localhost
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-pid"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -247,7 +190,7 @@ function test_ust_pid_streaming ()
        $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
                validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
@@ -267,18 +210,10 @@ function test_ust_uid_streaming_custom_output ()
        local session_name="$1"
        local grouping="$2"
        local custom_output="custom_second_token"
-       local is_automatic_session=false
 
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
-
-       diag "Test UST uid buffer streaming, custom output [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST uid buffer streaming, custom output [$grouping][${session_name}]"
 
        create_lttng_session_uri "$session_name" net://localhost/$custom_output
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -287,7 +222,7 @@ function test_ust_uid_streaming_custom_output ()
        $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
                validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$custom_output"
@@ -306,18 +241,10 @@ function test_ust_uid_streaming_rotate ()
 {
        local session_name="$1"
        local grouping="$2"
-       local is_automatic_session=false
 
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
-
-       diag "Test UST uid buffer rotate [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST uid buffer rotate [$grouping][${session_name}]"
 
        create_lttng_session_uri "$session_name" net://localhost
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -327,7 +254,7 @@ function test_ust_uid_streaming_rotate ()
        rotate_session_ok "$session_name"
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
                validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
@@ -347,18 +274,10 @@ function test_ust_uid_streaming_rotate_custom_output ()
        local session_name="$1"
        local grouping="$2"
        local custom_output="rotate_custom_path"
-       local is_automatic_session=false
 
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
-
-       diag "Test UST uid buffer rotate, custom output [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST uid buffer rotate, custom output [$grouping][${session_name}]"
 
        create_lttng_session_uri "$session_name" net://localhost/$custom_output
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -369,7 +288,7 @@ function test_ust_uid_streaming_rotate_custom_output ()
 
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
                validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$custom_output"
@@ -388,18 +307,10 @@ function test_ust_pid_streaming_rotate ()
 {
        local session_name="$1"
        local grouping="$2"
-       local is_automatic_session=false
-
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
 
-       diag "Test UST pid buffer rotate with session_name [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST pid buffer rotate with session_name [$grouping][${session_name}]"
 
        create_lttng_session_uri "$session_name" net://localhost
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-pid"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -409,7 +320,7 @@ function test_ust_pid_streaming_rotate ()
        rotate_session_ok "$session_name"
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
                validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
@@ -428,18 +339,10 @@ function test_ust_uid_streaming_snapshot ()
 {
        local session_name="$1"
        local grouping="$2"
-       local is_automatic_session=false
-
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
 
-       diag "Test UST uid buffer snapshot streaming using 'create --snapshot' [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST uid buffer snapshot streaming using 'create --snapshot' [$grouping][${session_name}]"
 
        create_lttng_session_uri "$session_name" net://localhost --snapshot
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -449,7 +352,7 @@ function test_ust_uid_streaming_snapshot ()
        lttng_snapshot_record "$session_name"
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
                validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
@@ -468,24 +371,16 @@ function test_ust_pid_streaming_snapshot ()
 {
        local session_name="$1"
        local grouping="$2"
-       local is_automatic_session=false
 
        local file_sync_after_first
        local file_sync_before_last
 
-       file_sync_after_first=$(mktemp -u)
-       file_sync_before_last=$(mktemp -u)
-
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
+       file_sync_after_first=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX")
+       file_sync_before_last=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
 
-       diag "Test UST pid buffer snapshot streaming using 'create --snapshot' [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST pid buffer snapshot streaming using 'create --snapshot' [$grouping][${session_name}]"
 
        create_lttng_session_uri "$session_name" net://localhost --snapshot
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-pid"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -505,7 +400,7 @@ function test_ust_pid_streaming_snapshot ()
        wait
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
                validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/snapshot-1*"
@@ -527,18 +422,10 @@ function test_ust_uid_streaming_snapshot_add_output_default_name ()
 {
        local session_name="$1"
        local grouping="$2"
-       local is_automatic_session=false
 
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
-
-       diag "Test UST uid buffer snapshot using 'add-output' with default snapshot name [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST uid buffer snapshot using 'add-output' with default snapshot name [$grouping][${session_name}]"
 
        create_lttng_session_no_output "$session_name"
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_lttng_mmap_overwrite_ust_channel "$session_name" "$CHANNEL_NAME"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -550,7 +437,7 @@ function test_ust_uid_streaming_snapshot_add_output_default_name ()
        lttng_snapshot_record "$session_name"
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
                validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/snapshot-1*"
@@ -570,18 +457,10 @@ function test_ust_uid_streaming_snapshot_add_output_custom_name ()
        local session_name="$1"
        local grouping="$2"
        local snapshot_name="this_is_my_snapshot"
-       local is_automatic_session=false
 
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
-
-       diag "Test UST uid buffer snapshot using 'add-output' with custom snapshot name [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST uid buffer snapshot using 'add-output' with custom snapshot name [$grouping][${session_name}]"
 
        create_lttng_session_no_output "$session_name"
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_lttng_mmap_overwrite_ust_channel "$session_name" "$CHANNEL_NAME"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -593,7 +472,7 @@ function test_ust_uid_streaming_snapshot_add_output_custom_name ()
        lttng_snapshot_record "$session_name"
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        # When session name is automatic, the actual directory is "auto", not
        # auto-<datetime>.
@@ -616,18 +495,10 @@ function test_ust_uid_streaming_snapshot_add_output_custom_name_custom_output ()
        local grouping="$2"
        local snapshot_name="this_is_my_snapshot"
        local custom_output="this/is/my/custom/path"
-       local is_automatic_session=false
 
-       if [ -z "$session_name" ]; then
-               is_automatic_session=true
-       fi
-
-       diag "Test UST uid buffer snapshot using 'add-output' with custom snapshot name and custom output path [$grouping][${session_name:-automatic session name}]"
+       diag "Test UST uid buffer snapshot using 'add-output' with custom snapshot name and custom output path [$grouping][${session_name}]"
 
        create_lttng_session_no_output "$session_name"
-       if [ "$is_automatic_session" = true ]; then
-               get_auto_session_name session_name
-       fi
 
        enable_lttng_mmap_overwrite_ust_channel "$session_name" "$CHANNEL_NAME"
        enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
@@ -639,7 +510,7 @@ function test_ust_uid_streaming_snapshot_add_output_custom_name_custom_output ()
        lttng_snapshot_record "$session_name"
 
        stop_lttng_tracing_ok "$session_name"
-       destroy_lttng_session_ok "$session_name"
+       destroy_lttng_session_ok "$session_name" --no-wait
 
        if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
                validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$custom_output/$snapshot_name*"
@@ -658,6 +529,7 @@ plan_tests $NUM_TESTS
 
 print_test_banner "$TEST_DESC"
 
+bail_out_if_no_babeltrace
 
 tests=(
        test_ust_uid_live
@@ -683,30 +555,21 @@ grouping_types=(
        $GROUP_BY_SESSION
        $GROUP_BY_HOSTNAME
 )
-for fct_test in "${tests[@]}";
+for grouping in "${grouping_types[@]}";
 do
-       for grouping in "${grouping_types[@]}";
+       TRACE_PATH=$(mktemp -d -t tmp.test_relayd_grouping_ust_trace_path.XXXXXX)
+       # Set the relayd in --group-output-by-session mode
+       start_lttng_relayd "-o $TRACE_PATH $grouping"
+       start_lttng_sessiond
+       for fct_test in "${tests[@]}";
        do
-               TRACE_PATH=$(mktemp -d)
-               # Set the relayd in --group-output-by-session mode
-               start_lttng_relayd "-o $TRACE_PATH $grouping"
-               start_lttng_sessiond
-
-               name=""
-               # Perform test when session name is generated by the client
-               ${fct_test} "$name" "$grouping"
-               count=$(find "$TRACE_PATH/" -maxdepth 1 -mindepth 1 | wc -l)
-               is "$count" "0" "LTTng-relayd output directory empty"
-
                # Perform test when session name is given
                name="my-session"
                ${fct_test} "$name" "$grouping"
                count=$(find "$TRACE_PATH/" -maxdepth 1 -mindepth 1 | wc -l)
                is "$count" "0" "LTTng-relayd output directory empty"
-
-               rm -rf "$TRACE_PATH"
-               stop_lttng_relayd
-               stop_lttng_sessiond
        done
+       rm -rf "$TRACE_PATH"
+       stop_lttng_relayd
+       stop_lttng_sessiond
 done
-
This page took 0.03063 seconds and 4 git commands to generate.