From fec7cc14f54b887abb2b43687783470710dc295a Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Thu, 31 Aug 2023 14:00:26 -0400 Subject: [PATCH] tests: Reduce sleep time when waiting for various daemons to die MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Motivation ========== Using the rough duration of the tests 'Wait after kill \w+ daemon', approximately 200s were being spent in those areas when running non-root, non-destructive tests on my development machine. ``` $ find . -iname '*.log' -exec grep -A4 -HE 'Wait for kill [a-z]+ daemon' {} \; | grep duration_ms | cut -d':' -f2 | datamash sum 1 198078.707216 ``` Solution ======== The `stop_x_opt()` functions with timers in `tests/utils/utils.sh` have the timeouts multiplied by 5 to reduce the counted sleep interval to 0.1s. After applying this change, the time spent in the tests as counted with the find command in the 'Motivation' section above was reduced to 92061.768ms, a reduction of about 1.5 minutes. Known drawbacks =============== None Change-Id: I1d4ad899808f37f6cb7b88bbab0ff05ab0c2b787 Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- tests/utils/utils.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 5bab2f372..27816dedd 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -675,8 +675,9 @@ function stop_lttng_relayd_opt() # Multiply time by 2 to simplify integer arithmetic + # Multiply time by 5 to adjust for sleeping every 0.1s if [ -n "$timeout_s" ]; then - dtimeleft_s=$((timeout_s * 2)) + dtimeleft_s=$((timeout_s * 2 * 5)) fi @@ -711,7 +712,7 @@ function stop_lttng_relayd_opt() fi dtimeleft_s=$((dtimeleft_s - 1)) fi - sleep 0.5 + sleep 0.1 done if [ "$withtap" -eq "1" ]; then if [ "$retval" -eq "0" ]; then @@ -835,8 +836,9 @@ function stop_lttng_sessiond_opt() fi # Multiply time by 2 to simplify integer arithmetic + # Multiply time by 5 to adjust for sleeping every 0.1s if [ -n "$timeout_s" ]; then - dtimeleft_s=$((timeout_s * 2)) + dtimeleft_s=$((timeout_s * 2 * 5)) fi if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then @@ -881,7 +883,7 @@ function stop_lttng_sessiond_opt() fi dtimeleft_s=$((dtimeleft_s - 1)) fi - sleep 0.5 + sleep 0.1 done out=1 while [ -n "$out" ]; do @@ -893,7 +895,7 @@ function stop_lttng_sessiond_opt() fi dtimeleft_s=$((dtimeleft_s - 1)) fi - sleep 0.5 + sleep 0.1 done if [ "$withtap" -eq "1" ]; then @@ -1003,8 +1005,9 @@ function stop_lttng_consumerd_opt() fi # Multiply time by 2 to simplify integer arithmetic + # Multiply time by 5 to adjust for sleeping every 0.1s if [ -n "$timeout_s" ]; then - dtimeleft_s=$((timeout_s * 2)) + dtimeleft_s=$((timeout_s * 2 * 5)) fi pids="$(lttng_pgrep "$CONSUMERD_MATCH")" @@ -1049,7 +1052,7 @@ function stop_lttng_consumerd_opt() fi dtimeleft_s=$((dtimeleft_s - 1)) fi - sleep 0.5 + sleep 0.1 done if [ "$withtap" -eq "1" ]; then if [ "$retval" -eq "0" ]; then -- 2.34.1