3 # Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
5 # SPDX-License-Identifier: LGPL-2.1-only
7 TEST_DESC
="Load session(s)"
10 CONFIG_DIR
="${CURDIR}/configuration"
11 TESTDIR
=$CURDIR/..
/..
/..
/
12 export LTTNG_SESSION_CONFIG_XSD_PATH
=$
(readlink
-m ${TESTDIR}..
/src
/common
/config
/)
14 SESSION_NAME
="load-42"
15 EVENT_NAME
="tp:tptest"
17 DIR
=$
(readlink
-f $TESTDIR)
21 source $TESTDIR/utils
/utils.sh
23 # MUST set TESTDIR before calling those functions
26 print_test_banner
"$TEST_DESC"
28 function test_basic_load
()
30 diag
"Test basic load"
32 lttng_load_ok
"-i $CURDIR/$SESSION_NAME.lttng"
34 destroy_lttng_session_ok
$SESSION_NAME
37 function test_complex_load
()
39 local sess
="$SESSION_NAME-complex"
42 diag
"Test complex load"
44 # Start relayd with localhost binding. The complex session uses those
46 start_lttng_relayd
"-C tcp://localhost:8172 -D tcp://localhost:9817"
48 lttng_load_ok
"-i $CURDIR/$sess.lttng"
50 # Once loaded, we are suppose to be able to disable certain events/channels
51 # thus having a confirmation that it's valid
52 disable_ust_lttng_event
$sess uevent1 chan1
53 disable_ust_lttng_event
$sess uevent2 chan2
54 disable_ust_lttng_event
$sess uevent3
* chan3
56 disable_ust_lttng_channel
$sess chan1
57 disable_ust_lttng_channel
$sess chan2
58 disable_ust_lttng_channel
$sess chan3
60 # Confirm that an event stored as disabled is restored in its disabled state
61 local mi_output_file
=$
(mktemp
--tmpdir "tmp.${FUNCNAME[0]}_output_file.XXXXXX")
65 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN --mi XML list
$sess -c chan2
> $mi_output_file
66 mi_result
=$
("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain[lttng:type='UST']/lttng:channels/lttng:channel[lttng:name='chan2']/lttng:events/lttng:event[lttng:name='uevent_disabled']/lttng:enabled/text()")
67 if [[ $mi_result = "false" ]]; then
68 ok
0 "Disabled event is loaded in disabled state"
70 fail
"Disabled event is loaded in disabled state"
73 mi_result
=$
("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:channels/lttng:channel[lttng:name='chan2']/lttng:events/lttng:event[lttng:name='uevent_disabled']/lttng:enabled/text()")
74 test $mi_result = "false"
75 ok $?
"Disabled event is loaded in disabled state"
77 # Check that uevent_same_name_diff_llevel with log level 6 (TRACE_INFO) is enabled
78 # This ensure that the state of events with similar name but not same
79 # descriptor tuple (exclusion,filter,loglevel) is restored correctly.
80 mi_result
=$
("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:channels/lttng:channel[lttng:name='chan2']/lttng:events/lttng:event[lttng:name='uevent_same_name_diff_llevel' and lttng:loglevel='TRACE_INFO']/lttng:enabled/text()")
81 test $mi_result = "true"
82 ok $?
"Enabled event with same name but different loglevel is in disabled state"
84 destroy_lttng_session_ok
$sess
88 rm -rf ${mi_output_file}
91 function test_all_load
()
93 diag
"Test load all sessions"
95 # Start relayd with localhost binding. The complex session uses those
97 start_lttng_relayd
"-C tcp://localhost:8172 -D tcp://localhost:9817"
99 lttng_load_ok
"-a -i $CURDIR"
101 destroy_lttng_session_ok
$SESSION_NAME
102 destroy_lttng_session_ok
"$SESSION_NAME-complex"
103 destroy_lttng_session_ok
"$SESSION_NAME-trackers"
104 destroy_lttng_session_ok
"tracker_legacy_all"
105 destroy_lttng_session_ok
"tracker_legacy_none"
106 destroy_lttng_session_ok
"tracker_legacy_selective"
111 function test_overwrite
()
113 diag
"Test load overwrite"
115 lttng_load_ok
"-i $CURDIR/$SESSION_NAME.lttng"
117 # This one should succeed
118 lttng_load_ok
"-f -i $CURDIR $SESSION_NAME"
120 destroy_lttng_session_ok
$SESSION_NAME
123 function test_trackers
()
125 diag
"Test trackers loading"
127 lttng_load_ok
"-i $CURDIR/$SESSION_NAME-trackers.lttng"
129 diag
"Test pid tracker"
130 local mi_output_file
=$
(mktemp
--tmpdir "tmp.${FUNCNAME[0]}_output_file.XXXXXX")
131 if [ $?
-ne 0 ]; then
134 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN --mi XML list
"$SESSION_NAME-trackers" > $mi_output_file
135 mi_result
=$
($XML_NODE_CHECK $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:process_attr_trackers/lttng:vpid_process_attr_tracker/lttng:process_attr_values/lttng:vpid")
136 if [[ $mi_result = "true" ]]; then
137 ok
0 "VPID target is present"
139 fail
"VPID target missing"
142 mi_result
=$
($XML_NODE_CHECK $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:process_attr_trackers/lttng:vuid_process_attr_tracker/lttng:process_attr_values/lttng:vuid")
143 if [[ $mi_result = "true" ]]; then
144 ok
0 "VUID target is present"
146 fail
"VUID target missing"
149 mi_result
=$
($XML_NODE_CHECK $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:process_attr_trackers/lttng:vgid_process_attr_tracker/lttng:process_attr_values/lttng:vgid")
150 if [[ $mi_result = "true" ]]; then
151 ok
0 "VGID target is present"
153 fail
"VGID target missing"
156 # Test to remove the target just to make sure
157 lttng_untrack_ok
"--vpid 666 -u -s $SESSION_NAME-trackers"
158 lttng_untrack_ok
"--vuid 777 -u -s $SESSION_NAME-trackers"
159 lttng_untrack_ok
"--vgid 888 -u -s $SESSION_NAME-trackers"
160 # Actually using vpid (backward compat)
161 lttng_untrack_ok
"--pid 999 -u -s $SESSION_NAME-trackers"
163 destroy_lttng_session_ok
"$SESSION_NAME-trackers"
164 rm -f ${mi_output_file}
167 function test_override_url_normal
()
169 local local_url_override
="file:///tmp/override/to/here"
170 local local_path_override
="/tmp/override/to/here"
171 local local_path_compare_value
="/tmp/override/to/here/"
172 local stream_url_override
="net://127.0.0.1:8172:9817"
173 local stream_url_compare
="tcp4://127.0.0.1:8172/ [data: 9817]"
175 diag
"Test url override for normal session"
177 start_lttng_relayd
"-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
179 local mi_output_file
=$
(mktemp
--tmpdir "tmp.${FUNCNAME[0]}_output_file.XXXXXX")
180 if [ $?
-ne 0 ]; then
184 # Url of style file://
185 lttng_load_ok
"-i $CURDIR/$SESSION_NAME.lttng --override-url=${local_url_override}"
186 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN --mi XML list
"$SESSION_NAME" > $mi_output_file
187 mi_result
=$
("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
189 test $mi_result = "${local_path_compare_value}"
190 ok $?
"Path url file:// override [{$mi_result}, ${local_path_compare_value}]"
191 destroy_lttng_session_ok
"$SESSION_NAME"
194 lttng_load_ok
"-i $CURDIR/$SESSION_NAME.lttng --override-url=${local_path_override}"
195 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN --mi XML list
"$SESSION_NAME" > $mi_output_file
196 mi_result
=$
("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
198 test $mi_result = "${local_path_compare_value}"
199 ok $?
"Path url / override [{$mi_result}, ${local_path_compare_value}]"
200 destroy_lttng_session_ok
"$SESSION_NAME"
202 # Url of style net://ip:port:port
203 lttng_load_ok
"-i $CURDIR/$SESSION_NAME.lttng --override-url=${stream_url_override}"
204 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN --mi XML list
"$SESSION_NAME" > $mi_output_file
205 mi_result
=$
("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
207 test "$mi_result" = "${stream_url_compare}"
208 ok $?
"Path url net://host:port:port override [${mi_result}, ${stream_url_compare}]"
210 destroy_lttng_session_ok
"$SESSION_NAME"
212 rm -rf ${mi_output_file}
215 function test_override_url_snapshot
()
217 local url_override
="file:///tmp/override/to/here"
218 local path_override
="/tmp/override/to/here"
219 local path_compare_value
="/tmp/override/to/here/"
220 local stream_url_override
="net://127.0.0.1:8172:9817"
221 local stream_url_compare_ctrl
="tcp4://127.0.0.1:8172/"
222 local stream_url_compare_data
="tcp4://127.0.0.1:9817/"
223 local local_session_name
="${SESSION_NAME}-snapshot"
225 diag
"Test url override for snapshot session"
227 start_lttng_relayd
"-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
229 local mi_output_file
=$
(mktemp
--tmpdir "tmp.${FUNCNAME[0]}_output_file.XXXXXX")
230 if [ $?
-ne 0 ]; then
234 # Url of style file://
235 lttng_load_ok
"-i $CONFIG_DIR/$local_session_name.lttng --override-url=${url_override}"
236 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN --mi XML snapshot list-output
-s "$local_session_name" > $mi_output_file
237 mi_result
=$
("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url")
239 test $mi_result = "${path_compare_value}"
240 ok $?
"Path url file:// override [{$mi_result}, ${path_compare_value}]"
241 destroy_lttng_session_ok
"$local_session_name"
244 lttng_load_ok
"-i $CONFIG_DIR/$local_session_name.lttng --override-url=${path_override}"
245 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN --mi XML snapshot list-output
-s "$local_session_name" > $mi_output_file
246 mi_result
=$
("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url")
248 test $mi_result = "${path_compare_value}"
249 ok $?
"Path url / override [{$mi_result}, ${path_compare_value}]"
250 destroy_lttng_session_ok
"$local_session_name"
252 # Url of style net://ip:port:port
253 lttng_load_ok
"-i $CONFIG_DIR/$local_session_name.lttng --override-url=${stream_url_override}"
254 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN --mi XML snapshot list-output
-s "$local_session_name" > $mi_output_file
255 mi_result
=$
("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url")
257 test "$mi_result" = "${stream_url_compare_ctrl}"
258 ok $?
"Path url ctrl net://host:port:port override [${mi_result}, ${stream_url_compare_ctrl}]"
260 mi_result
=$
("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:data_url")
262 test "$mi_result" = "${stream_url_compare_data}"
263 ok $?
"Path url data net://host:port:port override [${mi_result}, ${stream_url_compare_data}]"
265 destroy_lttng_session_ok
"$local_session_name"
267 rm -rf ${mi_output_file}
270 function test_override_url_live
()
272 local url_override
="file:///tmp/override/to/here"
273 local path_override
="/tmp/override/to/here"
274 local path_compare_value
="/tmp/override/to/here/"
275 local stream_url_override
="net://127.0.0.1:8172:9817"
276 local stream_url_compare
="tcp4://127.0.0.1:8172/ [data: 9817]"
277 local local_session_name
="${SESSION_NAME}-live"
279 diag
"Test url override for live session"
281 start_lttng_relayd
"-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
283 local mi_output_file
=$
(mktemp
--tmpdir "tmp.${FUNCNAME[0]}_output_file.XXXXXX")
284 if [ $?
-ne 0 ]; then
288 # Url of style file://
289 # Expect this to fail since live session should never accept local
291 lttng_load_fail
"-i $CONFIG_DIR/$local_session_name.lttng --override-url=${url_override}"
292 destroy_lttng_session_fail
"$local_session_name"
295 # Expect this to fail since live session should never accept local
297 lttng_load_fail
"-i $CONFIG_DIR/$local_session_name.lttng --override-url=${path_override}"
298 destroy_lttng_session_fail
"$local_session_name"
300 # Url of style net://ip:port:port
301 lttng_load_ok
"-i $CONFIG_DIR/$local_session_name.lttng --override-url=${stream_url_override}"
302 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN --mi XML list
"$local_session_name" > $mi_output_file
303 mi_result
=$
("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
305 test "$mi_result" = "${stream_url_compare}"
306 ok $?
"Path url net://host:port:port override [${mi_result}, ${stream_url_compare}]"
308 destroy_lttng_session_ok
"$local_session_name"
310 rm -rf ${mi_output_file}
313 function test_override_session_name
()
315 diag
"Test session name override"
316 local override_name
="PinkyAndTheBrain"
317 local output_path
="/tmp/lttng/load-42-1"
319 local mi_output_file
=$
(mktemp
--tmpdir "tmp.${FUNCNAME[0]}_output_file.XXXXXX")
320 if [ $?
-ne 0 ]; then
324 lttng_load_ok
"-i ${CURDIR}/${SESSION_NAME}.lttng --override-name=${override_name} ${SESSION_NAME}"
325 ${TESTDIR}/../src/bin/lttng/${LTTNG_BIN} --mi XML list "${SESSION_NAME}" &> /dev/null
326 if [ $? -eq 0 ]; then
327 fail "Expected a failure on listing
for old session name
"
330 ${TESTDIR}/../src/bin/lttng/${LTTNG_BIN} --mi XML list "${override_name}" > $mi_output_file
331 mi_result
=$
("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:name")
333 test "${mi_result}" = "${override_name}"
334 ok $?
"Override name successful [${SESSION_NAME} to ${override_name}]"
336 # Make sure that the name override did not change something else
337 mi_result
=$
("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
338 test "${mi_result}" = "${output_path}"
339 ok $?
"Output path is not affected by name override"
341 destroy_lttng_session_ok
"${override_name}"
343 diag
"Test session name override with all (Do not permit)"
344 lttng_load_fail
"-i ${CURDIR}/${SESSION_NAME}.lttng --override-name=${override_name}"
346 rm -rf ${mi_output_file}
357 test_override_session_name
358 test_override_url_normal
359 test_override_url_snapshot
360 test_override_url_live
363 for fct_test
in ${TESTS[@]};
365 TRACE_PATH
=$
(mktemp
--tmpdir -d tmp.test_load_trace_path.XXXXXX
)
368 if [ $?
-ne 0 ]; then
371 # Only delete if successful