From 7e547df6a875230134157556398e767574a3da69 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Tue, 26 Sep 2023 09:39:41 -0400 Subject: [PATCH] tests: Run relayd-grouping tests by grouping type MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Observed issue ============== The `relayd-grouping/test_ust` test takes ~2 minutes to run. A significant amount of that time is statring and stopping the relay and sesion daemons. Solution ======== Each test function is run with a different grouping setup for the relayd. Rather than iterating over each test and then grouping variations, the iteration can be changed to organize the tests run by grouping setup. This allows us to start th relay and session daemons once per grouping setup, rather than twice for each test function. Further more, each test function is run twice: once with auto-generated session names, once with user-defined session names. This behaviour can be cut out to reduce the runtime of the test further. On my development machine, the test went from running in 113s to 18s. Known drawbacks =============== This no longer exercises the automatic session naming. I don't think that the automatic session naming paths are pertinent with regards to the grouping settings; however it appears it can impact output directories (eg. in `test_ust_uid_streaming_snapshot_add_output_custom_name`). Change-Id: I89d8cb224e594dd68b7e8f3367d1907ecfa2bf13 Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- .../regression/tools/relayd-grouping/test_ust | 170 +++--------------- 1 file changed, 24 insertions(+), 146 deletions(-) diff --git a/tests/regression/tools/relayd-grouping/test_ust b/tests/regression/tools/relayd-grouping/test_ust index fe40bd551..8e2dca9cc 100755 --- a/tests/regression/tools/relayd-grouping/test_ust +++ b/tests/regression/tools/relayd-grouping/test_ust @@ -19,7 +19,7 @@ CHANNEL_NAME="my_channel" 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" @@ -54,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" @@ -93,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" @@ -133,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" @@ -172,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" @@ -211,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" @@ -251,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" @@ -290,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" @@ -331,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" @@ -372,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" @@ -412,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" @@ -452,7 +371,6 @@ 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 @@ -460,16 +378,9 @@ function test_ust_pid_streaming_snapshot () 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") - if [ -z "$session_name" ]; then - is_automatic_session=true - fi - - 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" @@ -511,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" @@ -554,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" @@ -600,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" @@ -668,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 -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 - - 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 - -- 2.34.1