3 # Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
4 # David Goulet <dgoulet@efficios.com>
6 # This library is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU Lesser General Public License as published by the Free
8 # Software Foundation; version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this library; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 TEST_DESC
="Streaming - High throughput with bandwidth limits"
25 BIN_NAME
="gen-ust-events"
26 SESSION_NAME
="high-throughput"
27 EVENT_NAME
="tp:tptest"
28 SESSIOND_CTRL_PORT
=5342
29 SESSIOND_DATA_PORT
=5343
32 TRACE_PATH
=$
(mktemp
-d)
34 source $TESTDIR/utils.sh
36 print_test_banner
"$TEST_DESC"
38 if [ ! -x "$CURDIR/$BIN_NAME" ]; then
39 echo -e "No UST nevents binary detected. Passing."
43 if [ "$(id -u)" != "0" ]; then
44 echo "This test must be running as root to set bandwidth limits. Aborting"
45 # Exit status 0 so the tests can continue
52 echo -n "Setting bandwidth limits to ${limit}kbits... "
53 tc qdisc add dev
$DEFAULT_IF root handle
1: htb default
15 >/dev
/null
2>&1
54 tc class add dev
$DEFAULT_IF parent
1: classid
1:1 htb rate
${limit}kbit ceil
${limit}kbit
>/dev
/null
2>&1
56 tc filter add dev
$DEFAULT_IF parent
1: protocol ip u32 match ip dport
$SESSIOND_CTRL_PORT 0xffff flowid
1:1 >/dev
/null
2>&1
58 tc filter add dev
$DEFAULT_IF parent
1: protocol ip u32 match ip dport
$SESSIOND_DATA_PORT 0xffff flowid
1:1 >/dev
/null
2>&1
62 function reset_bw_limit
64 echo -n "Resetting bandwidth limits... "
65 tc qdisc del dev
$DEFAULT_IF root
>/dev
/null
2>&1
69 function create_lttng_session_with_uri
73 # Create session with custom URI
74 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
-U $uri $sess_name >/dev
/null
2>&1
77 function enable_lttng_consumer
80 # Create session with custom URI
81 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-consumer
-u $uri >/dev
/null
2>&1
86 for i
in `seq 1 $NR_APP_ITER`; do
87 # With bandwidth limitation, unfortunately, application easily timeout
88 # due to very slow communication between the consumer and relayd making
89 # the status reply from the consumer quite slow thus delaying the
90 # registration done message.
91 LTTNG_UST_REGISTER_TIMEOUT
=-1 .
/$CURDIR/$BIN_NAME $NR_ITER & >/dev
/null
2>&1
97 echo "Waiting for applications to end"
98 while [ -n "$(pidof $BIN_NAME)" ]; do
105 function test_high_throughput
107 NETWORK_URI
="net://localhost"
108 create_lttng_session_with_uri
$SESSION_NAME $NETWORK_URI
109 enable_lttng_consumer
$NETWORK_URI
110 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
111 start_lttng_tracing
$SESSION_NAME
115 stop_lttng_tracing
$SESSION_NAME
116 destroy_lttng_session
$SESSION_NAME
120 function validate_event_count
124 TEMP_FILE_2
=$
(mktemp
)
126 traced
=$
(babeltrace
$TRACE_PATH 2>/dev
/null |
wc -l)
127 babeltrace
$TRACE_PATH >/dev
/null
2>$TEMP_FILE_2
129 cat $TEMP_FILE_2 | cut
-f4 -d " " >$TEMP_FILE
134 let dropped
=$dropped+$line
137 let total
=$dropped+$traced
138 let wanted
=$NR_APP_ITER*$NR_ITER
140 if [ $wanted -ne $total ]; then
141 echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
145 echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
148 # Cleanup only if everything is ok and passes.
150 rm $TEMP_FILE $TEMP_FILE_2
156 function interrupt_cleanup
()
158 echo -en "\n*** Exiting ***\n"
165 # Catch sigint and try to cleanup limits
166 trap interrupt_cleanup SIGINT
168 BW_LIMITS
=(3200 1600 800 400 200 100 50 25)
169 for BW
in ${BW_LIMITS[@]};
172 echo -e "=== Testing high-throughput with bandwidth limit set to ${BW}kbits"
176 start_lttng_relayd
"-o $TRACE_PATH"
183 if [ $result -ne 0 ]; then