tests: Reduce runtime of tools/tracker/test_event_tracker tests
authorKienan Stewart <kstewart@efficios.com>
Tue, 26 Sep 2023 15:36:24 +0000 (11:36 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 21 Dec 2023 21:38:35 +0000 (16:38 -0500)
Observed issue
==============

When running the test as root, so both UST and kernel tests are
exercised, this test takes about 100s to run on my development system.

Solution
========

By using session destroy with '--no-wait', the runtime is reduced by
30-40s. For the kernel tests in particular this introduces a detail to
keep in mind with regards to unloading the lttng-tests kernel
module. More details in the 'Known drawbacks' section.

The test applications (both userspace and kernel) also execute much
more quickly than the 0.5s sleep they are given. By reducing the sleep
to a hundreth of a second, another 15s or so can be shaved off the
test runtime.

Overall, the test runtime is reduced from 102s to 45s on my
development machine.

Known drawbacks
===============

If `modprobe -r lttng-tests` is run too quickly after the last session
destruction with `--no-wait`, the removal will fail. This patch uses a
simple one second sleep to give some time for the processes using that
module to get completely shutdown. I think it could be somewhat
brittle on systems that are slow or overcommitted; however, it seemed
more 'maintainable' than remembering to ensure that the last kernel
test session destruction doesn't use `--no-wait`.

Change-Id: Ib953ef22299d30507f46d2e6507fbd0f5641aa27
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/tools/tracker/test_event_tracker

index 98ca990fc2be04a491cb1e09e9d227f0556d33a9..be42407405df6e3aca655326f58a3bf13548ecd4 100755 (executable)
@@ -52,7 +52,7 @@ function prepare_ust_app
        # Wait for the app to execute all the way to right before the last
        # event.
        while [ ! -f "${TOUCH_BEFORE_LAST_PATH}" ]; do
-               sleep 0.5
+               sleep 0.01
        done
 }
 
@@ -114,7 +114,7 @@ function test_event_tracker()
        trace_"$domain"_app
 
        stop_lttng_tracing_ok
-       destroy_lttng_session_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME --no-wait
 
        if [ "$expect_event" -eq 1 ]; then
                trace_matches "$EVENT_NAME" $NR_ITER "$trace_path"
@@ -159,7 +159,7 @@ function test_event_vpid_tracker()
        trace_"$domain"_app
 
        stop_lttng_tracing_ok
-       destroy_lttng_session_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME --no-wait
 
        if [ "$expect_event" -eq 1 ]; then
                validate_trace "$EVENT_NAME" "$trace_path"
@@ -204,7 +204,7 @@ function test_event_pid_tracker()
        trace_"$domain"_app
 
        stop_lttng_tracing_ok
-       destroy_lttng_session_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME --no-wait
 
        if [ "$expect_event" -eq 1 ]; then
                validate_trace "$EVENT_NAME" "$trace_path"
@@ -230,7 +230,7 @@ function test_event_tracker_fail()
        create_lttng_session_ok $SESSION_NAME "$trace_path"
        enable_"$domain"_lttng_event_ok $SESSION_NAME "$wildcard"
        lttng_track_"$domain"_fail "${tracker}"
-       destroy_lttng_session_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME --no-wait
 
        rm -rf "$trace_path"
 }
@@ -267,7 +267,7 @@ function test_event_track_untrack()
        trace_"$domain"_app
 
        stop_lttng_tracing_ok
-       destroy_lttng_session_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME --no-wait
 
        if [ "$expect_event" -eq 1 ]; then
                trace_matches "$EVENT_NAME" $NR_ITER "$trace_path"
@@ -309,7 +309,7 @@ function test_event_vpid_track_untrack()
        trace_"$domain"_app
 
        stop_lttng_tracing_ok
-       destroy_lttng_session_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME --no-wait
 
        if [ "$expect_event" -eq 1 ]; then
                validate_trace "$EVENT_NAME" "$trace_path"
@@ -351,7 +351,7 @@ function test_event_pid_track_untrack()
        trace_"$domain"_app
 
        stop_lttng_tracing_ok
-       destroy_lttng_session_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME --no-wait
 
        if [ "$expect_event" -eq 1 ]; then
                validate_trace "$EVENT_NAME" "$trace_path"
@@ -382,7 +382,7 @@ function test_event_ust_vpid_untrack_snapshot()
        lttng_snapshot_record $SESSION_NAME
 
        stop_lttng_tracing_ok
-       destroy_lttng_session_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME --no-wait
 
        snapshot_count=$(find "$trace_path" -name metadata | wc -l)
        is "$snapshot_count" 0 "Number of snapshot is zero"
@@ -565,6 +565,19 @@ skip $isroot "Root access is needed. Skipping all kernel tracker tests." $NUM_KE
        test_event_tracker kernel 1 "${EVENT_NAME}" "--pid --all"
        test_event_pid_tracker kernel 1 "${EVENT_NAME}"
 
+       # When using session destroy with '--no-wait', the quick
+       # exit at the end means that the lttng-test modules is
+       # still marked as being in use and 'modprobe --remove' fails.
+       #
+       # It is possible to work around the issue by not setting
+       # '--no-wait' on the last kernel test, but it seems like
+       # an easy detail to forget about.
+       #
+       # The sleep here gives the system a small amount of time to
+       # finish wrapping up the session that had the lttng-test kernel
+       # module loaded.
+       sleep 1
+
        modprobe --remove lttng-test
        ok $? "Unloading lttng-test module"
 }
This page took 0.026977 seconds and 4 git commands to generate.