da1e6c6c3ac1dfa20be923316c6f1f4e7820dcff
[lttng-tools.git] / tests / regression / tools / save-load / test_load
1 #!/bin/bash
2 #
3 # Copyright (C) - 2014 David Goulet <dgoulet@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="Load session(s)"
19
20 CURDIR=$(dirname $0)/
21 TESTDIR=$CURDIR/../../../
22 SESSIOND_BIN="lttng-sessiond"
23 RELAYD_BIN="lttng-relayd"
24 LTTNG_BIN="lttng"
25 export LTTNG_SESSION_CONFIG_XSD_PATH=$(readlink -m ${TESTDIR}../src/common/config/)
26
27 SESSION_NAME="load-42"
28 EVENT_NAME="tp:tptest"
29
30 DIR=$(readlink -f $TESTDIR)
31
32 NUM_TESTS=28
33
34 source $TESTDIR/utils/utils.sh
35
36 # MUST set TESTDIR before calling those functions
37 plan_tests $NUM_TESTS
38
39 print_test_banner "$TEST_DESC"
40
41 function test_basic_load()
42 {
43 diag "Test basic load"
44
45 lttng_load "-i $CURDIR/$SESSION_NAME.lttng"
46
47 destroy_lttng_session_ok $SESSION_NAME
48 }
49
50 function test_complex_load()
51 {
52 local sess="$SESSION_NAME-complex"
53 diag "Test complex load"
54
55 # Start relayd with localhost binding. The complex session uses those
56 # custom values.
57 start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
58
59 lttng_load "-i $CURDIR/$sess.lttng"
60
61 # Once loaded, we are suppose to be able to disable certain events/channels
62 # thus having a confirmation that it's valid
63 disable_ust_lttng_event $sess uevent1 chan1
64 disable_ust_lttng_event $sess uevent2 chan2
65 disable_ust_lttng_event $sess uevent3* chan3
66
67 disable_ust_lttng_channel $sess chan1
68 disable_ust_lttng_channel $sess chan2
69 disable_ust_lttng_channel $sess chan3
70
71 # Confirm that an event stored as disabled is restored in its disabled state
72 local mi_output_file=$(mktemp)
73 if [ $? -ne 0 ]; then
74 break;
75 fi
76 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list $sess -c chan2 > $mi_output_file
77 mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//command/output/sessions/session/domains/domain/channels/channel[name='chan2']/events/event[name='uevent_disabled']/enabled/text()")
78 if [[ $mi_result = "false" ]]; then
79 ok 0 "Disabled event is loaded in disabled state"
80 else
81 fail "Disabled event is loaded in disabled state"
82 fi
83 destroy_lttng_session_ok $sess
84
85 stop_lttng_relayd
86 }
87
88 function test_all_load()
89 {
90 diag "Test load all sessions"
91
92 # Start relayd with localhost binding. The complex session uses those
93 # custom values.
94 start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
95
96 lttng_load "-a -i $CURDIR"
97
98 destroy_lttng_session_ok $SESSION_NAME
99 destroy_lttng_session_ok "$SESSION_NAME-complex"
100 destroy_lttng_session_ok "$SESSION_NAME-trackers"
101
102 stop_lttng_relayd
103 }
104
105 function test_overwrite()
106 {
107 diag "Test load overwrite"
108
109 lttng_load "-i $CURDIR/$SESSION_NAME.lttng"
110
111 # This one should succeed
112 lttng_load "-f -i $CURDIR $SESSION_NAME"
113
114 destroy_lttng_session_ok $SESSION_NAME
115 }
116
117 function test_trackers()
118 {
119 diag "Test trackers loading"
120
121 lttng_load "-i $CURDIR/$SESSION_NAME-trackers.lttng"
122
123 diag "Test pid tracker"
124 local mi_output_file=$(mktemp)
125 if [ $? -ne 0 ]; then
126 break;
127 fi
128 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME-trackers" > $mi_output_file
129 mi_result=$($CURDIR/../mi/extract_xml -e $mi_output_file "//command/output/sessions/session/domains/domain/trackers/pid_tracker/targets/pid_target")
130 if [[ $mi_result = "true" ]]; then
131 ok 0 "Pid target is present"
132 else
133 fail "Pid target missing"
134 fi
135
136 # Test to remove the target just to make sure
137 lttng_untrack_ok "-p 666 -u -s $SESSION_NAME-trackers"
138
139 destroy_lttng_session_ok "$SESSION_NAME-trackers"
140 }
141
142 start_lttng_sessiond
143
144 TESTS=(
145 test_basic_load
146 test_complex_load
147 test_all_load
148 test_overwrite
149 test_trackers
150 )
151
152 for fct_test in ${TESTS[@]};
153 do
154 TRACE_PATH=$(mktemp -d)
155
156 ${fct_test}
157 if [ $? -ne 0 ]; then
158 break;
159 fi
160 # Only delete if successful
161 rm -rf $TRACE_PATH
162 done
163
164 stop_lttng_sessiond
This page took 0.037512 seconds and 4 git commands to generate.