From 5784f8357b75adb3e966c95964a8f467fac9e136 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Tue, 7 Jun 2016 21:46:42 -0400 Subject: [PATCH] Test: template on create session Signed-off-by: Jonathan Rajotte --- configure.ac | 2 + tests/regression/Makefile.am | 3 +- tests/regression/tools/Makefile.am | 2 +- tests/regression/tools/templates/Makefile.am | 17 + .../tools/templates/sessions/Makefile.am | 18 + .../tools/templates/sessions/full_load.lttng | 54 ++ .../tools/templates/sessions/live.lttng | 21 + .../sessions/live_output_generation.lttng | 10 + .../templates/sessions/name_generation.lttng | 14 + .../templates/sessions/normal_local.lttng | 15 + .../tools/templates/sessions/normal_net.lttng | 18 + .../templates/sessions/normal_no_output.lttng | 15 + .../sessions/normal_output_generation.lttng | 7 + .../tools/templates/sessions/shm_path.lttng | 16 + .../templates/sessions/snapshot_local.lttng | 24 + .../templates/sessions/snapshot_net.lttng | 27 + .../sessions/snapshot_output_generation.lttng | 10 + tests/regression/tools/templates/test_create | 718 ++++++++++++++++++ tests/utils/utils.sh | 23 + 19 files changed, 1012 insertions(+), 2 deletions(-) create mode 100644 tests/regression/tools/templates/Makefile.am create mode 100644 tests/regression/tools/templates/sessions/Makefile.am create mode 100644 tests/regression/tools/templates/sessions/full_load.lttng create mode 100644 tests/regression/tools/templates/sessions/live.lttng create mode 100644 tests/regression/tools/templates/sessions/live_output_generation.lttng create mode 100644 tests/regression/tools/templates/sessions/name_generation.lttng create mode 100644 tests/regression/tools/templates/sessions/normal_local.lttng create mode 100644 tests/regression/tools/templates/sessions/normal_net.lttng create mode 100644 tests/regression/tools/templates/sessions/normal_no_output.lttng create mode 100644 tests/regression/tools/templates/sessions/normal_output_generation.lttng create mode 100644 tests/regression/tools/templates/sessions/shm_path.lttng create mode 100644 tests/regression/tools/templates/sessions/snapshot_local.lttng create mode 100644 tests/regression/tools/templates/sessions/snapshot_net.lttng create mode 100644 tests/regression/tools/templates/sessions/snapshot_output_generation.lttng create mode 100755 tests/regression/tools/templates/test_create diff --git a/configure.ac b/configure.ac index fb2b0136f..633ceef8a 100644 --- a/configure.ac +++ b/configure.ac @@ -981,6 +981,8 @@ AC_CONFIG_FILES([ tests/regression/tools/wildcard/Makefile tests/regression/tools/crash/Makefile tests/regression/tools/metadata-regen/Makefile + tests/regression/tools/templates/Makefile + tests/regression/tools/templates/sessions/Makefile tests/regression/ust/Makefile tests/regression/ust/nprocesses/Makefile tests/regression/ust/high-throughput/Makefile diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am index 6a2d24c7b..d1c19e6b4 100644 --- a/tests/regression/Makefile.am +++ b/tests/regression/Makefile.am @@ -22,7 +22,8 @@ TESTS = tools/filtering/test_invalid_filter \ tools/mi/test_mi \ tools/wildcard/test_event_wildcard \ tools/crash/test_crash \ - tools/metadata-regen/test_ust + tools/metadata-regen/test_ust \ + tools/templates/test_create if HAVE_LIBLTTNG_UST_CTL SUBDIRS += ust diff --git a/tests/regression/tools/Makefile.am b/tests/regression/tools/Makefile.am index 6c39c9f18..5c4207d94 100644 --- a/tests/regression/tools/Makefile.am +++ b/tests/regression/tools/Makefile.am @@ -1,2 +1,2 @@ SUBDIRS = streaming filtering health tracefile-limits snapshots live exclusion save-load mi \ - wildcard crash metadata-regen + wildcard crash metadata-regen templates diff --git a/tests/regression/tools/templates/Makefile.am b/tests/regression/tools/templates/Makefile.am new file mode 100644 index 000000000..8fe5b1986 --- /dev/null +++ b/tests/regression/tools/templates/Makefile.am @@ -0,0 +1,17 @@ +noinst_SCRIPTS = test_create +EXTRA_DIST = $(noinst_SCRIPTS) sessions +SUBDIRS= sessions + +all-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + cp -f $(srcdir)/$$script $(builddir); \ + done; \ + fi + +clean-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + rm -f $(builddir)/$$script; \ + done; \ + fi diff --git a/tests/regression/tools/templates/sessions/Makefile.am b/tests/regression/tools/templates/sessions/Makefile.am new file mode 100644 index 000000000..484426bff --- /dev/null +++ b/tests/regression/tools/templates/sessions/Makefile.am @@ -0,0 +1,18 @@ +EXTRA_DIST = live.lttng live_output_generation.lttng name_generation.lttng \ + normal_local.lttng normal_net.lttng normal_no_output.lttng \ + normal_output_generation.lttng shm_path.lttng snapshot_local.lttng \ + snapshot_net.lttng snapshot_output_generation.lttng full_load.lttng + +all-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + cp -f $(srcdir)/$$script $(builddir); \ + done; \ + fi + +clean-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + rm -f $(builddir)/$$script; \ + done; \ + fi diff --git a/tests/regression/tools/templates/sessions/full_load.lttng b/tests/regression/tools/templates/sessions/full_load.lttng new file mode 100644 index 000000000..938f3d7b2 --- /dev/null +++ b/tests/regression/tools/templates/sessions/full_load.lttng @@ -0,0 +1,54 @@ + + + + full_load + + + UST + PER_UID + + + channel0 + true + DISCARD + 131072 + 4 + 0 + 0 + MMAP + 0 + 0 + 0 + + + + + + + + JUL + PER_UID + + + + LOG4J + PER_UID + + + + PYTHON + PER_UID + + + + false + + + true + + /home/jonathan/lttng-traces/full_load-20160607-021349 + + + + + diff --git a/tests/regression/tools/templates/sessions/live.lttng b/tests/regression/tools/templates/sessions/live.lttng new file mode 100644 index 000000000..206127527 --- /dev/null +++ b/tests/regression/tools/templates/sessions/live.lttng @@ -0,0 +1,21 @@ + + + + live + false + + 1000000 + + + + true + + + tcp4://127.0.0.1:5342/ + tcp4://127.0.0.1:5343/ + + + + + + diff --git a/tests/regression/tools/templates/sessions/live_output_generation.lttng b/tests/regression/tools/templates/sessions/live_output_generation.lttng new file mode 100644 index 000000000..ccc038bab --- /dev/null +++ b/tests/regression/tools/templates/sessions/live_output_generation.lttng @@ -0,0 +1,10 @@ + + + + live_output_generation + false + + 1000000 + + + diff --git a/tests/regression/tools/templates/sessions/name_generation.lttng b/tests/regression/tools/templates/sessions/name_generation.lttng new file mode 100644 index 000000000..f2c44c972 --- /dev/null +++ b/tests/regression/tools/templates/sessions/name_generation.lttng @@ -0,0 +1,14 @@ + + + + false + + + true + + /home/jonathan/lttng-traces/normal_local-20160606-132532 + + + + + diff --git a/tests/regression/tools/templates/sessions/normal_local.lttng b/tests/regression/tools/templates/sessions/normal_local.lttng new file mode 100644 index 000000000..fe55111d6 --- /dev/null +++ b/tests/regression/tools/templates/sessions/normal_local.lttng @@ -0,0 +1,15 @@ + + + + normal_local + false + + + true + + /home/jonathan/lttng-traces/normal_local-20160606-132532 + + + + + diff --git a/tests/regression/tools/templates/sessions/normal_net.lttng b/tests/regression/tools/templates/sessions/normal_net.lttng new file mode 100644 index 000000000..3e875a762 --- /dev/null +++ b/tests/regression/tools/templates/sessions/normal_net.lttng @@ -0,0 +1,18 @@ + + + + normal_net + false + + + true + + + tcp4://127.0.0.1:5342/normal_net-20160606-132620 + tcp4://127.0.0.1:5343/ + + + + + + diff --git a/tests/regression/tools/templates/sessions/normal_no_output.lttng b/tests/regression/tools/templates/sessions/normal_no_output.lttng new file mode 100644 index 000000000..85eacb8e7 --- /dev/null +++ b/tests/regression/tools/templates/sessions/normal_no_output.lttng @@ -0,0 +1,15 @@ + + + + normal_no_output + false + + + true + + + + + + + diff --git a/tests/regression/tools/templates/sessions/normal_output_generation.lttng b/tests/regression/tools/templates/sessions/normal_output_generation.lttng new file mode 100644 index 000000000..683f17eee --- /dev/null +++ b/tests/regression/tools/templates/sessions/normal_output_generation.lttng @@ -0,0 +1,7 @@ + + + + normal_output_generation + false + + diff --git a/tests/regression/tools/templates/sessions/shm_path.lttng b/tests/regression/tools/templates/sessions/shm_path.lttng new file mode 100644 index 000000000..17bf2a30b --- /dev/null +++ b/tests/regression/tools/templates/sessions/shm_path.lttng @@ -0,0 +1,16 @@ + + + + shm_path + /tmp/shm_path-20160606-161801 + false + + + true + + /home/jonathan/lttng-traces/shm_path-20160606-161801 + + + + + diff --git a/tests/regression/tools/templates/sessions/snapshot_local.lttng b/tests/regression/tools/templates/sessions/snapshot_local.lttng new file mode 100644 index 000000000..58a8ab435 --- /dev/null +++ b/tests/regression/tools/templates/sessions/snapshot_local.lttng @@ -0,0 +1,24 @@ + + + + snapshot_local + false + + true + + + + + snapshot-1 + 0 + + true + + /home/jonathan/lttng-traces/snapshot_local-20160606-132651 + + + + + + + diff --git a/tests/regression/tools/templates/sessions/snapshot_net.lttng b/tests/regression/tools/templates/sessions/snapshot_net.lttng new file mode 100644 index 000000000..8a068f60d --- /dev/null +++ b/tests/regression/tools/templates/sessions/snapshot_net.lttng @@ -0,0 +1,27 @@ + + + + snapshot_net + false + + true + + + + + snapshot-1 + 0 + + true + + + tcp4://127.0.0.1:5342/ + tcp4://127.0.0.1:5343/ + + + + + + + + diff --git a/tests/regression/tools/templates/sessions/snapshot_output_generation.lttng b/tests/regression/tools/templates/sessions/snapshot_output_generation.lttng new file mode 100644 index 000000000..35ea4e0fa --- /dev/null +++ b/tests/regression/tools/templates/sessions/snapshot_output_generation.lttng @@ -0,0 +1,10 @@ + + + + snapshot_output_generation + false + + true + + + diff --git a/tests/regression/tools/templates/test_create b/tests/regression/tools/templates/test_create new file mode 100755 index 000000000..b16b00ed8 --- /dev/null +++ b/tests/regression/tools/templates/test_create @@ -0,0 +1,718 @@ +#!/bin/bash +# +# Copyright (C) - 2016 Jonathan Rajotte +# +# This library is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the Free +# Software Foundation; version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +TEST_DESC="Session creation based on template" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../../ +SESSIOND_BIN="lttng-sessiond" +RELAYD_BIN="lttng-relayd" + +export LTTNG_SESSION_CONFIG_XSD_PATH=$(readlink -m ${TESTDIR}../src/common/config/) + +SESSION_NAME="load-42" + +DIR=$(readlink -f $TESTDIR) + +NUM_TESTS=89 + +source $TESTDIR/utils/utils.sh + +LTTNG_BIN="lttng --mi xml" + +# MUST set TESTDIR before calling those functions +plan_tests $NUM_TESTS + +print_test_banner "$TEST_DESC" + +#Test related data + +XPATH_SESSION_NAME="//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:name/text()" +XPATH_SESSION_PATH="//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path/text()" +XPATH_SESSION_SNAPSHOT_MODE="//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:snapshot_mode/text()" +XPATH_SESSION_SNAPSHOT_CTRL_URL="//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url/text()" +XPATH_SESSION_SNAPSHOT_DATA_URL="//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:data_url/text()" +XPATH_SESSION_LIVE_TIMER_INTERVAL="//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:live_timer_interval/text()" +XPATH_SAVE_SESSION_SHM_PATH="//sessions/session/shared_memory_path/text()" + +TEMPLATE_DIR="$CURDIR/sessions" + +# TODO: note: most of these fuctions could have been tested via lttng save and +# diffing the original and the saved one. Might want to go this way... + +function test_normal_local() +{ + diag "Load from template a normal session with local consumer output" + local template_name="normal_local.lttng" + local session_name="normal_local" + local output_path="/home/jonathan/lttng-traces/normal_local-20160606-132532" + + local template_path="$TEMPLATE_DIR/$template_name" + + local mi_output_file=$(mktemp) + if [ $? -ne 0 ]; then + break; + fi + + + create_lttng_session_template_ok "$template_path" + + OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name + + # Validate name + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_NAME}") + if [[ $mi_result = "$session_name" ]]; then + ok 0 "Session names are the same" + else + fail "Session names should be $session_name but value is $mi_result" + fi + + # Validate output + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") + if [[ $mi_result = "$output_path" ]]; then + ok 0 "Output paths are the same" + else + fail "Output paths should be $output_path but value is $mi_result" + fi + + destroy_lttng_session_ok $session_name +} + +function test_normal_no_output() +{ + diag "Load from template a normal session with no output (--no-output)" + local template_name="normal_no_output.lttng" + local session_name="normal_no_output" + local output_path="" + + local template_path="$TEMPLATE_DIR/$template_name" + + local mi_output_file=$(mktemp) + if [ $? -ne 0 ]; then + break; + fi + + + create_lttng_session_template_ok "$template_path" + + OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name + + # Validate name + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_NAME}") + if [[ $mi_result = "$session_name" ]]; then + ok 0 "Session names are the same" + else + fail "Session names should be $session_name but value is $mi_result" + fi + + # Validate output + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") + if [[ $mi_result = "$output_path" ]]; then + ok 0 "Output paths are the same" + else + fail "Output paths should be empty but value is $mi_result" + fi + + destroy_lttng_session_ok $session_name +} + +function test_normal_net() +{ + diag "Load from template a normal session with net output" + local template_name="normal_net.lttng" + local session_name="normal_net" + local output_path="tcp4://127.0.0.1:5342/normal_net-20160606-132620 [data: 5343]" + + local template_path="$TEMPLATE_DIR/$template_name" + + local mi_output_file=$(mktemp) + if [ $? -ne 0 ]; then + break; + fi + + + create_lttng_session_template_ok "$template_path" + + OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name + + # Validate name + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_NAME}") + if [[ $mi_result = "$session_name" ]]; then + ok 0 "Session names are the same" + else + fail "Session names should be $session_name but value is $mi_result" + fi + + # Validate output + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") + if [[ $mi_result = "$output_path" ]]; then + ok 0 "Output paths are the same" + else + fail "Output paths should be empty but value is $mi_result" + fi + + destroy_lttng_session_ok $session_name +} + +function test_snapshot_local() +{ + diag "Load from template a snapshot session with local output" + local template_name="snapshot_local.lttng" + local session_name="snapshot_local" + local output_path="" + local snapshot_ctrl_url="/home/jonathan/lttng-traces/snapshot_local-20160606-132651" + local snapshot_data_url="" + + local template_path="$TEMPLATE_DIR/$template_name" + + local mi_output_file=$(mktemp) + if [ $? -ne 0 ]; then + break; + fi + + + create_lttng_session_template_ok "$template_path" + + OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name + + # Validate name + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_MODE}") + if [[ $mi_result = "1" ]]; then + ok 0 "Session snapshot mode is enabled" + else + fail "Session snapshot mode is invalid value is $mi_result" + fi + + # Validate output + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") + if [[ $mi_result = "$output_path" ]]; then + ok 0 "Output paths are the same" + else + fail "Output paths should be empty but value is $mi_result" + fi + + OUTPUT_DEST="$mi_output_file" lttng_snapshot_list $session_name + + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_CTRL_URL}") + if [[ $mi_result = "$snapshot_ctrl_url" ]]; then + ok 0 "Ctrl urls for snapshot are the same" + else + fail "Ctrl urls should be $snapshot_ctrl_url but value is $mi_result" + fi + + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_DATA_URL}") + if [[ $mi_result = "$snapshot_data_url" ]]; then + ok 0 "Data urls for snapshot are the same" + else + fail "Data urls should be $snapshot_data_url but value is $mi_result" + fi + + destroy_lttng_session_ok $session_name +} + +function test_snapshot_net() +{ + diag "Load from template a snapshot session with net output" + local template_name="snapshot_net.lttng" + local session_name="snapshot_net" + local output_path="" + local snapshot_ctrl_url="tcp4://127.0.0.1:5342/" + local snapshot_data_url="tcp4://127.0.0.1:5343/" + + local template_path="$TEMPLATE_DIR/$template_name" + + local mi_output_file=$(mktemp) + if [ $? -ne 0 ]; then + break; + fi + + create_lttng_session_template_ok "$template_path" + + OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name + + # Validate name + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_MODE}") + if [[ $mi_result = "1" ]]; then + ok 0 "Session snapshot mode is enabled" + else + fail "Session snapshot mode is invalid value is $mi_result" + fi + + # Validate output + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") + if [[ $mi_result = "$output_path" ]]; then + ok 0 "Output paths are the same" + else + fail "Output paths should be empty but value is $mi_result" + fi + + OUTPUT_DEST="$mi_output_file" lttng_snapshot_list $session_name + + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_CTRL_URL}") + if [[ $mi_result = "$snapshot_ctrl_url" ]]; then + ok 0 "Ctrl urls for snapshot are the same" + else + fail "Ctrl urls should be $snapshot_ctrl_url but value is $mi_result" + fi + + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_DATA_URL}") + if [[ $mi_result = "$snapshot_data_url" ]]; then + ok 0 "Data urls for snapshot are the same" + else + fail "Data urls should be $snapshot_data_url but value is $mi_result" + fi + + destroy_lttng_session_ok $session_name +} + +function test_live() +{ + diag "Load from template a live session" + local template_name="live.lttng" + local session_name="live" + local output_path="tcp4://127.0.0.1:5342/ [data: 5343]" + local live_timer_interval="1000000" + + local template_path="$TEMPLATE_DIR/$template_name" + + local mi_output_file=$(mktemp) + if [ $? -ne 0 ]; then + break; + fi + + + create_lttng_session_template_ok "$template_path" + + OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name + + # Validate name + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_NAME}") + if [[ $mi_result = "$session_name" ]]; then + ok 0 "Session names are the same" + else + fail "Session names should be $session_name but value is $mi_result" + fi + + # Validate live timer + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_LIVE_TIMER_INTERVAL}") + if [[ $mi_result = "$live_timer_interval" ]]; then + ok 0 "Session live timer intervals are the same" + else + fail "Session live timer should be $live_timer_interval but value is $mi_result" + fi + + # Validate output + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") + if [[ $mi_result = "$output_path" ]]; then + ok 0 "Output paths are the same" + else + fail "Output paths should be empty but value is $mi_result" + fi + + destroy_lttng_session_ok $session_name +} + +function test_shm_path() +{ + # Since lttng list do not expose the shm path save the session and check + # for the shm path. + diag "Load from template a session with a shared memory path" + local template_name="shm_path.lttng" + local session_name="shm_path" + local shared_memory_path="/tmp/shm_path-20160606-161801" + + local template_path="$TEMPLATE_DIR/$template_name" + + local save_output_path=$(mktemp -d) + local save_output_file="${save_output_path}/$session_name.lttng" + if [ $? -ne 0 ]; then + break; + fi + + create_lttng_session_template_ok "$template_path" + + lttng_save $session_name "-o ${save_output_path}" + + # Validate name + save_result=$($CURDIR/../mi/extract_xml $save_output_file "${XPATH_SAVE_SESSION_SHM_PATH}") + if [[ $save_result = "$shared_memory_path" ]]; then + ok 0 "Session shared memory paths are the same" + else + fail "Session shared memory path should be $shared_memory_path but value is $save_result" + fi + + rm $save_output_file + rmdir $save_output_path + destroy_lttng_session_ok $session_name +} + +# Default data generation +function test_name_generation() +{ + diag "Load from template a session with no name" + local template_name="name_generation.lttng" + local template_path="$TEMPLATE_DIR/$template_name" + + # On session creation success a name must have been generated. + create_lttng_session_template_ok "$template_path" + + destroy_lttng_session_ok $session_name +} + +function test_normal_output_generation() +{ + diag "Load from template a normal session with no consumer output defined" + local template_name="normal_output_generation.lttng" + local session_name="normal_output_generation" + local output_path="/home/jonathan/lttng-traces/normal_local-20160606-132532" + + local template_path="$TEMPLATE_DIR/$template_name" + + local mi_output_file=$(mktemp) + if [ $? -ne 0 ]; then + break; + fi + + create_lttng_session_template_ok "$template_path" + + OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name + + # Validate output + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") + if [ ! -z "$mi_result" ]; then + ok 0 "Output path was generated" + else + fail "Output path should not be empty $mi_result" + fi + + destroy_lttng_session_ok $session_name +} + +function test_snapshot_output_generation() +{ + diag "Load from template a snapshot session with no local output defined" + local template_name="snapshot_output_generation.lttng" + local session_name="snapshot_output_generation" + + local template_path="$TEMPLATE_DIR/$template_name" + + local mi_output_file=$(mktemp) + if [ $? -ne 0 ]; then + break; + fi + + + create_lttng_session_template_ok "$template_path" + + OUTPUT_DEST="$mi_output_file" lttng_snapshot_list $session_name + + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_CTRL_URL}") + if [ ! -z "${mi_result}" ]; then + ok 0 "Local snapshot output was generated" + else + fail "Local snapshot output is null" + fi + + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_DATA_URL}") + if [ -z "${mi_result}" ]; then + ok 0 "Data url is empty as planned" + else + fail "Data url should be null but value is : $mi_result" + fi + + destroy_lttng_session_ok $session_name +} + +function test_live_output_generation() +{ + diag "Load from template a live session with no consumer output defined" + local template_name="live_output_generation.lttng" + local session_name="live_output_generation" + local output_path="tcp4://127.0.0.1:5342/ [data: 5343]" + + local template_path="$TEMPLATE_DIR/$template_name" + + local mi_output_file=$(mktemp) + if [ $? -ne 0 ]; then + break; + fi + + create_lttng_session_template_ok "$template_path" + + OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name + + # Validate output + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") + if [[ $mi_result = "$output_path" ]]; then + ok 0 "Output path was generated and value is good: $mi_result" + else + fail "Output path default is invalid: $mi_result" + fi + + destroy_lttng_session_ok $session_name +} + +# Override +function test_overwrite_live_timer() +{ + diag "Load from template a live session - Overwrite live timer" + local template_name="live.lttng" + local session_name="live" + local output_path="tcp4://127.0.0.1:5342/ [data: 5343]" + local live_timer_interval="123456" + + local template_path="$TEMPLATE_DIR/$template_name" + + local mi_output_file=$(mktemp) + if [ $? -ne 0 ]; then + break; + fi + + create_lttng_session_template_ok "$template_path" "--live=${live_timer_interval}" + + OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name + + # Validate live timer + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_LIVE_TIMER_INTERVAL}") + if [[ $mi_result = "$live_timer_interval" ]]; then + ok 0 "Session live timer intervals are the same: $mi_result == $live_timer_interval" + else + fail "Session live timer should be $live_timer_interval but value is $mi_result" + fi + + destroy_lttng_session_ok $session_name +} + +function test_overwrite_shm_path() +{ + # Since lttng list do not expose the shm path save the session and check + # for the shm path. + diag "Load from template a session with a shared memory path - Overwrite shm path" + local template_name="shm_path.lttng" + local session_name="shm_path" + local shared_memory_path="/tmp/beer-run" + + local template_path="$TEMPLATE_DIR/$template_name" + + local save_output_path=$(mktemp -d) + local save_output_file="${save_output_path}/$session_name.lttng" + if [ $? -ne 0 ]; then + break; + fi + + create_lttng_session_template_ok "$template_path" "--shm-path=${shared_memory_path}" + + lttng_save $session_name "-o ${save_output_path}" + + # Validate name + save_result=$($CURDIR/../mi/extract_xml $save_output_file "${XPATH_SAVE_SESSION_SHM_PATH}") + if [[ $(dirname $save_result) = "$shared_memory_path" ]]; then + ok 0 "Session shared memory paths are the same" + else + fail "Session shared memory path should be $shared_memory_path but value is $save_result" + fi + + rm $save_output_file + rmdir $save_output_path + destroy_lttng_session_ok $session_name +} + +function test_overwrite_normal_net_to_local() +{ + diag "Load from template a normal session with net output - Overwrite to local output" + local template_name="normal_net.lttng" + local session_name="normal_net" + local output_path="/tmp/beer-run" + + local template_path="$TEMPLATE_DIR/$template_name" + + local mi_output_file=$(mktemp) + if [ $? -ne 0 ]; then + break; + fi + + create_lttng_session_template_ok "$template_path" "--set-url=file://${output_path}" + + OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name + + # Validate output + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") + if [[ $mi_result = "$output_path" ]]; then + ok 0 "Output paths are the same" + else + fail "Output paths should be empty but value is $mi_result" + fi + + destroy_lttng_session_ok $session_name + + create_lttng_session_template_ok "$template_path" "--output=${output_path}" + + OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name + + # Validate output + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") + if [[ $mi_result = "$output_path" ]]; then + ok 0 "Output paths are the same" + else + fail "Output paths should be empty but value is $mi_result" + fi + + destroy_lttng_session_ok $session_name + +} + +function test_overwrite_snapshot_local_to_net() +{ + diag "Load from template a snapshot session with local output" + local template_name="snapshot_local.lttng" + local session_name="snapshot_local" + local output_path="" + local snapshot_ctrl_url="tcp4://127.0.0.1:5342/" + local snapshot_data_url="tcp4://127.0.0.1:5343/" + + local template_path="$TEMPLATE_DIR/$template_name" + + local mi_output_file=$(mktemp) + if [ $? -ne 0 ]; then + break; + fi + + create_lttng_session_template_ok "$template_path" "--ctrl-url=${snapshot_ctrl_url} --data-url=${snapshot_data_url}" + + OUTPUT_DEST="$mi_output_file" lttng_snapshot_list $session_name + + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_CTRL_URL}") + if [[ $mi_result = "$snapshot_ctrl_url" ]]; then + ok 0 "Ctrl urls for snapshot are the same" + else + fail "Ctrl urls should be $snapshot_ctrl_url but value is $mi_result" + fi + + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_SNAPSHOT_DATA_URL}") + if [[ $mi_result = "$snapshot_data_url" ]]; then + ok 0 "Data urls for snapshot are the same" + else + fail "Data urls should be $snapshot_data_url but value is $mi_result" + fi + + destroy_lttng_session_ok $session_name +} + +function test_overwrite_live_net() +{ + diag "Load from template a live session - Overwrite net output" + local template_name="live.lttng" + local session_name="live" + local ctrl_url="tcp4://127.0.0.1:1000/" + local data_url="tcp4://127.0.0.1:1001/" + local output_path="tcp4://127.0.0.1:1000/ [data: 1001]" + + local template_path="$TEMPLATE_DIR/$template_name" + + local mi_output_file=$(mktemp) + if [ $? -ne 0 ]; then + break; + fi + + create_lttng_session_template_ok "$template_path" "--ctrl-url=${ctrl_url} --data-url=${data_url}" + + OUTPUT_DEST="$mi_output_file" list_lttng_with_opts $session_name + + # Validate output + mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "${XPATH_SESSION_PATH}") + if [[ $mi_result = "$output_path" ]]; then + ok 0 "Output paths are the same" + else + fail "Output paths should be empty but value is $mi_result" + fi + + destroy_lttng_session_ok $session_name +} + +# With subchild data +function test_full_load() +{ + # Since lttng list do not expose the shm path save the session and check + # for the shm path. + diag "Load from template a complex session with henabled channel and events" + local template_name="full_load.lttng" + local session_name="full_load" + + local template_path="$TEMPLATE_DIR/$template_name" + + local save_output_path=$(mktemp -d) + local save_output_file="${save_output_path}/$session_name.lttng" + if [ $? -ne 0 ]; then + break; + fi + + create_lttng_session_template_ok "$template_path" + + lttng_save $session_name "-o ${save_output_path}" + + # Validate name + save_result=$($CURDIR/../mi/extract_xml $save_output_file "${XPATH_SAVE_SESSION_SHM_PATH}") + if diff $template_path $save_output_path ; then + ok 0 "Session complex load" + else + fail "Sessions results are different" + fi + + rm $save_output_file + rmdir $save_output_path + destroy_lttng_session_ok $session_name +} + +TESTS=( + test_normal_local + test_normal_no_output + test_normal_net + test_snapshot_local + test_snapshot_net + test_live + test_shm_path + # Default data generation + test_name_generation + test_normal_output_generation + test_snapshot_output_generation + test_live_output_generation + # Override + test_overwrite_live_timer + test_overwrite_shm_path + test_overwrite_normal_net_to_local + test_overwrite_snapshot_local_to_net + test_overwrite_live_net + # With subchild data + test_full_load +) + +start_lttng_relayd +start_lttng_sessiond + +for fct_test in ${TESTS[@]}; +do + ${fct_test} + if [ $? -ne 0 ]; then + break; + fi + # Only delete if successful +done + +stop_lttng_sessiond +stop_lttng_relayd + + diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index da2efe91a..d4ba4d060 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -689,6 +689,29 @@ function create_lttng_session_fail () create_lttng_session 1 "$@" } +function create_lttng_session_template () +{ + local expected_to_fail=$1 + local template_path=$2 + local opt=$3 + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN create --template-path="$template_path" $opt > $OUTPUT_DEST + ret=$? + if [[ $expected_to_fail -eq "1" ]]; then + test "$ret" -ne "0" + ok $? "Create session from template $template_path failed as expected" + else + ok $ret "Create session from template $template_path" + fi +} + +function create_lttng_session_template_ok () { + create_lttng_session_template 0 "$@" +} + +function create_lttng_session_template_fail () { + create_lttng_session_template 1 "$@" +} function enable_ust_lttng_channel () { -- 2.34.1