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
18 TEST_DESC
="Streaming - URI switching"
22 BIN_NAME
="gen-ust-events"
24 EVENT_NAME
="tp:tptest"
27 TRACE_PATH
=$
(mktemp
-d)
29 source $TESTDIR/utils.sh
31 print_test_banner
"$TEST_DESC"
33 if [ ! -x "$CURDIR/$BIN_NAME" ]; then
34 echo -e "No UST nevents binary detected. Skipping."
38 function lttng_create_session
41 # Create session with custom URI
42 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
-U $URI $SESSION_NAME >/dev
/null
2>&1
45 function lttng_enable_consumer
48 # Create session with custom URI
49 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-consumer
-u $URI >/dev
/null
2>&1
54 # Run 5 times with a 1 second delay
57 .
/$CURDIR/$BIN_NAME $COUNT $APP_DELAY >/dev
/null
2>&1 &
63 echo -n "Waiting for applications to end"
64 while [ -n "$(pidof $BIN_NAME)" ]; do
71 function test_uri_switch_localhost_folder
74 echo -e "\n=== Testing switch of localhost folder ($IPVER)\n"
76 if [ "$IPVER" == "IPv6" ]; then
77 BASE_URI
="net6://localhost"
79 BASE_URI
="net://localhost"
86 lttng_create_session
$BASE_URI
88 echo -e "Randomizing output folder on $BASE_URI..."
89 while [ "$i" -le $RANDCOUNT ]
91 RAND
=$
(randstring
16 0)
92 lttng_enable_consumer
"$BASE_URI/$RAND"
96 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
97 start_lttng_tracing
$SESSION_NAME
100 stop_lttng_tracing
$SESSION_NAME
101 destroy_lttng_session
$SESSION_NAME
102 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$RAND
104 if [ $?
-eq 0 ]; then
105 # Only delete if successful
110 function test_uri_switch_file_network
114 echo -e "=== Testing switch file -> network ($IPVER)"
116 TMP_PATH
=$
(mktemp
-d)
117 FILE_URI
="file://$TMP_PATH"
119 if [ "$IPVER" == "IPv6" ]; then
120 NETWORK_URIS
=("net6://localhost" "net6://[::1]")
122 NETWORK_URIS
=("net://localhost" "net://127.0.0.1")
125 NET_PATHS
=("foo/bar" "OohEehOohAhAahTingTangWallaWallaBingBang" ".")
127 for NETWORK_URI
in ${NETWORK_URIS[@]};
129 for NET_PATH
in ${NET_PATHS[@]};
131 SESSION_NAME
=$
(randstring
16 0)
133 echo "$FILE_URI -> $NETWORK_URI/$NET_PATH"
135 lttng_create_session
$FILE_URI
136 lttng_enable_consumer
"$NETWORK_URI/$NET_PATH"
137 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
138 start_lttng_tracing
$SESSION_NAME
141 stop_lttng_tracing
$SESSION_NAME
142 destroy_lttng_session
$SESSION_NAME
143 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$NET_PATH
145 if [ $?
-eq 0 ]; then
146 # Only delete if successful
156 function test_uri_switch_network_file
160 echo -e "=== Testing switch network ($IPVER) -> file"
162 if [ "$IPVER" == "IPv6" ]; then
163 NETWORK_URI
="net6://localhost"
165 NETWORK_URI
="net://localhost"
168 FILE_PATHS
=("." "foo/bar" "42")
170 for FILE_PATH
in ${FILE_PATHS[@]};
172 TMP_PATH
=$
(mktemp
-d)
173 FILE_URI
="file://$TMP_PATH"
174 SESSION_NAME
=$
(randstring
16 0)
177 echo "$NETWORK_URI -> $FILE_URI/$FILE_PATH"
179 lttng_create_session
$NETWORK_URI
180 lttng_enable_consumer
"$FILE_URI/$FILE_PATH"
181 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
182 start_lttng_tracing
$SESSION_NAME
185 stop_lttng_tracing
$SESSION_NAME
186 destroy_lttng_session
$SESSION_NAME
187 validate_trace
$EVENT_NAME $TMP_PATH/$FILE_PATH
189 if [ $?
-eq 0 ]; then
190 # Only delete if successful
202 echo "=== Testing with IPv4"
203 start_lttng_relayd
"-o $TRACE_PATH"
204 test_uri_switch_localhost_folder
"IPv4"
205 test_uri_switch_file_network
"IPv4"
206 test_uri_switch_network_file
"IPv4"
210 echo "=== Testing with IPv6"
211 start_lttng_relayd
"-o $TRACE_PATH -C tcp6://localhost:5342 -D tcp6://localhost:5343"
212 test_uri_switch_localhost_folder
"IPv6"
213 test_uri_switch_file_network
"IPv6"
214 test_uri_switch_network_file
"IPv6"