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"
21 TESTDIR
=$CURDIR/..
/..
/..
22 BIN_NAME
="gen-ust-events"
24 EVENT_NAME
="tp:tptest"
27 TRACE_PATH
=$
(mktemp
-d)
31 source $TESTDIR/utils
/utils.sh
33 print_test_banner
"$TEST_DESC"
35 if [ ! -x "$CURDIR/$BIN_NAME" ]; then
36 BAIL_OUT
"No UST nevents binary detected. Skipping."
39 function lttng_create_session
42 # Create session with custom URI
43 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
-U $URI $SESSION_NAME >/dev
/null
2>&1
44 ok $?
"Create session with uri $URI"
47 function lttng_enable_consumer
50 # Create session with custom URI
51 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-consumer
-u $URI >/dev
/null
2>&1
52 ok $?
"Enable consumer with uri $URI"
57 # Run 5 times with a 1 second delay
60 .
/$CURDIR/$BIN_NAME $COUNT $APP_DELAY >/dev
/null
2>&1 &
65 while [ -n "$(pidof $BIN_NAME)" ]; do
68 pass
"Wait for applications to end"
71 function test_uri_switch_localhost_folder
75 diag
"Test switch of localhost folder ($IPVER)"
77 if [ "$IPVER" == "IPv6" ]; then
78 BASE_URI
="net6://localhost"
80 BASE_URI
="net://localhost"
87 lttng_create_session
$BASE_URI
89 while [ "$i" -le $RANDCOUNT ]
91 RAND
=$
(randstring
16 0)
92 lttng_enable_consumer
"$BASE_URI/$RAND"
96 pass
"Randomize output folder on $BASE_URI"
98 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
99 start_lttng_tracing
$SESSION_NAME
102 stop_lttng_tracing
$SESSION_NAME
103 destroy_lttng_session
$SESSION_NAME
104 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$RAND
106 if [ $?
-eq 0 ]; then
107 # Only delete if successful
112 function test_uri_switch_file_network
116 diag
"Test switch file -> network ($IPVER)"
118 TMP_PATH
=$
(mktemp
-d)
119 FILE_URI
="file://$TMP_PATH"
121 if [ "$IPVER" == "IPv6" ]; then
122 NETWORK_URIS
=("net6://localhost" "net6://[::1]")
124 NETWORK_URIS
=("net://localhost" "net://127.0.0.1")
127 NET_PATHS
=("foo/bar" "OohEehOohAhAahTingTangWallaWallaBingBang" ".")
129 for NETWORK_URI
in ${NETWORK_URIS[@]};
131 for NET_PATH
in ${NET_PATHS[@]};
133 SESSION_NAME
=$
(randstring
16 0)
134 diag
"$FILE_URI -> $NETWORK_URI/$NET_PATH"
136 lttng_create_session
$FILE_URI
137 lttng_enable_consumer
"$NETWORK_URI/$NET_PATH"
138 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
139 start_lttng_tracing
$SESSION_NAME
142 stop_lttng_tracing
$SESSION_NAME
143 destroy_lttng_session
$SESSION_NAME
144 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$NET_PATH
146 if [ $?
-eq 0 ]; then
147 # Only delete if successful
157 function test_uri_switch_network_file
160 diag
"Test 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)
176 diag
"$NETWORK_URI -> $FILE_URI/$FILE_PATH"
178 lttng_create_session
$NETWORK_URI
179 lttng_enable_consumer
"$FILE_URI/$FILE_PATH"
180 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
181 start_lttng_tracing
$SESSION_NAME
184 stop_lttng_tracing
$SESSION_NAME
185 destroy_lttng_session
$SESSION_NAME
186 validate_trace
$EVENT_NAME $TMP_PATH/$FILE_PATH
188 if [ $?
-eq 0 ]; then
189 # Only delete if successful
197 plan_tests
$NUM_TESTS
201 diag
"Test with IPv4"
202 start_lttng_relayd
"-o $TRACE_PATH"
203 test_uri_switch_localhost_folder
"IPv4"
204 test_uri_switch_file_network
"IPv4"
205 test_uri_switch_network_file
"IPv4"
208 diag
"Test with IPv6"
209 start_lttng_relayd
"-o $TRACE_PATH -C tcp6://localhost:5342 -D tcp6://localhost:5343"
210 test_uri_switch_localhost_folder
"IPv6"
211 test_uri_switch_file_network
"IPv6"
212 test_uri_switch_network_file
"IPv6"