trackers: update list/track/untrack commands
[lttng-tools.git] / tests / regression / tools / save-load / test_load
CommitLineData
e02b109b
DG
1#!/bin/bash
2#
3# Copyright (C) - 2014 David Goulet <dgoulet@efficios.com>
4#
5# This library is free software; you can redistribute it and/or modify it under
6# the terms of the GNU Lesser General Public License as published by the Free
7# Software Foundation; version 2.1 of the License.
8#
9# This library is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12# details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this library; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18TEST_DESC="Load session(s)"
19
20CURDIR=$(dirname $0)/
192ac418 21CONFIG_DIR="${CURDIR}/configuration"
e02b109b 22TESTDIR=$CURDIR/../../../
742e5f18 23export LTTNG_SESSION_CONFIG_XSD_PATH=$(readlink -m ${TESTDIR}../src/common/config/)
e02b109b
DG
24
25SESSION_NAME="load-42"
26EVENT_NAME="tp:tptest"
27
28DIR=$(readlink -f $TESTDIR)
29
83d6d6c4 30NUM_TESTS=72
e02b109b
DG
31
32source $TESTDIR/utils/utils.sh
33
34# MUST set TESTDIR before calling those functions
35plan_tests $NUM_TESTS
36
37print_test_banner "$TEST_DESC"
38
e02b109b
DG
39function test_basic_load()
40{
41 diag "Test basic load"
42
192ac418 43 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng"
e02b109b 44
67b4c664 45 destroy_lttng_session_ok $SESSION_NAME
e02b109b
DG
46}
47
48function test_complex_load()
49{
50 local sess="$SESSION_NAME-complex"
26313f02
JR
51 local mi_result=""
52 local ret=1
e02b109b
DG
53 diag "Test complex load"
54
55 # Start relayd with localhost binding. The complex session uses those
56 # custom values.
57 start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
58
192ac418 59 lttng_load_ok "-i $CURDIR/$sess.lttng"
e02b109b
DG
60
61 # Once loaded, we are suppose to be able to disable certain events/channels
62 # thus having a confirmation that it's valid
722f854b
JR
63 disable_ust_lttng_event $sess uevent1 chan1
64 disable_ust_lttng_event $sess uevent2 chan2
65 disable_ust_lttng_event $sess uevent3* chan3
e02b109b
DG
66
67 disable_ust_lttng_channel $sess chan1
68 disable_ust_lttng_channel $sess chan2
69 disable_ust_lttng_channel $sess chan3
70
ea05d84b
JG
71 # Confirm that an event stored as disabled is restored in its disabled state
72 local mi_output_file=$(mktemp)
73 if [ $? -ne 0 ]; then
74 break;
75 fi
373ff56c 76 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list $sess -c chan2 > $mi_output_file
272ba89a 77 mi_result=$($CURDIR/../mi/extract_xml $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()")
ea05d84b
JG
78 if [[ $mi_result = "false" ]]; then
79 ok 0 "Disabled event is loaded in disabled state"
80 else
81 fail "Disabled event is loaded in disabled state"
82 fi
26313f02
JR
83
84 mi_result=$($CURDIR/../mi/extract_xml $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()")
85 test $mi_result = "false"
86 ok $? "Disabled event is loaded in disabled state"
87
88 # Check that uevent_same_name_diff_llevel with log level 6 (TRACE_INFO) is enabled
89 # This ensure that the state of events with similar name but not same
90 # descriptor tuple (exclusion,filter,loglevel) is restored correctly.
91 mi_result=$($CURDIR/../mi/extract_xml $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()")
92 test $mi_result = "true"
93 ok $? "Enabled event with same name but different loglevel is in disabled state"
94
67b4c664 95 destroy_lttng_session_ok $sess
e02b109b 96
7182f137 97 rm $mi_output_file
05aa48da 98 stop_lttng_relayd
192ac418 99 rm -rf ${mi_output_file}
e02b109b
DG
100}
101
102function test_all_load()
103{
104 diag "Test load all sessions"
105
106 # Start relayd with localhost binding. The complex session uses those
107 # custom values.
108 start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
109
192ac418 110 lttng_load_ok "-a -i $CURDIR"
e02b109b 111
67b4c664
JR
112 destroy_lttng_session_ok $SESSION_NAME
113 destroy_lttng_session_ok "$SESSION_NAME-complex"
722f854b 114 destroy_lttng_session_ok "$SESSION_NAME-trackers"
e02b109b 115
05aa48da 116 stop_lttng_relayd
e02b109b
DG
117}
118
119function test_overwrite()
120{
121 diag "Test load overwrite"
122
192ac418 123 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng"
e02b109b
DG
124
125 # This one should succeed
192ac418 126 lttng_load_ok "-f -i $CURDIR $SESSION_NAME"
e02b109b 127
67b4c664 128 destroy_lttng_session_ok $SESSION_NAME
e02b109b
DG
129}
130
722f854b
JR
131function test_trackers()
132{
133 diag "Test trackers loading"
134
192ac418 135 lttng_load_ok "-i $CURDIR/$SESSION_NAME-trackers.lttng"
722f854b
JR
136
137 diag "Test pid tracker"
138 local mi_output_file=$(mktemp)
139 if [ $? -ne 0 ]; then
140 break;
141 fi
142 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME-trackers" > $mi_output_file
83d6d6c4 143 mi_result=$($CURDIR/../mi/extract_xml -e $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:trackers/lttng:vpid_tracker/lttng:targets/lttng:vpid_target")
722f854b 144 if [[ $mi_result = "true" ]]; then
83d6d6c4 145 ok 0 "VPID target is present"
722f854b 146 else
83d6d6c4
JR
147 fail "VPID target missing"
148 fi
149
150 mi_result=$($CURDIR/../mi/extract_xml -e $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:trackers/lttng:vuid_tracker/lttng:targets/lttng:vuid_target")
151 if [[ $mi_result = "true" ]]; then
152 ok 0 "VUID target is present"
153 else
154 fail "VUID target missing"
155 fi
156
157 mi_result=$($CURDIR/../mi/extract_xml -e $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:trackers/lttng:vgid_tracker/lttng:targets/lttng:vgid_target")
158 if [[ $mi_result = "true" ]]; then
159 ok 0 "VGID target is present"
160 else
161 fail "VGID target missing"
722f854b
JR
162 fi
163
164 # Test to remove the target just to make sure
83d6d6c4
JR
165 lttng_untrack_ok "--vpid 666 -u -s $SESSION_NAME-trackers"
166 lttng_untrack_ok "--vuid 777 -u -s $SESSION_NAME-trackers"
167 lttng_untrack_ok "--vgid 888 -u -s $SESSION_NAME-trackers"
168 # Actually using vpid (backward compat)
169 lttng_untrack_ok "--pid 999 -u -s $SESSION_NAME-trackers"
722f854b
JR
170
171 destroy_lttng_session_ok "$SESSION_NAME-trackers"
83d6d6c4 172 rm -f ${mi_output_file}
192ac418
JR
173}
174
175function test_override_url_normal()
176{
177 local local_url_override="file:///tmp/override/to/here"
178 local local_path_override="/tmp/override/to/here"
179 local local_path_compare_value="/tmp/override/to/here/"
180 local stream_url_override="net://127.0.0.1:8172:9817"
181 local stream_url_compare="tcp4://127.0.0.1:8172/ [data: 9817]"
182
183 diag "Test url override for normal session"
184
185 start_lttng_relayd "-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
186
187 local mi_output_file=$(mktemp)
188 if [ $? -ne 0 ]; then
189 break;
190 fi
191
192 # Url of style file://
193 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${local_url_override}"
194 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file
195 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
196
197 test $mi_result = "${local_path_compare_value}"
198 ok $? "Path url file:// override [{$mi_result}, ${local_path_compare_value}]"
199 destroy_lttng_session_ok "$SESSION_NAME"
200
201 # Url of style /
202 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${local_path_override}"
203 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file
204 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
205
206 test $mi_result = "${local_path_compare_value}"
207 ok $? "Path url / override [{$mi_result}, ${local_path_compare_value}]"
208 destroy_lttng_session_ok "$SESSION_NAME"
209
210 # Url of style net://ip:port:port
211 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${stream_url_override}"
212 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file
213 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
214
215 test "$mi_result" = "${stream_url_compare}"
216 ok $? "Path url net://host:port:port override [${mi_result}, ${stream_url_compare}]"
217
218 destroy_lttng_session_ok "$SESSION_NAME"
219 stop_lttng_relayd
220 rm -rf ${mi_output_file}
221}
222
223function test_override_url_snapshot()
224{
225 local url_override="file:///tmp/override/to/here"
226 local path_override="/tmp/override/to/here"
227 local path_compare_value="/tmp/override/to/here/"
228 local stream_url_override="net://127.0.0.1:8172:9817"
229 local stream_url_compare_ctrl="tcp4://127.0.0.1:8172/"
230 local stream_url_compare_data="tcp4://127.0.0.1:9817/"
231 local local_session_name="${SESSION_NAME}-snapshot"
232
233 diag "Test url override for snapshot session"
234
235 start_lttng_relayd "-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
236
237 local mi_output_file=$(mktemp)
238 if [ $? -ne 0 ]; then
239 break;
240 fi
241
242 # Url of style file://
243 lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${url_override}"
244 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file
245 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url")
246
247 test $mi_result = "${path_compare_value}"
248 ok $? "Path url file:// override [{$mi_result}, ${path_compare_value}]"
249 destroy_lttng_session_ok "$local_session_name"
250
251 # Url of style /
252 lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${path_override}"
253 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file
254 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url")
255
256 test $mi_result = "${path_compare_value}"
257 ok $? "Path url / override [{$mi_result}, ${path_compare_value}]"
258 destroy_lttng_session_ok "$local_session_name"
259
260 # Url of style net://ip:port:port
261 lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${stream_url_override}"
262 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file
263 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url")
264
265 test "$mi_result" = "${stream_url_compare_ctrl}"
266 ok $? "Path url ctrl net://host:port:port override [${mi_result}, ${stream_url_compare_ctrl}]"
267
268 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:data_url")
269
270 test "$mi_result" = "${stream_url_compare_data}"
271 ok $? "Path url data net://host:port:port override [${mi_result}, ${stream_url_compare_data}]"
272
273 destroy_lttng_session_ok "$local_session_name"
274 stop_lttng_relayd
275 rm -rf ${mi_output_file}
276}
277
278function test_override_url_live()
279{
280 local url_override="file:///tmp/override/to/here"
281 local path_override="/tmp/override/to/here"
282 local path_compare_value="/tmp/override/to/here/"
283 local stream_url_override="net://127.0.0.1:8172:9817"
284 local stream_url_compare="tcp4://127.0.0.1:8172/ [data: 9817]"
285 local local_session_name="${SESSION_NAME}-live"
286
287 diag "Test url override for live session"
288
289 start_lttng_relayd "-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
290
291 local mi_output_file=$(mktemp)
292 if [ $? -ne 0 ]; then
293 break;
294 fi
295
296 # Url of style file://
297 # Expect this to fail since live session should never accept local
298 # output.
299 lttng_load_fail "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${url_override}"
300 destroy_lttng_session_fail "$local_session_name"
301
302 # Url of style /
303 # Expect this to fail since live session should never accept local
304 # output.
305 lttng_load_fail "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${path_override}"
306 destroy_lttng_session_fail "$local_session_name"
307
308 # Url of style net://ip:port:port
309 lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${stream_url_override}"
310 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$local_session_name" > $mi_output_file
311 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
312
313 test "$mi_result" = "${stream_url_compare}"
314 ok $? "Path url net://host:port:port override [${mi_result}, ${stream_url_compare}]"
315
316 destroy_lttng_session_ok "$local_session_name"
317 stop_lttng_relayd
318 rm -rf ${mi_output_file}
722f854b
JR
319}
320
5f735641
JR
321function test_override_session_name()
322{
323 diag "Test session name override"
324 local override_name="PinkyAndTheBrain"
a04d7147 325 local output_path="/tmp/lttng/load-42-1"
5f735641
JR
326
327 local mi_output_file=$(mktemp)
328 if [ $? -ne 0 ]; then
329 break;
330 fi
331
332 lttng_load_ok "-i ${CURDIR}/${SESSION_NAME}.lttng --override-name=${override_name} ${SESSION_NAME}"
333 ${TESTDIR}/../src/bin/lttng/${LTTNG_BIN} --mi XML list "${SESSION_NAME}" &> /dev/null
334 if [ $? -eq 0 ]; then
335 fail "Expected a failure on listing for old session name"
336 fi
337
338 ${TESTDIR}/../src/bin/lttng/${LTTNG_BIN} --mi XML list "${override_name}" > $mi_output_file
339 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:name")
340
341 test "${mi_result}" = "${override_name}"
342 ok $? "Override name successful [${SESSION_NAME} to ${override_name}]"
a04d7147
JR
343
344 # Make sure that the name override did not change something else
345 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
346 test "${mi_result}" = "${output_path}"
347 ok $? "Output path is not affected by name override"
348
5f735641
JR
349 destroy_lttng_session_ok "${override_name}"
350
351 diag "Test session name override with all (Do not permit)"
352 lttng_load_fail "-i ${CURDIR}/${SESSION_NAME}.lttng --override-name=${override_name}"
353
354 rm -rf ${mi_output_file}
355}
356
e02b109b
DG
357start_lttng_sessiond
358
359TESTS=(
360 test_basic_load
361 test_complex_load
362 test_all_load
363 test_overwrite
722f854b 364 test_trackers
a04d7147 365 test_override_session_name
192ac418
JR
366 test_override_url_normal
367 test_override_url_snapshot
368 test_override_url_live
e02b109b
DG
369)
370
371for fct_test in ${TESTS[@]};
372do
373 TRACE_PATH=$(mktemp -d)
374
375 ${fct_test}
376 if [ $? -ne 0 ]; then
377 break;
378 fi
379 # Only delete if successful
380 rm -rf $TRACE_PATH
381done
382
383stop_lttng_sessiond
This page took 0.083158 seconds and 4 git commands to generate.