3 # Copyright (C) - 2017 Julien Desfossez <jdesfossez@efficios.com>
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.
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
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
18 # Clean everything under directory but keep directory
19 function clean_path
()
22 # Use -u from bash top prevent empty expansion of variable yielding a
23 # list of current directory from find.
25 find $path -mindepth 1 -maxdepth 1 -exec rm -rf '{}' \
;
29 function set_chunk_pattern
()
31 # Need to call this function after $today has been set.
33 # YYYYMMDDTHHMMSS[+-]HHMM-YYYYMMDDTHHMMSS[+-]HHMM
34 export chunk_pattern
="${today}T[0-9][0-9][0-9][0-9][0-9][0-9][+-][0-9][0-9][0-9][0-9]-${today}T[0-9][0-9][0-9][0-9][0-9][0-9][+-][0-9][0-9][0-9][0-9]"
37 function validate_test_chunks
()
48 # Validate that only 3 chunks are present
49 nb_chunk
=$
(ls -A $local_path |
wc -l)
51 ok $?
"${local_path} contains 3 chunks only"
53 # Check if the first and second chunk folders exist and they contain a ${app_path}/metadata file.
54 for chunk
in $
(seq 1 2); do
55 path
=$
(ls $local_path/${chunk_pattern}-${chunk}/${app_path}/metadata
)
56 ok $?
"Chunk ${chunk} exists based on path $path"
59 # In per-pid the last chunk (3) must be empty.
60 if [ "${per_pid}" -eq "1" ]; then
61 test -z "$(ls -A $local_path/${chunk_pattern}-3/${domain})"
62 ok $?
"Chunk 3 is empty per-pid mode"
64 path
=$
(ls $local_path/${chunk_pattern}-3/${app_path}/metadata
)
65 ok $?
"Chunk 3 exists based on path $path"
68 # Make sure we don't have anything else in the first 2 chunk directories
69 # besides the kernel folder.
70 nr_stale
=$
(\
ls $local_path/${chunk_pattern}-1 |
grep -v $domain |
wc -l)
71 ok
$nr_stale "No stale folders in chunk 1 directory"
72 nr_stale
=$
(\
ls $local_path/${chunk_pattern}-2 |
grep -v $domain |
wc -l)
73 ok
$nr_stale "No stale folders in chunk 2 directory"
75 # We expect a complete session of 30 events
76 validate_trace_count
$EVENT_NAME $local_path 30
79 validate_trace_count
$EVENT_NAME $local_path/${chunk_pattern}-1 10
82 validate_trace_count
$EVENT_NAME $local_path/${chunk_pattern}-2 20
85 # Trace for chunk number 3 can only be read in per-uid mode since in
86 # per-pid mode it is empty (no metadata or stream files).
87 if test $per_pid = 0; then
88 validate_trace_empty
$local_path/${chunk_pattern}-3
92 function rotate_timer_test
()
102 # Wait for $expected_chunks to be generated, timeout after
103 # 3 * $expected_chunks * 0.5s.
104 # On a laptop with an empty session, a local rotation takes about 200ms,
105 # and a remote rotation takes about 600ms.
106 # We currently set the timeout to 6 seconds for 3 rotations, if we get
107 # errors, we can bump this value.
109 until [ $nr -ge $expected_chunks ] ||
[ $nr_iter -ge $
(($expected_chunks * 2 )) ]; do
110 nr
=$
(ls $local_path |
wc -l)
111 nr_iter
=$
(($nr_iter+1))
114 test $nr -ge $expected_chunks
115 ok $?
"Generated $nr chunks in $(($nr_iter))s"
116 stop_lttng_tracing_ok
$SESSION_NAME
117 destroy_lttng_session_ok
$SESSION_NAME
121 ok $?
"Date did not change during the test"
123 # Make sure the 10 first chunks are valid empty traces
127 # In a per-pid setup, only the first chunk is a valid trace, the other
128 # chunks should be empty folders
129 if test $per_pid = 1; then
130 validate_trace_empty
$local_path/${chunk_pattern}-1
131 nr
=$
(ls $local_path/${chunk_pattern}-2/ust |
wc -l)
133 ok $?
"Chunk 2 is empty"
134 nr
=$
(ls $local_path/${chunk_pattern}-3/ust |
wc -l)
136 ok $?
"Chunk 3 is empty"
138 while [ $i -le $expected_chunks ]; do
139 validate_trace_empty
$local_path/${chunk_pattern}-$i
This page took 0.038101 seconds and 6 git commands to generate.