Commit | Line | Data |
---|---|---|
e02b109b DG |
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" | |
742e5f18 | 25 | export LTTNG_SESSION_CONFIG_XSD_PATH=$(readlink -m ${TESTDIR}../src/common/config/) |
e02b109b DG |
26 | |
27 | SESSION_NAME="load-42" | |
28 | EVENT_NAME="tp:tptest" | |
29 | ||
30 | DIR=$(readlink -f $TESTDIR) | |
31 | ||
ea05d84b | 32 | NUM_TESTS=21 |
e02b109b DG |
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 disable_event() | |
42 | { | |
43 | local sess_name="$1" | |
44 | local chan_name="$2" | |
45 | local event_name="$3" | |
46 | ||
47 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1 | |
48 | ok $? "Disable event $event_name for session $sess_name" | |
49 | } | |
50 | ||
51 | function test_basic_load() | |
52 | { | |
53 | diag "Test basic load" | |
54 | ||
83b7c3bf | 55 | lttng_load "-i $CURDIR/$SESSION_NAME.lttng" |
e02b109b | 56 | |
67b4c664 | 57 | destroy_lttng_session_ok $SESSION_NAME |
e02b109b DG |
58 | } |
59 | ||
60 | function test_complex_load() | |
61 | { | |
62 | local sess="$SESSION_NAME-complex" | |
63 | diag "Test complex load" | |
64 | ||
65 | # Start relayd with localhost binding. The complex session uses those | |
66 | # custom values. | |
67 | start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817" | |
68 | ||
83b7c3bf | 69 | lttng_load "-i $CURDIR/$sess.lttng" |
e02b109b DG |
70 | |
71 | # Once loaded, we are suppose to be able to disable certain events/channels | |
72 | # thus having a confirmation that it's valid | |
73 | disable_event $sess chan1 uevent1 | |
74 | disable_event $sess chan2 uevent2 | |
75 | disable_event $sess chan3 uevent3* | |
76 | ||
77 | disable_ust_lttng_channel $sess chan1 | |
78 | disable_ust_lttng_channel $sess chan2 | |
79 | disable_ust_lttng_channel $sess chan3 | |
80 | ||
ea05d84b JG |
81 | # Confirm that an event stored as disabled is restored in its disabled state |
82 | local mi_output_file=$(mktemp) | |
83 | if [ $? -ne 0 ]; then | |
84 | break; | |
85 | fi | |
373ff56c | 86 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list $sess -c chan2 > $mi_output_file |
ea05d84b JG |
87 | 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()") |
88 | if [[ $mi_result = "false" ]]; then | |
89 | ok 0 "Disabled event is loaded in disabled state" | |
90 | else | |
91 | fail "Disabled event is loaded in disabled state" | |
92 | fi | |
67b4c664 | 93 | destroy_lttng_session_ok $sess |
e02b109b DG |
94 | |
95 | stop_lttng_relayd_nocheck | |
96 | } | |
97 | ||
98 | function test_all_load() | |
99 | { | |
100 | diag "Test load all sessions" | |
101 | ||
102 | # Start relayd with localhost binding. The complex session uses those | |
103 | # custom values. | |
104 | start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817" | |
105 | ||
106 | lttng_load "-a -i $CURDIR" | |
107 | ||
67b4c664 JR |
108 | destroy_lttng_session_ok $SESSION_NAME |
109 | destroy_lttng_session_ok "$SESSION_NAME-complex" | |
e02b109b DG |
110 | |
111 | stop_lttng_relayd_nocheck | |
112 | } | |
113 | ||
114 | function test_overwrite() | |
115 | { | |
116 | diag "Test load overwrite" | |
117 | ||
83b7c3bf | 118 | lttng_load "-i $CURDIR/$SESSION_NAME.lttng" |
e02b109b DG |
119 | |
120 | # This one should succeed | |
11143783 | 121 | lttng_load "-f -i $CURDIR $SESSION_NAME" |
e02b109b | 122 | |
67b4c664 | 123 | destroy_lttng_session_ok $SESSION_NAME |
e02b109b DG |
124 | } |
125 | ||
126 | start_lttng_sessiond | |
127 | ||
128 | TESTS=( | |
129 | test_basic_load | |
130 | test_complex_load | |
131 | test_all_load | |
132 | test_overwrite | |
133 | ) | |
134 | ||
135 | for fct_test in ${TESTS[@]}; | |
136 | do | |
137 | TRACE_PATH=$(mktemp -d) | |
138 | ||
139 | ${fct_test} | |
140 | if [ $? -ne 0 ]; then | |
141 | break; | |
142 | fi | |
143 | # Only delete if successful | |
144 | rm -rf $TRACE_PATH | |
145 | done | |
146 | ||
147 | stop_lttng_sessiond |