Commit | Line | Data |
---|---|---|
5784f835 JR |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2016 Jonathan Rajotte <jonathan.rajotte-julien@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="Session creation based on template" | |
19 | ||
20 | CURDIR=$(dirname $0)/ | |
21 | TESTDIR=$CURDIR/../../../ | |
22 | SESSIOND_BIN="lttng-sessiond" | |
23 | RELAYD_BIN="lttng-relayd" | |
24 | ||
25 | export LTTNG_SESSION_CONFIG_XSD_PATH=$(readlink -m ${TESTDIR}../src/common/config/) | |
26 | ||
27 | SESSION_NAME="load-42" | |
28 | ||
29 | DIR=$(readlink -f $TESTDIR) | |
30 | ||
31 | NUM_TESTS=89 | |
32 | ||
33 | source $TESTDIR/utils/utils.sh | |
34 | ||
35 | LTTNG_BIN="lttng --mi xml" | |
36 | ||
37 | # MUST set TESTDIR before calling those functions | |
38 | plan_tests $NUM_TESTS | |
39 | ||
40 | print_test_banner "$TEST_DESC" | |
41 | ||
42 | #Test related data | |
43 | ||
44 | XPATH_SESSION_NAME="//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:name/text()" | |
45 | XPATH_SESSION_PATH="//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path/text()" | |
46 | XPATH_SESSION_SNAPSHOT_MODE="//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:snapshot_mode/text()" | |
47 | XPATH_SESSION_SNAPSHOT_CTRL_URL="//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url/text()" | |
48 | XPATH_SESSION_SNAPSHOT_DATA_URL="//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:data_url/text()" | |
49 | XPATH_SESSION_LIVE_TIMER_INTERVAL="//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:live_timer_interval/text()" | |
50 | XPATH_SAVE_SESSION_SHM_PATH="//sessions/session/shared_memory_path/text()" | |
51 | ||
52 | TEMPLATE_DIR="$CURDIR/sessions" | |
53 | ||
54 | # TODO: note: most of these fuctions could have been tested via lttng save and | |
55 | # diffing the original and the saved one. Might want to go this way... | |
56 | ||
57 | function test_normal_local() | |
58 | { | |
59 | diag "Load from template a normal session with local consumer output" | |
60 | local template_name="normal_local.lttng" | |
61 | local session_name="normal_local" | |
62 | local output_path="/home/jonathan/lttng-traces/normal_local-20160606-132532" | |
63 | ||
64 | local template_path="$TEMPLATE_DIR/$template_name" | |
65 | ||
66 | local mi_output_file=$(mktemp) | |
67 | if [ $? -ne 0 ]; then | |
68 | break; | |
69 | fi | |
70 | ||
71 | ||
72 | create_lttng_session_template_ok "$template_path" | |
73 | ||
74 | OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name | |
75 | ||
76 | # Validate name | |
77 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_NAME}") | |
78 | if [[ $mi_result = "$session_name" ]]; then | |
79 | ok 0 "Session names are the same" | |
80 | else | |
81 | fail "Session names should be $session_name but value is $mi_result" | |
82 | fi | |
83 | ||
84 | # Validate output | |
85 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") | |
86 | if [[ $mi_result = "$output_path" ]]; then | |
87 | ok 0 "Output paths are the same" | |
88 | else | |
89 | fail "Output paths should be $output_path but value is $mi_result" | |
90 | fi | |
91 | ||
92 | destroy_lttng_session_ok $session_name | |
93 | } | |
94 | ||
95 | function test_normal_no_output() | |
96 | { | |
97 | diag "Load from template a normal session with no output (--no-output)" | |
98 | local template_name="normal_no_output.lttng" | |
99 | local session_name="normal_no_output" | |
100 | local output_path="" | |
101 | ||
102 | local template_path="$TEMPLATE_DIR/$template_name" | |
103 | ||
104 | local mi_output_file=$(mktemp) | |
105 | if [ $? -ne 0 ]; then | |
106 | break; | |
107 | fi | |
108 | ||
109 | ||
110 | create_lttng_session_template_ok "$template_path" | |
111 | ||
112 | OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name | |
113 | ||
114 | # Validate name | |
115 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_NAME}") | |
116 | if [[ $mi_result = "$session_name" ]]; then | |
117 | ok 0 "Session names are the same" | |
118 | else | |
119 | fail "Session names should be $session_name but value is $mi_result" | |
120 | fi | |
121 | ||
122 | # Validate output | |
123 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") | |
124 | if [[ $mi_result = "$output_path" ]]; then | |
125 | ok 0 "Output paths are the same" | |
126 | else | |
127 | fail "Output paths should be empty but value is $mi_result" | |
128 | fi | |
129 | ||
130 | destroy_lttng_session_ok $session_name | |
131 | } | |
132 | ||
133 | function test_normal_net() | |
134 | { | |
135 | diag "Load from template a normal session with net output" | |
136 | local template_name="normal_net.lttng" | |
137 | local session_name="normal_net" | |
138 | local output_path="tcp4://127.0.0.1:5342/normal_net-20160606-132620 [data: 5343]" | |
139 | ||
140 | local template_path="$TEMPLATE_DIR/$template_name" | |
141 | ||
142 | local mi_output_file=$(mktemp) | |
143 | if [ $? -ne 0 ]; then | |
144 | break; | |
145 | fi | |
146 | ||
147 | ||
148 | create_lttng_session_template_ok "$template_path" | |
149 | ||
150 | OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name | |
151 | ||
152 | # Validate name | |
153 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_NAME}") | |
154 | if [[ $mi_result = "$session_name" ]]; then | |
155 | ok 0 "Session names are the same" | |
156 | else | |
157 | fail "Session names should be $session_name but value is $mi_result" | |
158 | fi | |
159 | ||
160 | # Validate output | |
161 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") | |
162 | if [[ $mi_result = "$output_path" ]]; then | |
163 | ok 0 "Output paths are the same" | |
164 | else | |
165 | fail "Output paths should be empty but value is $mi_result" | |
166 | fi | |
167 | ||
168 | destroy_lttng_session_ok $session_name | |
169 | } | |
170 | ||
171 | function test_snapshot_local() | |
172 | { | |
173 | diag "Load from template a snapshot session with local output" | |
174 | local template_name="snapshot_local.lttng" | |
175 | local session_name="snapshot_local" | |
176 | local output_path="" | |
177 | local snapshot_ctrl_url="/home/jonathan/lttng-traces/snapshot_local-20160606-132651" | |
178 | local snapshot_data_url="" | |
179 | ||
180 | local template_path="$TEMPLATE_DIR/$template_name" | |
181 | ||
182 | local mi_output_file=$(mktemp) | |
183 | if [ $? -ne 0 ]; then | |
184 | break; | |
185 | fi | |
186 | ||
187 | ||
188 | create_lttng_session_template_ok "$template_path" | |
189 | ||
190 | OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name | |
191 | ||
192 | # Validate name | |
193 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_MODE}") | |
194 | if [[ $mi_result = "1" ]]; then | |
195 | ok 0 "Session snapshot mode is enabled" | |
196 | else | |
197 | fail "Session snapshot mode is invalid value is $mi_result" | |
198 | fi | |
199 | ||
200 | # Validate output | |
201 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") | |
202 | if [[ $mi_result = "$output_path" ]]; then | |
203 | ok 0 "Output paths are the same" | |
204 | else | |
205 | fail "Output paths should be empty but value is $mi_result" | |
206 | fi | |
207 | ||
208 | OUTPUT_DEST="$mi_output_file" lttng_snapshot_list $session_name | |
209 | ||
210 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_CTRL_URL}") | |
211 | if [[ $mi_result = "$snapshot_ctrl_url" ]]; then | |
212 | ok 0 "Ctrl urls for snapshot are the same" | |
213 | else | |
214 | fail "Ctrl urls should be $snapshot_ctrl_url but value is $mi_result" | |
215 | fi | |
216 | ||
217 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_DATA_URL}") | |
218 | if [[ $mi_result = "$snapshot_data_url" ]]; then | |
219 | ok 0 "Data urls for snapshot are the same" | |
220 | else | |
221 | fail "Data urls should be $snapshot_data_url but value is $mi_result" | |
222 | fi | |
223 | ||
224 | destroy_lttng_session_ok $session_name | |
225 | } | |
226 | ||
227 | function test_snapshot_net() | |
228 | { | |
229 | diag "Load from template a snapshot session with net output" | |
230 | local template_name="snapshot_net.lttng" | |
231 | local session_name="snapshot_net" | |
232 | local output_path="" | |
233 | local snapshot_ctrl_url="tcp4://127.0.0.1:5342/" | |
234 | local snapshot_data_url="tcp4://127.0.0.1:5343/" | |
235 | ||
236 | local template_path="$TEMPLATE_DIR/$template_name" | |
237 | ||
238 | local mi_output_file=$(mktemp) | |
239 | if [ $? -ne 0 ]; then | |
240 | break; | |
241 | fi | |
242 | ||
243 | create_lttng_session_template_ok "$template_path" | |
244 | ||
245 | OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name | |
246 | ||
247 | # Validate name | |
248 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_MODE}") | |
249 | if [[ $mi_result = "1" ]]; then | |
250 | ok 0 "Session snapshot mode is enabled" | |
251 | else | |
252 | fail "Session snapshot mode is invalid value is $mi_result" | |
253 | fi | |
254 | ||
255 | # Validate output | |
256 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") | |
257 | if [[ $mi_result = "$output_path" ]]; then | |
258 | ok 0 "Output paths are the same" | |
259 | else | |
260 | fail "Output paths should be empty but value is $mi_result" | |
261 | fi | |
262 | ||
263 | OUTPUT_DEST="$mi_output_file" lttng_snapshot_list $session_name | |
264 | ||
265 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_CTRL_URL}") | |
266 | if [[ $mi_result = "$snapshot_ctrl_url" ]]; then | |
267 | ok 0 "Ctrl urls for snapshot are the same" | |
268 | else | |
269 | fail "Ctrl urls should be $snapshot_ctrl_url but value is $mi_result" | |
270 | fi | |
271 | ||
272 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_DATA_URL}") | |
273 | if [[ $mi_result = "$snapshot_data_url" ]]; then | |
274 | ok 0 "Data urls for snapshot are the same" | |
275 | else | |
276 | fail "Data urls should be $snapshot_data_url but value is $mi_result" | |
277 | fi | |
278 | ||
279 | destroy_lttng_session_ok $session_name | |
280 | } | |
281 | ||
282 | function test_live() | |
283 | { | |
284 | diag "Load from template a live session" | |
285 | local template_name="live.lttng" | |
286 | local session_name="live" | |
287 | local output_path="tcp4://127.0.0.1:5342/ [data: 5343]" | |
288 | local live_timer_interval="1000000" | |
289 | ||
290 | local template_path="$TEMPLATE_DIR/$template_name" | |
291 | ||
292 | local mi_output_file=$(mktemp) | |
293 | if [ $? -ne 0 ]; then | |
294 | break; | |
295 | fi | |
296 | ||
297 | ||
298 | create_lttng_session_template_ok "$template_path" | |
299 | ||
300 | OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name | |
301 | ||
302 | # Validate name | |
303 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_NAME}") | |
304 | if [[ $mi_result = "$session_name" ]]; then | |
305 | ok 0 "Session names are the same" | |
306 | else | |
307 | fail "Session names should be $session_name but value is $mi_result" | |
308 | fi | |
309 | ||
310 | # Validate live timer | |
311 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_LIVE_TIMER_INTERVAL}") | |
312 | if [[ $mi_result = "$live_timer_interval" ]]; then | |
313 | ok 0 "Session live timer intervals are the same" | |
314 | else | |
315 | fail "Session live timer should be $live_timer_interval but value is $mi_result" | |
316 | fi | |
317 | ||
318 | # Validate output | |
319 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") | |
320 | if [[ $mi_result = "$output_path" ]]; then | |
321 | ok 0 "Output paths are the same" | |
322 | else | |
323 | fail "Output paths should be empty but value is $mi_result" | |
324 | fi | |
325 | ||
326 | destroy_lttng_session_ok $session_name | |
327 | } | |
328 | ||
329 | function test_shm_path() | |
330 | { | |
331 | # Since lttng list do not expose the shm path save the session and check | |
332 | # for the shm path. | |
333 | diag "Load from template a session with a shared memory path" | |
334 | local template_name="shm_path.lttng" | |
335 | local session_name="shm_path" | |
336 | local shared_memory_path="/tmp/shm_path-20160606-161801" | |
337 | ||
338 | local template_path="$TEMPLATE_DIR/$template_name" | |
339 | ||
340 | local save_output_path=$(mktemp -d) | |
341 | local save_output_file="${save_output_path}/$session_name.lttng" | |
342 | if [ $? -ne 0 ]; then | |
343 | break; | |
344 | fi | |
345 | ||
346 | create_lttng_session_template_ok "$template_path" | |
347 | ||
348 | lttng_save $session_name "-o ${save_output_path}" | |
349 | ||
350 | # Validate name | |
351 | save_result=$($CURDIR/../mi/extract_xml $save_output_file "${XPATH_SAVE_SESSION_SHM_PATH}") | |
352 | if [[ $save_result = "$shared_memory_path" ]]; then | |
353 | ok 0 "Session shared memory paths are the same" | |
354 | else | |
355 | fail "Session shared memory path should be $shared_memory_path but value is $save_result" | |
356 | fi | |
357 | ||
358 | rm $save_output_file | |
359 | rmdir $save_output_path | |
360 | destroy_lttng_session_ok $session_name | |
361 | } | |
362 | ||
363 | # Default data generation | |
364 | function test_name_generation() | |
365 | { | |
366 | diag "Load from template a session with no name" | |
367 | local template_name="name_generation.lttng" | |
368 | local template_path="$TEMPLATE_DIR/$template_name" | |
369 | ||
370 | # On session creation success a name must have been generated. | |
371 | create_lttng_session_template_ok "$template_path" | |
372 | ||
373 | destroy_lttng_session_ok $session_name | |
374 | } | |
375 | ||
376 | function test_normal_output_generation() | |
377 | { | |
378 | diag "Load from template a normal session with no consumer output defined" | |
379 | local template_name="normal_output_generation.lttng" | |
380 | local session_name="normal_output_generation" | |
381 | local output_path="/home/jonathan/lttng-traces/normal_local-20160606-132532" | |
382 | ||
383 | local template_path="$TEMPLATE_DIR/$template_name" | |
384 | ||
385 | local mi_output_file=$(mktemp) | |
386 | if [ $? -ne 0 ]; then | |
387 | break; | |
388 | fi | |
389 | ||
390 | create_lttng_session_template_ok "$template_path" | |
391 | ||
392 | OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name | |
393 | ||
394 | # Validate output | |
395 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") | |
396 | if [ ! -z "$mi_result" ]; then | |
397 | ok 0 "Output path was generated" | |
398 | else | |
399 | fail "Output path should not be empty $mi_result" | |
400 | fi | |
401 | ||
402 | destroy_lttng_session_ok $session_name | |
403 | } | |
404 | ||
405 | function test_snapshot_output_generation() | |
406 | { | |
407 | diag "Load from template a snapshot session with no local output defined" | |
408 | local template_name="snapshot_output_generation.lttng" | |
409 | local session_name="snapshot_output_generation" | |
410 | ||
411 | local template_path="$TEMPLATE_DIR/$template_name" | |
412 | ||
413 | local mi_output_file=$(mktemp) | |
414 | if [ $? -ne 0 ]; then | |
415 | break; | |
416 | fi | |
417 | ||
418 | ||
419 | create_lttng_session_template_ok "$template_path" | |
420 | ||
421 | OUTPUT_DEST="$mi_output_file" lttng_snapshot_list $session_name | |
422 | ||
423 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_CTRL_URL}") | |
424 | if [ ! -z "${mi_result}" ]; then | |
425 | ok 0 "Local snapshot output was generated" | |
426 | else | |
427 | fail "Local snapshot output is null" | |
428 | fi | |
429 | ||
430 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_DATA_URL}") | |
431 | if [ -z "${mi_result}" ]; then | |
432 | ok 0 "Data url is empty as planned" | |
433 | else | |
434 | fail "Data url should be null but value is : $mi_result" | |
435 | fi | |
436 | ||
437 | destroy_lttng_session_ok $session_name | |
438 | } | |
439 | ||
440 | function test_live_output_generation() | |
441 | { | |
442 | diag "Load from template a live session with no consumer output defined" | |
443 | local template_name="live_output_generation.lttng" | |
444 | local session_name="live_output_generation" | |
445 | local output_path="tcp4://127.0.0.1:5342/ [data: 5343]" | |
446 | ||
447 | local template_path="$TEMPLATE_DIR/$template_name" | |
448 | ||
449 | local mi_output_file=$(mktemp) | |
450 | if [ $? -ne 0 ]; then | |
451 | break; | |
452 | fi | |
453 | ||
454 | create_lttng_session_template_ok "$template_path" | |
455 | ||
456 | OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name | |
457 | ||
458 | # Validate output | |
459 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") | |
460 | if [[ $mi_result = "$output_path" ]]; then | |
461 | ok 0 "Output path was generated and value is good: $mi_result" | |
462 | else | |
463 | fail "Output path default is invalid: $mi_result" | |
464 | fi | |
465 | ||
466 | destroy_lttng_session_ok $session_name | |
467 | } | |
468 | ||
469 | # Override | |
470 | function test_overwrite_live_timer() | |
471 | { | |
472 | diag "Load from template a live session - Overwrite live timer" | |
473 | local template_name="live.lttng" | |
474 | local session_name="live" | |
475 | local output_path="tcp4://127.0.0.1:5342/ [data: 5343]" | |
476 | local live_timer_interval="123456" | |
477 | ||
478 | local template_path="$TEMPLATE_DIR/$template_name" | |
479 | ||
480 | local mi_output_file=$(mktemp) | |
481 | if [ $? -ne 0 ]; then | |
482 | break; | |
483 | fi | |
484 | ||
485 | create_lttng_session_template_ok "$template_path" "--live=${live_timer_interval}" | |
486 | ||
487 | OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name | |
488 | ||
489 | # Validate live timer | |
490 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_LIVE_TIMER_INTERVAL}") | |
491 | if [[ $mi_result = "$live_timer_interval" ]]; then | |
492 | ok 0 "Session live timer intervals are the same: $mi_result == $live_timer_interval" | |
493 | else | |
494 | fail "Session live timer should be $live_timer_interval but value is $mi_result" | |
495 | fi | |
496 | ||
497 | destroy_lttng_session_ok $session_name | |
498 | } | |
499 | ||
500 | function test_overwrite_shm_path() | |
501 | { | |
502 | # Since lttng list do not expose the shm path save the session and check | |
503 | # for the shm path. | |
504 | diag "Load from template a session with a shared memory path - Overwrite shm path" | |
505 | local template_name="shm_path.lttng" | |
506 | local session_name="shm_path" | |
507 | local shared_memory_path="/tmp/beer-run" | |
508 | ||
509 | local template_path="$TEMPLATE_DIR/$template_name" | |
510 | ||
511 | local save_output_path=$(mktemp -d) | |
512 | local save_output_file="${save_output_path}/$session_name.lttng" | |
513 | if [ $? -ne 0 ]; then | |
514 | break; | |
515 | fi | |
516 | ||
517 | create_lttng_session_template_ok "$template_path" "--shm-path=${shared_memory_path}" | |
518 | ||
519 | lttng_save $session_name "-o ${save_output_path}" | |
520 | ||
521 | # Validate name | |
522 | save_result=$($CURDIR/../mi/extract_xml $save_output_file "${XPATH_SAVE_SESSION_SHM_PATH}") | |
523 | if [[ $(dirname $save_result) = "$shared_memory_path" ]]; then | |
524 | ok 0 "Session shared memory paths are the same" | |
525 | else | |
526 | fail "Session shared memory path should be $shared_memory_path but value is $save_result" | |
527 | fi | |
528 | ||
529 | rm $save_output_file | |
530 | rmdir $save_output_path | |
531 | destroy_lttng_session_ok $session_name | |
532 | } | |
533 | ||
534 | function test_overwrite_normal_net_to_local() | |
535 | { | |
536 | diag "Load from template a normal session with net output - Overwrite to local output" | |
537 | local template_name="normal_net.lttng" | |
538 | local session_name="normal_net" | |
539 | local output_path="/tmp/beer-run" | |
540 | ||
541 | local template_path="$TEMPLATE_DIR/$template_name" | |
542 | ||
543 | local mi_output_file=$(mktemp) | |
544 | if [ $? -ne 0 ]; then | |
545 | break; | |
546 | fi | |
547 | ||
548 | create_lttng_session_template_ok "$template_path" "--set-url=file://${output_path}" | |
549 | ||
550 | OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name | |
551 | ||
552 | # Validate output | |
553 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") | |
554 | if [[ $mi_result = "$output_path" ]]; then | |
555 | ok 0 "Output paths are the same" | |
556 | else | |
557 | fail "Output paths should be empty but value is $mi_result" | |
558 | fi | |
559 | ||
560 | destroy_lttng_session_ok $session_name | |
561 | ||
562 | create_lttng_session_template_ok "$template_path" "--output=${output_path}" | |
563 | ||
564 | OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name | |
565 | ||
566 | # Validate output | |
567 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") | |
568 | if [[ $mi_result = "$output_path" ]]; then | |
569 | ok 0 "Output paths are the same" | |
570 | else | |
571 | fail "Output paths should be empty but value is $mi_result" | |
572 | fi | |
573 | ||
574 | destroy_lttng_session_ok $session_name | |
575 | ||
576 | } | |
577 | ||
578 | function test_overwrite_snapshot_local_to_net() | |
579 | { | |
580 | diag "Load from template a snapshot session with local output" | |
581 | local template_name="snapshot_local.lttng" | |
582 | local session_name="snapshot_local" | |
583 | local output_path="" | |
584 | local snapshot_ctrl_url="tcp4://127.0.0.1:5342/" | |
585 | local snapshot_data_url="tcp4://127.0.0.1:5343/" | |
586 | ||
587 | local template_path="$TEMPLATE_DIR/$template_name" | |
588 | ||
589 | local mi_output_file=$(mktemp) | |
590 | if [ $? -ne 0 ]; then | |
591 | break; | |
592 | fi | |
593 | ||
594 | create_lttng_session_template_ok "$template_path" "--ctrl-url=${snapshot_ctrl_url} --data-url=${snapshot_data_url}" | |
595 | ||
596 | OUTPUT_DEST="$mi_output_file" lttng_snapshot_list $session_name | |
597 | ||
598 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_CTRL_URL}") | |
599 | if [[ $mi_result = "$snapshot_ctrl_url" ]]; then | |
600 | ok 0 "Ctrl urls for snapshot are the same" | |
601 | else | |
602 | fail "Ctrl urls should be $snapshot_ctrl_url but value is $mi_result" | |
603 | fi | |
604 | ||
605 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_DATA_URL}") | |
606 | if [[ $mi_result = "$snapshot_data_url" ]]; then | |
607 | ok 0 "Data urls for snapshot are the same" | |
608 | else | |
609 | fail "Data urls should be $snapshot_data_url but value is $mi_result" | |
610 | fi | |
611 | ||
612 | destroy_lttng_session_ok $session_name | |
613 | } | |
614 | ||
615 | function test_overwrite_live_net() | |
616 | { | |
617 | diag "Load from template a live session - Overwrite net output" | |
618 | local template_name="live.lttng" | |
619 | local session_name="live" | |
620 | local ctrl_url="tcp4://127.0.0.1:1000/" | |
621 | local data_url="tcp4://127.0.0.1:1001/" | |
622 | local output_path="tcp4://127.0.0.1:1000/ [data: 1001]" | |
623 | ||
624 | local template_path="$TEMPLATE_DIR/$template_name" | |
625 | ||
626 | local mi_output_file=$(mktemp) | |
627 | if [ $? -ne 0 ]; then | |
628 | break; | |
629 | fi | |
630 | ||
631 | create_lttng_session_template_ok "$template_path" "--ctrl-url=${ctrl_url} --data-url=${data_url}" | |
632 | ||
633 | OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name | |
634 | ||
635 | # Validate output | |
636 | mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") | |
637 | if [[ $mi_result = "$output_path" ]]; then | |
638 | ok 0 "Output paths are the same" | |
639 | else | |
640 | fail "Output paths should be empty but value is $mi_result" | |
641 | fi | |
642 | ||
643 | destroy_lttng_session_ok $session_name | |
644 | } | |
645 | ||
646 | # With subchild data | |
647 | function test_full_load() | |
648 | { | |
649 | # Since lttng list do not expose the shm path save the session and check | |
650 | # for the shm path. | |
651 | diag "Load from template a complex session with henabled channel and events" | |
652 | local template_name="full_load.lttng" | |
653 | local session_name="full_load" | |
654 | ||
655 | local template_path="$TEMPLATE_DIR/$template_name" | |
656 | ||
657 | local save_output_path=$(mktemp -d) | |
658 | local save_output_file="${save_output_path}/$session_name.lttng" | |
659 | if [ $? -ne 0 ]; then | |
660 | break; | |
661 | fi | |
662 | ||
663 | create_lttng_session_template_ok "$template_path" | |
664 | ||
665 | lttng_save $session_name "-o ${save_output_path}" | |
666 | ||
667 | # Validate name | |
668 | save_result=$($CURDIR/../mi/extract_xml $save_output_file "${XPATH_SAVE_SESSION_SHM_PATH}") | |
669 | if diff $template_path $save_output_path ; then | |
670 | ok 0 "Session complex load" | |
671 | else | |
672 | fail "Sessions results are different" | |
673 | fi | |
674 | ||
675 | rm $save_output_file | |
676 | rmdir $save_output_path | |
677 | destroy_lttng_session_ok $session_name | |
678 | } | |
679 | ||
680 | TESTS=( | |
681 | test_normal_local | |
682 | test_normal_no_output | |
683 | test_normal_net | |
684 | test_snapshot_local | |
685 | test_snapshot_net | |
686 | test_live | |
687 | test_shm_path | |
688 | # Default data generation | |
689 | test_name_generation | |
690 | test_normal_output_generation | |
691 | test_snapshot_output_generation | |
692 | test_live_output_generation | |
693 | # Override | |
694 | test_overwrite_live_timer | |
695 | test_overwrite_shm_path | |
696 | test_overwrite_normal_net_to_local | |
697 | test_overwrite_snapshot_local_to_net | |
698 | test_overwrite_live_net | |
699 | # With subchild data | |
700 | test_full_load | |
701 | ) | |
702 | ||
703 | start_lttng_relayd | |
704 | start_lttng_sessiond | |
705 | ||
706 | for fct_test in ${TESTS[@]}; | |
707 | do | |
708 | ${fct_test} | |
709 | if [ $? -ne 0 ]; then | |
710 | break; | |
711 | fi | |
712 | # Only delete if successful | |
713 | done | |
714 | ||
715 | stop_lttng_sessiond | |
716 | stop_lttng_relayd | |
717 | ||
718 |