From 609996d5eafa3c5fb62924f4acb3813b00264e18 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 5 Jul 2022 16:43:26 -0400 Subject: [PATCH] Tests: size-based rotation: implement a trace size cutoff protection MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Stop waiting for rotations when the trace exceeds a certain size cutoff. This prevents those tests from filling a hard drive when they fail. However, this check is racy since it is possible for an arbitrary number of apps to run before the session daemon gets a chance to perform the scheduled rotations. Signed-off-by: Jérémie Galarneau Change-Id: I465462e6f1d5c17ada2b3aceb68662d8663254eb --- tests/regression/tools/rotation/rotate_utils.sh | 9 ++++++++- tests/regression/tools/rotation/test_kernel | 3 ++- tests/regression/tools/rotation/test_ust | 6 ++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/regression/tools/rotation/rotate_utils.sh b/tests/regression/tools/rotation/rotate_utils.sh index 8ac2afab7..146f7e25c 100644 --- a/tests/regression/tools/rotation/rotate_utils.sh +++ b/tests/regression/tools/rotation/rotate_utils.sh @@ -150,15 +150,22 @@ function trace_until_n_archives () local produce_events=$1 local trace_path=$2 local target_archive_count=$3 + local trace_size_cutoff=$4 local archive_count=0 + local trace_size=0 diag "Waiting for $target_archive_count size-based rotations to occur" - while [[ archive_count -lt $target_archive_count ]] + while [[ archive_count -lt $target_archive_count && $trace_size -lt $trace_size_cutoff ]] do archive_count=$(find "$trace_path" -mindepth 2 -maxdepth 2 -type d -path "*archives*" | wc -l) + trace_size=$(du -b "$trace_path" | tail -n1 | cut -f1) $produce_events 2000 done + if [[ $trace_size -ge $trace_size_cutoff ]]; then + diag "Exceeded size cutoff of $trace_size_cutoff bytes while waiting for $target_archive_count rotations" + fi + [[ $archive_count -eq $target_archive_count ]] ok $? "Found $target_archive_count trace archives resulting from trace archive rotations" } diff --git a/tests/regression/tools/rotation/test_kernel b/tests/regression/tools/rotation/test_kernel index 62bc5c33d..760930e95 100755 --- a/tests/regression/tools/rotation/test_kernel +++ b/tests/regression/tools/rotation/test_kernel @@ -96,7 +96,8 @@ function test_kernel_local_size () lttng_enable_rotation_size_ok $SESSION_NAME $size_threshold start_lttng_tracing_ok $SESSION_NAME - trace_until_n_archives produce_n_events "$TRACE_PATH" 5 + # Cutoff at 100 times the expected size + trace_until_n_archives produce_n_events "$TRACE_PATH" 5 $((5 * 100 * size_threshold)) destroy_lttng_session_ok $SESSION_NAME } diff --git a/tests/regression/tools/rotation/test_ust b/tests/regression/tools/rotation/test_ust index aaeee4454..043b123bf 100755 --- a/tests/regression/tools/rotation/test_ust +++ b/tests/regression/tools/rotation/test_ust @@ -274,7 +274,8 @@ function test_ust_local_size_uid () lttng_enable_rotation_size_ok $SESSION_NAME $size_threshold start_lttng_tracing_ok $SESSION_NAME - trace_until_n_archives produce_n_events "$TRACE_PATH" 5 + # Cutoff at 100 times the expected size + trace_until_n_archives produce_n_events "$TRACE_PATH" 5 $((5 * 100 * size_threshold)) destroy_lttng_session_ok $SESSION_NAME } @@ -291,7 +292,8 @@ function test_ust_local_size_pid () lttng_enable_rotation_size_ok $SESSION_NAME $size_threshold start_lttng_tracing_ok $SESSION_NAME - trace_until_n_archives produce_n_events "$TRACE_PATH" 3 + # Cutoff at 100 times the expected size + trace_until_n_archives produce_n_events "$TRACE_PATH" 3 $((3 * 100 * size_threshold)) destroy_lttng_session_ok $SESSION_NAME } -- 2.34.1