Tests for metadata regenerate
[lttng-tools.git] / tests / regression / tools / metadata-regen / test_ust
CommitLineData
801236b0
JD
1#!/bin/bash
2#
3# Copyright (C) - 2015 Julien Desfossez <jdesfossez@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
17TEST_DESC="Streaming - User space tracing"
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../../..
21NR_ITER=1
22NR_USEC_WAIT=0
23TESTAPP_PATH="$TESTDIR/utils/testapp"
24TESTAPP_NAME="gen-ust-events"
25TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
26SESSION_NAME="stream"
27EVENT_NAME="tp:tptest"
28PID_RELAYD=0
29
30TRACE_PATH=$(mktemp -d)
31
32NUM_TESTS=33
33
34source $TESTDIR/utils/utils.sh
35
36if [ ! -x "$TESTAPP_BIN" ]; then
37 BAIL_OUT "No UST events binary detected."
38fi
39
40function lttng_create_session_uri
41{
42 # Create session with default path
43 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
44 ok $? "Create session with default path"
45}
46
47function lttng_create_session_uri_live
48{
49 # Create session with default path
50 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --live -U net://localhost >/dev/null 2>&1
51 ok $? "Create live session"
52}
53
54function enable_channel_per_pid()
55{
56 sess_name=$1
57 channel_name=$2
58
59 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-pid -u $channel_name -s $sess_name >/dev/null 2>&1
60 ok $? "Enable channel $channel_name per PID for session $sess_name"
61}
62
63# MUST set TESTDIR before calling those functions
64
65function test_ust_streaming ()
66{
67 local file_sync_after_first=$(mktemp -u)
68 local file_sync_before_last=$(mktemp -u)
69
70 diag "Test UST streaming with metadata regeneration"
71 lttng_create_session_uri
72 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
73
74 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
75
76 start_lttng_tracing_ok $SESSION_NAME
77
78 touch ${file_sync_before_last}
79
80 # Wait for the applications started in background
81 wait
82 metadata_regenerate_ok $SESSION_NAME
83
84 stop_lttng_tracing_ok $SESSION_NAME
85 destroy_lttng_session_ok $SESSION_NAME
86 # Validate test
87 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
88 if [ $? -eq 0 ]; then
89 # Only delete if successful
90 rm -rf $TRACE_PATH
91 fi
92 rm -f ${file_sync_after_first}
93 rm -f ${file_sync_before_last}
94}
95
96function test_ust_local ()
97{
98 local file_sync_after_first=$(mktemp -u)
99 local file_sync_before_last=$(mktemp -u)
100
101 diag "Test UST local with metadata regeneration"
102 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
103 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
104
105 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
106
107 start_lttng_tracing_ok $SESSION_NAME
108
109 touch ${file_sync_before_last}
110
111 # Wait for the applications started in background
112 wait
113 metadata_regenerate_ok $SESSION_NAME
114
115 stop_lttng_tracing_ok $SESSION_NAME
116 destroy_lttng_session_ok $SESSION_NAME
117 # Validate test
118 validate_trace $EVENT_NAME $TRACE_PATH
119 if [ $? -eq 0 ]; then
120 # Only delete if successful
121 rm -rf $TRACE_PATH
122 fi
123 rm -f ${file_sync_after_first}
124 rm -f ${file_sync_before_last}
125}
126
127function test_ust_pid ()
128{
129 local file_sync_after_first=$(mktemp -u)
130 local file_sync_before_last=$(mktemp -u)
131
132 diag "Test UST per-pid with metadata regeneration (expect failure)"
133 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
134 enable_channel_per_pid $SESSION_NAME "channel0"
135 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
136
137 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
138
139 start_lttng_tracing_ok $SESSION_NAME
140
141 touch ${file_sync_before_last}
142
143 # Wait for the applications started in background
144 wait
145 metadata_regenerate_fail $SESSION_NAME
146
147 stop_lttng_tracing_ok $SESSION_NAME
148 destroy_lttng_session_ok $SESSION_NAME
149 # Validate test
150 validate_trace $EVENT_NAME $TRACE_PATH
151 if [ $? -eq 0 ]; then
152 # Only delete if successful
153 rm -rf $TRACE_PATH
154 fi
155 rm -f ${file_sync_after_first}
156 rm -f ${file_sync_before_last}
157}
158
159function test_ust_live ()
160{
161 local file_sync_after_first=$(mktemp -u)
162 local file_sync_before_last=$(mktemp -u)
163
164 diag "Test UST live with metadata regeneration (expect failure)"
165 lttng_create_session_uri_live $SESSION_NAME $TRACE_PATH
166 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
167
168 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
169
170 start_lttng_tracing_ok $SESSION_NAME
171
172 touch ${file_sync_before_last}
173
174 # Wait for the applications started in background
175 wait
176 metadata_regenerate_fail $SESSION_NAME
177
178 stop_lttng_tracing_ok $SESSION_NAME
179 destroy_lttng_session_ok $SESSION_NAME
180 # Validate test
181 validate_trace $EVENT_NAME $TRACE_PATH
182 if [ $? -eq 0 ]; then
183 # Only delete if successful
184 rm -rf $TRACE_PATH
185 fi
186 rm -f ${file_sync_after_first}
187 rm -f ${file_sync_before_last}
188}
189
190plan_tests $NUM_TESTS
191
192print_test_banner "$TEST_DESC"
193
194start_lttng_relayd "-o $TRACE_PATH"
195start_lttng_sessiond
196
197tests=( test_ust_streaming test_ust_local test_ust_pid test_ust_live )
198
199for fct_test in ${tests[@]};
200do
201 SESSION_NAME=$(randstring 16 0)
202 ${fct_test}
203done
204
205stop_lttng_sessiond
206stop_lttng_relayd
207
208exit $out
This page took 0.030356 seconds and 4 git commands to generate.