Tests: MI: {add, list, remove}-trigger
[deliverable/lttng-tools.git] / tests / regression / tools / relayd-grouping / test_ust
1 #!/bin/bash
2 #
3 # Copyright (C) 2018 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
4 #
5 # SPDX-License-Identifier: LGPL-2.1-only
6
7 TEST_DESC="LTTng relayd filesystem grouping - Userspace tracing"
8
9 CURDIR=$(dirname "$0")/
10 TESTDIR=$CURDIR/../../..
11 NR_ITER=10
12 NR_USEC_WAIT=100
13 TESTAPP_PATH="$TESTDIR/utils/testapp"
14 TESTAPP_NAME="gen-ust-events"
15 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
16 EVENT_NAME="tp:tptest"
17 CHANNEL_NAME="my_channel"
18
19 XSD_PATH=$TESTDIR/../src/common/mi-lttng-4.0.xsd
20
21 XML_VALIDATE="$TESTDIR/utils/xml-utils/validate_xml $XSD_PATH"
22 XML_EXTRACT="$TESTDIR/utils/xml-utils/extract_xml"
23
24 XPATH_CMD_OUTPUT="//lttng:command/lttng:output"
25 XPATH_SESSION="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session"
26
27
28 NUM_TESTS=688
29
30 source "$TESTDIR/utils/utils.sh"
31
32 if [ ! -x "$TESTAPP_BIN" ]; then
33 BAIL_OUT "No UST events binary detected."
34 fi
35
36 function get_auto_session_name ()
37 {
38 local __result=$1
39
40 local lttng_bin=$LTTNG_BIN
41
42 LTTNG_BIN="${lttng_bin} --mi xml"
43 OUTPUT_DEST=$(mktemp --tmpdir "tmp.${FUNCNAME[0]}_output.XXXXXX")
44
45 list_lttng_with_opts
46 $XML_VALIDATE "$OUTPUT_DEST"
47 ok $? "Valid lttng list XML"
48
49 value=$($XML_EXTRACT "$OUTPUT_DEST" ${XPATH_SESSION}/lttng:name/text\(\))
50 ok $? "Extraction of session name"
51 rm -f $OUTPUT_DEST
52 OUTPUT_DEST=/dev/null
53 LTTNG_BIN=$lttng_bin
54
55 # Transfer value to passed arguments
56 eval "$__result='$value'"
57 }
58
59 function test_ust_uid_live ()
60 {
61 local session_name="$1"
62 local grouping="$2"
63 local is_automatic_session=false
64
65 if [ -z "$session_name" ]; then
66 is_automatic_session=true
67 fi
68
69 diag "Test UST uid buffer live [$grouping][${session_name:-automatic session name}]"
70
71 create_lttng_session_uri "$session_name" net://localhost --live
72 if [ "$is_automatic_session" = true ]; then
73 get_auto_session_name session_name
74 fi
75
76 enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
77 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
78 start_lttng_tracing_ok "$session_name"
79
80 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
81
82 stop_lttng_tracing_ok "$session_name"
83 destroy_lttng_session_ok "$session_name"
84
85 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
86 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
87 else
88 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*"
89 fi
90
91 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
92 rm -rf "${TRACE_PATH:?}/$session_name"
93 else
94 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
95 fi
96 }
97
98 function test_ust_pid_live ()
99 {
100 local session_name="$1"
101 local grouping="$2"
102 local is_automatic_session=false
103
104 if [ -z "$session_name" ]; then
105 is_automatic_session=true
106 fi
107
108 diag "Test UST pid buffer live [$grouping][${session_name:-automatic session name}]"
109
110 create_lttng_session_uri "$session_name" net://localhost --live
111 if [ "$is_automatic_session" = true ]; then
112 get_auto_session_name session_name
113 fi
114
115 enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-pid"
116 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
117 start_lttng_tracing_ok "$session_name"
118
119 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
120
121 stop_lttng_tracing_ok "$session_name"
122 destroy_lttng_session_ok "$session_name"
123
124 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
125 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
126 else
127 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*"
128 fi
129
130 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
131 rm -rf "${TRACE_PATH:?}/$session_name"
132 else
133 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
134 fi
135 }
136
137 function test_ust_uid_live_custom_output ()
138 {
139 local session_name="$1"
140 local grouping="$2"
141 local custom_output="my_live_custom_output"
142 local is_automatic_session=false
143
144 if [ -z "$session_name" ]; then
145 is_automatic_session=true
146 fi
147
148 diag "Test UST uid buffer live, custom output [$grouping][${session_name:-automatic session name}]"
149
150 create_lttng_session_uri "$session_name" net://localhost/$custom_output --live
151 if [ "$is_automatic_session" = true ]; then
152 get_auto_session_name session_name
153 fi
154
155 enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
156 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
157 start_lttng_tracing_ok "$session_name"
158
159 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
160
161 stop_lttng_tracing_ok "$session_name"
162 destroy_lttng_session_ok "$session_name"
163
164 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
165 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$custom_output"
166 else
167 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$custom_output"
168 fi
169
170 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
171 rm -rf "${TRACE_PATH:?}/$session_name"
172 else
173 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
174 fi
175 }
176
177 function test_ust_uid_streaming ()
178 {
179 local session_name="$1"
180 local grouping="$2"
181 local is_automatic_session=false
182
183 if [ -z "$session_name" ]; then
184 is_automatic_session=true
185 fi
186
187 diag "Test UST uid buffer streaming [$grouping][${session_name:-automatic session name}]"
188
189 create_lttng_session_uri "$session_name" net://localhost
190 if [ "$is_automatic_session" = true ]; then
191 get_auto_session_name session_name
192 fi
193
194 enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
195 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
196 start_lttng_tracing_ok "$session_name"
197
198 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
199
200 stop_lttng_tracing_ok "$session_name"
201 destroy_lttng_session_ok "$session_name"
202
203 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
204 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
205 else
206 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*"
207 fi
208
209 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
210 rm -rf "${TRACE_PATH:?}/$session_name"
211 else
212 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
213 fi
214 }
215
216 function test_ust_pid_streaming ()
217 {
218 local session_name="$1"
219 local grouping="$2"
220 local is_automatic_session=false
221
222 if [ -z "$session_name" ]; then
223 is_automatic_session=true
224 fi
225
226 diag "Test UST pid buffer streaming [$grouping][${session_name:-automatic session name}]"
227
228 create_lttng_session_uri "$session_name" net://localhost
229 if [ "$is_automatic_session" = true ]; then
230 get_auto_session_name session_name
231 fi
232
233 enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-pid"
234 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
235 start_lttng_tracing_ok "$session_name"
236
237 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
238
239 stop_lttng_tracing_ok "$session_name"
240 destroy_lttng_session_ok "$session_name"
241
242 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
243 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
244 else
245 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*"
246 fi
247
248 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
249 rm -rf "${TRACE_PATH:?}/$session_name"
250 else
251 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
252 fi
253 }
254
255 function test_ust_uid_streaming_custom_output ()
256 {
257 local session_name="$1"
258 local grouping="$2"
259 local custom_output="custom_second_token"
260 local is_automatic_session=false
261
262 if [ -z "$session_name" ]; then
263 is_automatic_session=true
264 fi
265
266 diag "Test UST uid buffer streaming, custom output [$grouping][${session_name:-automatic session name}]"
267
268 create_lttng_session_uri "$session_name" net://localhost/$custom_output
269 if [ "$is_automatic_session" = true ]; then
270 get_auto_session_name session_name
271 fi
272
273 enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
274 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
275 start_lttng_tracing_ok "$session_name"
276
277 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
278
279 stop_lttng_tracing_ok "$session_name"
280 destroy_lttng_session_ok "$session_name"
281
282 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
283 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$custom_output"
284 else
285 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$custom_output"
286 fi
287
288 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
289 rm -rf "${TRACE_PATH:?}/$session_name"
290 else
291 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
292 fi
293 }
294
295 function test_ust_uid_streaming_rotate ()
296 {
297 local session_name="$1"
298 local grouping="$2"
299 local is_automatic_session=false
300
301 if [ -z "$session_name" ]; then
302 is_automatic_session=true
303 fi
304
305 diag "Test UST uid buffer rotate [$grouping][${session_name:-automatic session name}]"
306
307 create_lttng_session_uri "$session_name" net://localhost
308 if [ "$is_automatic_session" = true ]; then
309 get_auto_session_name session_name
310 fi
311
312 enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
313 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
314 start_lttng_tracing_ok "$session_name"
315
316 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
317 rotate_session_ok "$session_name"
318
319 stop_lttng_tracing_ok "$session_name"
320 destroy_lttng_session_ok "$session_name"
321
322 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
323 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
324 else
325 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*"
326 fi
327
328 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
329 rm -rf "${TRACE_PATH:?}/$session_name"
330 else
331 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
332 fi
333 }
334
335 function test_ust_uid_streaming_rotate_custom_output ()
336 {
337 local session_name="$1"
338 local grouping="$2"
339 local custom_output="rotate_custom_path"
340 local is_automatic_session=false
341
342 if [ -z "$session_name" ]; then
343 is_automatic_session=true
344 fi
345
346 diag "Test UST uid buffer rotate, custom output [$grouping][${session_name:-automatic session name}]"
347
348 create_lttng_session_uri "$session_name" net://localhost/$custom_output
349 if [ "$is_automatic_session" = true ]; then
350 get_auto_session_name session_name
351 fi
352
353 enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
354 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
355 start_lttng_tracing_ok "$session_name"
356
357 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
358 rotate_session_ok "$session_name"
359
360
361 stop_lttng_tracing_ok "$session_name"
362 destroy_lttng_session_ok "$session_name"
363
364 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
365 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$custom_output"
366 else
367 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$custom_output"
368 fi
369
370 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
371 rm -rf "${TRACE_PATH:?}/$session_name"
372 else
373 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
374 fi
375 }
376
377 function test_ust_pid_streaming_rotate ()
378 {
379 local session_name="$1"
380 local grouping="$2"
381 local is_automatic_session=false
382
383 if [ -z "$session_name" ]; then
384 is_automatic_session=true
385 fi
386
387 diag "Test UST pid buffer rotate with session_name [$grouping][${session_name:-automatic session name}]"
388
389 create_lttng_session_uri "$session_name" net://localhost
390 if [ "$is_automatic_session" = true ]; then
391 get_auto_session_name session_name
392 fi
393
394 enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-pid"
395 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
396 start_lttng_tracing_ok "$session_name"
397
398 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
399 rotate_session_ok "$session_name"
400
401 stop_lttng_tracing_ok "$session_name"
402 destroy_lttng_session_ok "$session_name"
403
404 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
405 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
406 else
407 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*"
408 fi
409
410 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
411 rm -rf "${TRACE_PATH:?}/$session_name"
412 else
413 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
414 fi
415 }
416
417 function test_ust_uid_streaming_snapshot ()
418 {
419 local session_name="$1"
420 local grouping="$2"
421 local is_automatic_session=false
422
423 if [ -z "$session_name" ]; then
424 is_automatic_session=true
425 fi
426
427 diag "Test UST uid buffer snapshot streaming using 'create --snapshot' [$grouping][${session_name:-automatic session name}]"
428
429 create_lttng_session_uri "$session_name" net://localhost --snapshot
430 if [ "$is_automatic_session" = true ]; then
431 get_auto_session_name session_name
432 fi
433
434 enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid"
435 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
436 start_lttng_tracing_ok "$session_name"
437
438 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
439 lttng_snapshot_record "$session_name"
440
441 stop_lttng_tracing_ok "$session_name"
442 destroy_lttng_session_ok "$session_name"
443
444 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
445 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*"
446 else
447 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*"
448 fi
449
450 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
451 rm -rf "${TRACE_PATH:?}/$session_name"
452 else
453 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
454 fi
455 }
456
457 function test_ust_pid_streaming_snapshot ()
458 {
459 local session_name="$1"
460 local grouping="$2"
461 local is_automatic_session=false
462
463 local file_sync_after_first
464 local file_sync_before_last
465
466 file_sync_after_first=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX")
467 file_sync_before_last=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
468
469 if [ -z "$session_name" ]; then
470 is_automatic_session=true
471 fi
472
473 diag "Test UST pid buffer snapshot streaming using 'create --snapshot' [$grouping][${session_name:-automatic session name}]"
474
475 create_lttng_session_uri "$session_name" net://localhost --snapshot
476 if [ "$is_automatic_session" = true ]; then
477 get_auto_session_name session_name
478 fi
479
480 enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-pid"
481 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
482 start_lttng_tracing_ok "$session_name"
483
484 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
485 --sync-after-first-event "$file_sync_after_first" \
486 --sync-before-last-event "$file_sync_before_last" 2>&1 &
487
488 while [ ! -f "${file_sync_after_first}" ]; do
489 sleep 0.5
490 done
491
492 lttng_snapshot_record "$session_name"
493
494 touch "$file_sync_before_last"
495 wait
496
497 stop_lttng_tracing_ok "$session_name"
498 destroy_lttng_session_ok "$session_name"
499
500 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
501 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/snapshot-1*"
502 else
503 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*/snapshot-1*"
504 fi
505
506 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
507 rm -rf "${TRACE_PATH:?}/$session_name"
508 else
509 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
510 fi
511
512 rm -f "$file_sync_after_first"
513 rm -f "$file_sync_before_last"
514 }
515
516 function test_ust_uid_streaming_snapshot_add_output_default_name ()
517 {
518 local session_name="$1"
519 local grouping="$2"
520 local is_automatic_session=false
521
522 if [ -z "$session_name" ]; then
523 is_automatic_session=true
524 fi
525
526 diag "Test UST uid buffer snapshot using 'add-output' with default snapshot name [$grouping][${session_name:-automatic session name}]"
527
528 create_lttng_session_no_output "$session_name"
529 if [ "$is_automatic_session" = true ]; then
530 get_auto_session_name session_name
531 fi
532
533 enable_lttng_mmap_overwrite_ust_channel "$session_name" "$CHANNEL_NAME"
534 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
535 start_lttng_tracing_ok "$session_name"
536
537 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
538
539 lttng_snapshot_add_output_ok "$session_name" "net://localhost"
540 lttng_snapshot_record "$session_name"
541
542 stop_lttng_tracing_ok "$session_name"
543 destroy_lttng_session_ok "$session_name"
544
545 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
546 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/snapshot-1*"
547 else
548 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*/snapshot-1*"
549 fi
550
551 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
552 rm -rf "${TRACE_PATH:?}/$session_name"
553 else
554 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
555 fi
556 }
557
558 function test_ust_uid_streaming_snapshot_add_output_custom_name ()
559 {
560 local session_name="$1"
561 local grouping="$2"
562 local snapshot_name="this_is_my_snapshot"
563 local is_automatic_session=false
564
565 if [ -z "$session_name" ]; then
566 is_automatic_session=true
567 fi
568
569 diag "Test UST uid buffer snapshot using 'add-output' with custom snapshot name [$grouping][${session_name:-automatic session name}]"
570
571 create_lttng_session_no_output "$session_name"
572 if [ "$is_automatic_session" = true ]; then
573 get_auto_session_name session_name
574 fi
575
576 enable_lttng_mmap_overwrite_ust_channel "$session_name" "$CHANNEL_NAME"
577 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
578 start_lttng_tracing_ok "$session_name"
579
580 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
581
582 lttng_snapshot_add_output_ok "$session_name" "net://localhost" "-n $snapshot_name"
583 lttng_snapshot_record "$session_name"
584
585 stop_lttng_tracing_ok "$session_name"
586 destroy_lttng_session_ok "$session_name"
587
588 # When session name is automatic, the actual directory is "auto", not
589 # auto-<datetime>.
590 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
591 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$snapshot_name*"
592 else
593 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*/$snapshot_name*"
594 fi
595
596 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
597 rm -rf "${TRACE_PATH:?}/$session_name"
598 else
599 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
600 fi
601 }
602
603 function test_ust_uid_streaming_snapshot_add_output_custom_name_custom_output ()
604 {
605 local session_name="$1"
606 local grouping="$2"
607 local snapshot_name="this_is_my_snapshot"
608 local custom_output="this/is/my/custom/path"
609 local is_automatic_session=false
610
611 if [ -z "$session_name" ]; then
612 is_automatic_session=true
613 fi
614
615 diag "Test UST uid buffer snapshot using 'add-output' with custom snapshot name and custom output path [$grouping][${session_name:-automatic session name}]"
616
617 create_lttng_session_no_output "$session_name"
618 if [ "$is_automatic_session" = true ]; then
619 get_auto_session_name session_name
620 fi
621
622 enable_lttng_mmap_overwrite_ust_channel "$session_name" "$CHANNEL_NAME"
623 enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME"
624 start_lttng_tracing_ok "$session_name"
625
626 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
627
628 lttng_snapshot_add_output_ok "$session_name" "net://localhost/$custom_output" "-n $snapshot_name"
629 lttng_snapshot_record "$session_name"
630
631 stop_lttng_tracing_ok "$session_name"
632 destroy_lttng_session_ok "$session_name"
633
634 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
635 validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$custom_output/$snapshot_name*"
636 else
637 validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$custom_output/$snapshot_name*"
638 fi
639
640 if [ "$grouping" = "$GROUP_BY_SESSION" ]; then
641 rm -rf "${TRACE_PATH:?}/$session_name"
642 else
643 rm -rf "${TRACE_PATH:?}/$HOSTNAME"
644 fi
645 }
646
647 plan_tests $NUM_TESTS
648
649 print_test_banner "$TEST_DESC"
650
651
652 tests=(
653 test_ust_uid_live
654 test_ust_pid_live
655 test_ust_uid_live_custom_output
656 test_ust_uid_streaming
657 test_ust_pid_streaming
658 test_ust_uid_streaming_custom_output
659 test_ust_uid_streaming_rotate
660 test_ust_uid_streaming_rotate_custom_output
661 test_ust_pid_streaming_rotate
662 test_ust_uid_streaming_snapshot
663 test_ust_pid_streaming_snapshot
664 test_ust_uid_streaming_snapshot_add_output_default_name
665 test_ust_uid_streaming_snapshot_add_output_custom_name
666 test_ust_uid_streaming_snapshot_add_output_custom_name_custom_output
667 )
668
669 GROUP_BY_SESSION="--group-output-by-session"
670 GROUP_BY_HOSTNAME="--group-output-by-host"
671
672 grouping_types=(
673 $GROUP_BY_SESSION
674 $GROUP_BY_HOSTNAME
675 )
676 for fct_test in "${tests[@]}";
677 do
678 for grouping in "${grouping_types[@]}";
679 do
680 TRACE_PATH=$(mktemp --tmpdir -d tmp.test_relayd_grouping_ust_trace_path.XXXXXX)
681 # Set the relayd in --group-output-by-session mode
682 start_lttng_relayd "-o $TRACE_PATH $grouping"
683 start_lttng_sessiond
684
685 name=""
686 # Perform test when session name is generated by the client
687 ${fct_test} "$name" "$grouping"
688 count=$(find "$TRACE_PATH/" -maxdepth 1 -mindepth 1 | wc -l)
689 is "$count" "0" "LTTng-relayd output directory empty"
690
691 # Perform test when session name is given
692 name="my-session"
693 ${fct_test} "$name" "$grouping"
694 count=$(find "$TRACE_PATH/" -maxdepth 1 -mindepth 1 | wc -l)
695 is "$count" "0" "LTTng-relayd output directory empty"
696
697 rm -rf "$TRACE_PATH"
698 stop_lttng_relayd
699 stop_lttng_sessiond
700 done
701 done
702
This page took 0.04827 seconds and 5 git commands to generate.