Test: load --override-url
[lttng-tools.git] / tests / regression / tools / save-load / test_load
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
18 TEST_DESC="Load session(s)"
19
20 CURDIR=$(dirname $0)/
21 CONFIG_DIR="${CURDIR}/configuration"
22 TESTDIR=$CURDIR/../../../
23 SESSIOND_BIN="lttng-sessiond"
24 RELAYD_BIN="lttng-relayd"
25 LTTNG_BIN="lttng"
26 export LTTNG_SESSION_CONFIG_XSD_PATH=$(readlink -m ${TESTDIR}../src/common/config/)
27
28 SESSION_NAME="load-42"
29 EVENT_NAME="tp:tptest"
30
31 DIR=$(readlink -f $TESTDIR)
32
33 NUM_TESTS=62
34
35 source $TESTDIR/utils/utils.sh
36
37 # MUST set TESTDIR before calling those functions
38 plan_tests $NUM_TESTS
39
40 print_test_banner "$TEST_DESC"
41
42 function test_basic_load()
43 {
44 diag "Test basic load"
45
46 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng"
47
48 destroy_lttng_session_ok $SESSION_NAME
49 }
50
51 function test_complex_load()
52 {
53 local sess="$SESSION_NAME-complex"
54 local mi_result=""
55 local ret=1
56 diag "Test complex load"
57
58 # Start relayd with localhost binding. The complex session uses those
59 # custom values.
60 start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
61
62 lttng_load_ok "-i $CURDIR/$sess.lttng"
63
64 # Once loaded, we are suppose to be able to disable certain events/channels
65 # thus having a confirmation that it's valid
66 disable_ust_lttng_event $sess uevent1 chan1
67 disable_ust_lttng_event $sess uevent2 chan2
68 disable_ust_lttng_event $sess uevent3* chan3
69
70 disable_ust_lttng_channel $sess chan1
71 disable_ust_lttng_channel $sess chan2
72 disable_ust_lttng_channel $sess chan3
73
74 # Confirm that an event stored as disabled is restored in its disabled state
75 local mi_output_file=$(mktemp)
76 if [ $? -ne 0 ]; then
77 break;
78 fi
79 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list $sess -c chan2 > $mi_output_file
80 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()")
81 if [[ $mi_result = "false" ]]; then
82 ok 0 "Disabled event is loaded in disabled state"
83 else
84 fail "Disabled event is loaded in disabled state"
85 fi
86
87 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()")
88 test $mi_result = "false"
89 ok $? "Disabled event is loaded in disabled state"
90
91 # Check that uevent_same_name_diff_llevel with log level 6 (TRACE_INFO) is enabled
92 # This ensure that the state of events with similar name but not same
93 # descriptor tuple (exclusion,filter,loglevel) is restored correctly.
94 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()")
95 test $mi_result = "true"
96 ok $? "Enabled event with same name but different loglevel is in disabled state"
97
98 destroy_lttng_session_ok $sess
99
100 stop_lttng_relayd
101 rm -rf ${mi_output_file}
102 }
103
104 function test_all_load()
105 {
106 diag "Test load all sessions"
107
108 # Start relayd with localhost binding. The complex session uses those
109 # custom values.
110 start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
111
112 lttng_load_ok "-a -i $CURDIR"
113
114 destroy_lttng_session_ok $SESSION_NAME
115 destroy_lttng_session_ok "$SESSION_NAME-complex"
116 destroy_lttng_session_ok "$SESSION_NAME-trackers"
117
118 stop_lttng_relayd
119 }
120
121 function test_overwrite()
122 {
123 diag "Test load overwrite"
124
125 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng"
126
127 # This one should succeed
128 lttng_load_ok "-f -i $CURDIR $SESSION_NAME"
129
130 destroy_lttng_session_ok $SESSION_NAME
131 }
132
133 function test_trackers()
134 {
135 diag "Test trackers loading"
136
137 lttng_load_ok "-i $CURDIR/$SESSION_NAME-trackers.lttng"
138
139 diag "Test pid tracker"
140 local mi_output_file=$(mktemp)
141 if [ $? -ne 0 ]; then
142 break;
143 fi
144 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME-trackers" > $mi_output_file
145 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:pid_tracker/lttng:targets/lttng:pid_target")
146 if [[ $mi_result = "true" ]]; then
147 ok 0 "Pid target is present"
148 else
149 fail "Pid target missing"
150 fi
151
152 # Test to remove the target just to make sure
153 lttng_untrack_ok "-p 666 -u -s $SESSION_NAME-trackers"
154
155 destroy_lttng_session_ok "$SESSION_NAME-trackers"
156 rm -rf ${mi_output_file}
157 }
158
159 function test_override_url_normal()
160 {
161 local local_url_override="file:///tmp/override/to/here"
162 local local_path_override="/tmp/override/to/here"
163 local local_path_compare_value="/tmp/override/to/here/"
164 local stream_url_override="net://127.0.0.1:8172:9817"
165 local stream_url_compare="tcp4://127.0.0.1:8172/ [data: 9817]"
166
167 diag "Test url override for normal session"
168
169 start_lttng_relayd "-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
170
171 local mi_output_file=$(mktemp)
172 if [ $? -ne 0 ]; then
173 break;
174 fi
175
176 # Url of style file://
177 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${local_url_override}"
178 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file
179 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
180
181 test $mi_result = "${local_path_compare_value}"
182 ok $? "Path url file:// override [{$mi_result}, ${local_path_compare_value}]"
183 destroy_lttng_session_ok "$SESSION_NAME"
184
185 # Url of style /
186 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${local_path_override}"
187 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file
188 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
189
190 test $mi_result = "${local_path_compare_value}"
191 ok $? "Path url / override [{$mi_result}, ${local_path_compare_value}]"
192 destroy_lttng_session_ok "$SESSION_NAME"
193
194 # Url of style net://ip:port:port
195 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${stream_url_override}"
196 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file
197 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
198
199 test "$mi_result" = "${stream_url_compare}"
200 ok $? "Path url net://host:port:port override [${mi_result}, ${stream_url_compare}]"
201
202 destroy_lttng_session_ok "$SESSION_NAME"
203 stop_lttng_relayd
204 rm -rf ${mi_output_file}
205 }
206
207 function test_override_url_snapshot()
208 {
209 local url_override="file:///tmp/override/to/here"
210 local path_override="/tmp/override/to/here"
211 local path_compare_value="/tmp/override/to/here/"
212 local stream_url_override="net://127.0.0.1:8172:9817"
213 local stream_url_compare_ctrl="tcp4://127.0.0.1:8172/"
214 local stream_url_compare_data="tcp4://127.0.0.1:9817/"
215 local local_session_name="${SESSION_NAME}-snapshot"
216
217 diag "Test url override for snapshot session"
218
219 start_lttng_relayd "-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
220
221 local mi_output_file=$(mktemp)
222 if [ $? -ne 0 ]; then
223 break;
224 fi
225
226 # Url of style file://
227 lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${url_override}"
228 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file
229 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")
230
231 test $mi_result = "${path_compare_value}"
232 ok $? "Path url file:// override [{$mi_result}, ${path_compare_value}]"
233 destroy_lttng_session_ok "$local_session_name"
234
235 # Url of style /
236 lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${path_override}"
237 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file
238 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")
239
240 test $mi_result = "${path_compare_value}"
241 ok $? "Path url / override [{$mi_result}, ${path_compare_value}]"
242 destroy_lttng_session_ok "$local_session_name"
243
244 # Url of style net://ip:port:port
245 lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${stream_url_override}"
246 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file
247 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")
248
249 test "$mi_result" = "${stream_url_compare_ctrl}"
250 ok $? "Path url ctrl net://host:port:port override [${mi_result}, ${stream_url_compare_ctrl}]"
251
252 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")
253
254 test "$mi_result" = "${stream_url_compare_data}"
255 ok $? "Path url data net://host:port:port override [${mi_result}, ${stream_url_compare_data}]"
256
257 destroy_lttng_session_ok "$local_session_name"
258 stop_lttng_relayd
259 rm -rf ${mi_output_file}
260 }
261
262 function test_override_url_live()
263 {
264 local url_override="file:///tmp/override/to/here"
265 local path_override="/tmp/override/to/here"
266 local path_compare_value="/tmp/override/to/here/"
267 local stream_url_override="net://127.0.0.1:8172:9817"
268 local stream_url_compare="tcp4://127.0.0.1:8172/ [data: 9817]"
269 local local_session_name="${SESSION_NAME}-live"
270
271 diag "Test url override for live session"
272
273 start_lttng_relayd "-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
274
275 local mi_output_file=$(mktemp)
276 if [ $? -ne 0 ]; then
277 break;
278 fi
279
280 # Url of style file://
281 # Expect this to fail since live session should never accept local
282 # output.
283 lttng_load_fail "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${url_override}"
284 destroy_lttng_session_fail "$local_session_name"
285
286 # Url of style /
287 # Expect this to fail since live session should never accept local
288 # output.
289 lttng_load_fail "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${path_override}"
290 destroy_lttng_session_fail "$local_session_name"
291
292 # Url of style net://ip:port:port
293 lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${stream_url_override}"
294 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$local_session_name" > $mi_output_file
295 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
296
297 test "$mi_result" = "${stream_url_compare}"
298 ok $? "Path url net://host:port:port override [${mi_result}, ${stream_url_compare}]"
299
300 destroy_lttng_session_ok "$local_session_name"
301 stop_lttng_relayd
302 rm -rf ${mi_output_file}
303 }
304
305 start_lttng_sessiond
306
307 TESTS=(
308 test_basic_load
309 test_complex_load
310 test_all_load
311 test_overwrite
312 test_trackers
313 test_override_url_normal
314 test_override_url_snapshot
315 test_override_url_live
316 )
317
318 for fct_test in ${TESTS[@]};
319 do
320 TRACE_PATH=$(mktemp -d)
321
322 ${fct_test}
323 if [ $? -ne 0 ]; then
324 break;
325 fi
326 # Only delete if successful
327 rm -rf $TRACE_PATH
328 done
329
330 stop_lttng_sessiond
This page took 0.05642 seconds and 5 git commands to generate.