13b158abcf96ef64d6feb2a0ebd3f34c2c347605
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
()
47 # Check if the 3 chunk folders exist and they contain a ${app_path}/metadata file.
48 ls $local_path/${chunk_pattern}-1/${app_path}/metadata
>/dev
/null
49 ok $?
"Chunk 1 exists"
50 ls $local_path/${chunk_pattern}-2/${app_path}/metadata
>/dev
/null
51 ok $?
"Chunk 2 exists"
52 ls $local_path/${chunk_pattern}-3/${domain} >/dev
/null
53 ok $?
"Chunk 3 exists"
55 # Make sure we don't have anything else in the first 2 chunk directories
56 # besides the kernel folder.
57 nr_stale
=$
(\
ls $local_path/${chunk_pattern}-1 |
grep -v $domain |
wc -l)
58 ok
$nr_stale "No stale folders in chunk 1 directory"
59 nr_stale
=$
(\
ls $local_path/${chunk_pattern}-2 |
grep -v $domain |
wc -l)
60 ok
$nr_stale "No stale folders in chunk 2 directory"
62 # We expect a session of 30 events
63 validate_trace_count
$EVENT_NAME $local_path 30
66 validate_trace_count
$EVENT_NAME $local_path/${chunk_pattern}-1 10
68 # Only delete if successful
69 rm -rf $local_path/${chunk_pattern}-1
73 validate_trace_count
$EVENT_NAME $local_path/${chunk_pattern}-2 20
75 # Only delete if successful
76 rm -rf $local_path/${chunk_pattern}-2
80 # Do not check in per-pid, because the folder is really empty, no metadata
82 if test $per_pid = 1; then
83 rm -rf $local_path/${chunk_pattern}-3
85 validate_trace_empty
$local_path/${chunk_pattern}-3
87 # Only delete if successful
88 rm -rf $local_path/${chunk_pattern}-3
92 # The session folder after all chunks have been removed is empty
93 test -z "$(\ls -A $local_path)"
95 ok
$empty "Trace folder is now empty"
98 function rotate_timer_test
()
103 today
=$
(date +%Y
%m
%d
)
108 # Wait for $expected_chunks to be generated, timeout after
109 # 3 * $expected_chunks * 0.5s.
110 # On a laptop with an empty session, a local rotation takes about 200ms,
111 # and a remote rotation takes about 600ms.
112 # We currently set the timeout to 6 seconds for 3 rotations, if we get
113 # errors, we can bump this value.
115 until [ $nr -ge $expected_chunks ] ||
[ $nr_iter -ge $
(($expected_chunks * 2 )) ]; do
116 nr
=$
(ls $local_path |
wc -l)
117 nr_iter
=$
(($nr_iter+1))
120 test $nr -ge $expected_chunks
121 ok $?
"Generated $nr chunks in $(($nr_iter))s"
122 stop_lttng_tracing_ok
$SESSION_NAME
123 destroy_lttng_session_ok
$SESSION_NAME
127 ok $?
"Date did not change during the test"
129 # Make sure the 10 first chunks are valid empty traces
133 # In a per-pid setup, only the first chunk is a valid trace, the other
134 # chunks should be empty folders
135 if test $per_pid = 1; then
136 validate_trace_empty
$local_path/${chunk_pattern}-1
137 nr
=$
(ls $local_path/${chunk_pattern}-2/ust |
wc -l)
139 ok $?
"Chunk 2 is empty"
140 nr
=$
(ls $local_path/${chunk_pattern}-3/ust |
wc -l)
142 ok $?
"Chunk 3 is empty"
144 while [ $i -le $expected_chunks ]; do
145 validate_trace_empty
$local_path/${chunk_pattern}-$i
This page took 0.033936 seconds and 4 git commands to generate.