docs: Add supported versions and fix-backport policy
[lttng-tools.git] / tests / stress / test_multi_sessions_per_uid_10app
CommitLineData
605ac758
DG
1#!/bin/bash
2#
9d16b343 3# Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
605ac758 4#
9d16b343 5# SPDX-License-Identifier: LGPL-2.1-only
605ac758 6#
605ac758 7
c1896e2d
KS
8CURDIR=$(dirname "$0")/
9TESTDIR="$CURDIR/.."
605ac758
DG
10LAUNCH_APP="launch_ust_app"
11SESSION_NAME="stress"
12EVENT_NAME="tp:tptest"
13LOG_FILE="sessiond.log"
14CHANNEL_NAME="channel0"
15NUM_TESTS=16
16NR_APP=10
17NR_SESSION=5
18NR_LOOP=1000
19COREDUMP_FILE=$(cat /proc/sys/kernel/core_pattern)
c1896e2d 20APP_PIDS=()
605ac758
DG
21
22TEST_DESC="Stress test - $NR_SESSION sessions per UID with $NR_APP apps"
23
c1896e2d
KS
24# shellcheck source-path=SCRIPTDIR/../
25source "$TESTDIR/utils/utils.sh"
605ac758
DG
26
27# MUST set TESTDIR before calling those functions
28
29function enable_channel_per_uid()
30{
c1896e2d
KS
31 local sess_name=$1
32 local channel_name=$2
605ac758 33
c1896e2d
KS
34 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-channel --buffers-uid -u "$channel_name" -s "$sess_name" >/dev/null 2>&1
35 ok $? "Enable channel $channel_name per UID for session $sess_name"
605ac758
DG
36}
37
38function check_sessiond()
39{
c1896e2d
KS
40 local str_date=''
41 if [ -z "$(lttng_pgrep lttng-sessiond)" ]; then
42 str_date=$(date +%H%M%S-%d%m%Y)
605ac758
DG
43
44 diag "!!!The session daemon died unexpectedly!!!"
c1896e2d
KS
45 mv $LOG_FILE "$LOG_FILE-$str_date"
46 if [ -e "$COREDUMP_FILE" ]; then
47 mv "$COREDUMP_FILE" "$COREDUMP_FILE-$str_date"
605ac758
DG
48 fi
49 exit 1
50 fi
51}
52
53function start_sessiond()
54{
c1896e2d 55 if ! validate_kernel_version ; then
605ac758
DG
56 fail "Start session daemon"
57 BAIL_OUT "*** Kernel too old for session daemon tests ***"
58 fi
59
c1896e2d 60 if [ -z "$(lttng_pgrep $SESSIOND_BIN)" ]; then
605ac758
DG
61 # We have to start it like this so the ulimit -c is used by this
62 # process. Also, we collect any error message printed out.
c1896e2d 63 "$TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN" --quiet --background --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE 2>&1
605ac758 64 status=$?
605ac758
DG
65 ok $status "Start session daemon"
66 fi
67}
68
69test_stress()
70{
c1896e2d 71 # shellcheck disable=SC2034
605ac758
DG
72 for b in $(seq 1 $NR_LOOP); do
73 for a in $(seq 1 $NR_SESSION); do
c1896e2d 74 create_lttng_session_ok $SESSION_NAME-"$a" "$TRACE_PATH"
605ac758 75 check_sessiond
c1896e2d 76 enable_channel_per_uid $SESSION_NAME-"$a" $CHANNEL_NAME
605ac758 77 check_sessiond
c1896e2d 78 enable_ust_lttng_event_ok $SESSION_NAME-"$a" $EVENT_NAME
605ac758 79 check_sessiond
c1896e2d 80 start_lttng_tracing_ok $SESSION_NAME-"$a"
605ac758
DG
81 check_sessiond
82 done
83
84 for a in $(seq 1 $NR_SESSION); do
c1896e2d 85 stop_lttng_tracing_ok $SESSION_NAME-"$a"
605ac758 86 check_sessiond
c1896e2d 87 destroy_lttng_session_ok $SESSION_NAME-"$a"
605ac758
DG
88 check_sessiond
89 done
90 done
91
92 return 0
93}
94
95function cleanup()
96{
97 diag "Cleaning up!"
c1896e2d
KS
98 kill -s SIGKILL "${APP_PIDS[@]}"
99 wait "${APP_PIDS[@]}" 2>/dev/null
100 APP_PIDS=()
101 # shellcheck disable=SC2119
605ac758
DG
102 stop_lttng_sessiond
103}
104
105function sighandler()
106{
107 cleanup
c1896e2d 108 rm "$LOG_FILE"
3be453c9 109 full_cleanup
605ac758
DG
110}
111
3be453c9 112trap sighandler SIGINT SIGTERM
605ac758
DG
113
114# Make sure we collect a coredump if possible.
115ulimit -c unlimited
116
117# MUST set TESTDIR before calling those functions
118plan_tests $NUM_TESTS
119
120print_test_banner "$TEST_DESC"
121
122start_sessiond
123
124diag "Starting applications"
125
126# Start NR_APP applications script that will spawn apps non stop.
c1896e2d
KS
127"./$TESTDIR/stress/$LAUNCH_APP" $NR_APP &
128APP_PIDS+=(${!})
605ac758 129
8d5a3312 130TRACE_PATH=$(mktemp -d -t tmp.test_multi_sess_per_uid_10app.XXXXXX)
605ac758
DG
131
132test_stress
133out=$?
134if [ $out -ne 0 ]; then
135 cleanup
136 exit $out
137fi
138
139cleanup
c1896e2d 140rm -rf "${TRACE_PATH:?}/"
605ac758
DG
141rm $LOG_FILE
142exit 0
This page took 0.060558 seconds and 4 git commands to generate.