rotation-api: introduce rotation schedule descriptors
[lttng-tools.git] / tests / regression / tools / rotation / test_save_load_mi
CommitLineData
e7716c6a
JD
1#!/bin/bash
2#
3# Copyright (C) - 2017 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
17
18TEST_DESC="Rotation - Save/Load/List/MI"
19
20CURDIR=$(dirname $0)/
21TESTDIR=$CURDIR/../../..
22SESSION_NAME="stream"
23
308a8946 24NUM_TESTS=22
e7716c6a
JD
25
26source $TESTDIR/utils/utils.sh
27source $CURDIR/rotate_utils.sh
28
2f686e35 29# Overwrite the lttng_bin to get mi output
e7716c6a
JD
30LTTNG_BIN="lttng --mi xml"
31
e7716c6a
JD
32XSD_PATH=$TESTDIR/../src/common/mi-lttng-3.0.xsd
33
34XML_VALIDATE="$TESTDIR/regression/tools/mi/validate_xml $XSD_PATH"
35XML_EXTRACT="$TESTDIR/regression/tools/mi/extract_xml"
36
37XPATH_CMD_OUTPUT="//lttng:command/lttng:output"
38XPATH_SESSION="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session"
66ea93b1
JG
39XPATH_ENABLE_ROTATE_TIMER="$XPATH_CMD_OUTPUT/lttng:rotation_schedule_results/lttng:rotation_schedule_result/lttng:rotation_schedule/lttng:periodic/lttng:time_us"
40XPATH_ENABLE_ROTATE_SIZE="$XPATH_CMD_OUTPUT/lttng:rotation_schedule_results/lttng:rotation_schedule_result/lttng:rotation_schedule/lttng:size_threshold/lttng:bytes"
41
42XPATH_LIST_ROTATE_TIMER="$XPATH_SESSION/lttng:rotation_schedules/lttng:periodic/lttng:time_us"
43XPATH_LIST_ROTATE_SIZE="$XPATH_SESSION/lttng:rotation_schedules/lttng:size_threshold/lttng:bytes"
e7716c6a 44
308a8946 45function test_save_load_mi ()
e7716c6a
JD
46{
47 tmp_xml_output=$(mktemp -u)
48 tmp_save_output=$(mktemp -d)
2f686e35 49 trace_path=$(mktemp -d)
e7716c6a
JD
50
51 diag "Test save/load/list/MI with rotation"
2f686e35 52 create_lttng_session_ok $SESSION_NAME $trace_path
e7716c6a
JD
53 enable_ust_lttng_event_ok $SESSION_NAME -a
54
55 # Enable a rotation timer and check the MI output of the command
308a8946
JR
56
57 OUTPUT_DEST=${tmp_xml_output}
58 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
e7716c6a
JD
59 $XML_VALIDATE ${tmp_xml_output}
60 ok $? "Valid lttng enable-rotation timer XML"
308a8946 61
66ea93b1 62 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_ENABLE_ROTATE_TIMER})
e7716c6a
JD
63 test $value = 500000
64 ok $? "Found the right rotation timer value in XML"
65
66 # Enable a rotation size and check the MI output of the command
308a8946 67 lttng_enable_rotation_size_ok $SESSION_NAME 500k
e7716c6a
JD
68 $XML_VALIDATE ${tmp_xml_output}
69 ok $? "Valid lttng enable-rotation size XML"
308a8946 70
66ea93b1 71 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_ENABLE_ROTATE_SIZE})
e7716c6a
JD
72 test $value = 512000
73 ok $? "Found the right rotation size value in XML"
74
75 # Check the output of lttng list with the 2 rotation parameters
308a8946 76 list_lttng_with_opts $SESSION_NAME
e7716c6a
JD
77 $XML_VALIDATE ${tmp_xml_output}
78 ok $? "Valid lttng list XML"
308a8946 79
66ea93b1 80 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_LIST_ROTATE_TIMER})
e7716c6a
JD
81 test $value = 500000
82 ok $? "Found the right rotation timer value in list XML"
308a8946 83
66ea93b1 84 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_LIST_ROTATE_SIZE})
e7716c6a
JD
85 test $value = 512000
86 ok $? "Found the right rotation size value in list XML"
87
88 # save, destroy and reload the same session
308a8946
JR
89 OUTPUT_DEST=/dev/null
90 lttng_save $SESSION_NAME "-o $tmp_save_output$SESSION_NAME"
91 destroy_lttng_session_ok $SESSION_NAME
92 lttng_load_ok "-i $tmp_save_output$SESSION_NAME"
e7716c6a 93
308a8946 94 OUTPUT_DEST=${tmp_xml_output}
e7716c6a 95 # Check the output of lttng list with the 2 rotation parameters after the load
308a8946 96 list_lttng_with_opts $SESSION_NAME
e7716c6a
JD
97 $XML_VALIDATE ${tmp_xml_output}
98 ok $? "Valid lttng list XML after load"
308a8946 99
66ea93b1 100 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_LIST_ROTATE_TIMER})
e7716c6a
JD
101 test $value = 500000
102 ok $? "Found the right rotation timer value in list XML after load"
308a8946 103
66ea93b1 104 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_LIST_ROTATE_SIZE})
e7716c6a
JD
105 test $value = 512000
106 ok $? "Found the right rotation size value in list XML after load"
107
308a8946
JR
108 OUTPUT_DEST=/dev/null
109 destroy_lttng_session_ok $SESSION_NAME
e7716c6a 110
2f686e35 111 rm -rf ${trace_path}
e7716c6a
JD
112 rm $tmp_xml_output
113 rm -rf $tmp_save_output
114}
115
116plan_tests $NUM_TESTS
117
118print_test_banner "$TEST_DESC"
119
120start_lttng_sessiond
121
308a8946 122tests=( test_save_load_mi )
e7716c6a
JD
123
124for fct_test in ${tests[@]};
125do
126 SESSION_NAME=$(randstring 16 0)
127 ${fct_test}
128done
129
130stop_lttng_sessiond
This page took 0.029051 seconds and 4 git commands to generate.