Test: load --override-url
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 19 Sep 2016 17:34:49 +0000 (13:34 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 7 Oct 2016 04:44:06 +0000 (00:44 -0400)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
tests/regression/tools/save-load/Makefile.am
tests/regression/tools/save-load/configuration/Makefile.am [new file with mode: 0644]
tests/regression/tools/save-load/configuration/load-42-live.lttng [new file with mode: 0644]
tests/regression/tools/save-load/configuration/load-42-snapshot.lttng [new file with mode: 0644]
tests/regression/tools/save-load/test_load
tests/utils/utils.sh

index dd7dddc818251b07cc040a21787b11d595d2836c..ab72dbe5e4f1d2807b6b3ffcd846a453d4e59dbe 100644 (file)
@@ -992,6 +992,7 @@ AC_CONFIG_FILES([
        tests/regression/tools/live/Makefile
        tests/regression/tools/exclusion/Makefile
        tests/regression/tools/save-load/Makefile
+       tests/regression/tools/save-load/configuration/Makefile
        tests/regression/tools/mi/Makefile
        tests/regression/tools/wildcard/Makefile
        tests/regression/tools/crash/Makefile
index 2913154a1fd0977d12ee24121085f06d1a2a5871..5cd677620c892d1fb290c268ff95a6642bed5ded 100644 (file)
@@ -2,6 +2,8 @@ noinst_SCRIPTS = test_save test_load
 EXTRA_DIST = $(noinst_SCRIPTS) load-42.lttng load-42-complex.lttng \
        load-42-trackers.lttng
 
+SUBDIRS = configuration
+
 all-local:
        @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
                for script in $(EXTRA_DIST); do \
diff --git a/tests/regression/tools/save-load/configuration/Makefile.am b/tests/regression/tools/save-load/configuration/Makefile.am
new file mode 100644 (file)
index 0000000..79673fc
--- /dev/null
@@ -0,0 +1,16 @@
+EXTRA_DIST = load-42-stream.lttng load-42-live.lttng \
+       load-42-snapshot.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/save-load/configuration/load-42-live.lttng b/tests/regression/tools/save-load/configuration/load-42-live.lttng
new file mode 100644 (file)
index 0000000..6335a58
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sessions>
+       <session>
+               <name>load-42-live</name>
+               <started>false</started>
+               <attributes>
+                       <live_timer_interval>1000000</live_timer_interval>
+               </attributes>
+               <output>
+                       <consumer_output>
+                               <enabled>true</enabled>
+                               <destination>
+                                       <net_output>
+                                               <control_uri>tcp4://127.0.0.1:5342/</control_uri>
+                                               
+                                       </net_output>
+                               </destination>
+                       </consumer_output>
+               </output>
+       </session>
+</sessions>
diff --git a/tests/regression/tools/save-load/configuration/load-42-snapshot.lttng b/tests/regression/tools/save-load/configuration/load-42-snapshot.lttng
new file mode 100644 (file)
index 0000000..f66ec2e
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sessions>
+       <session>
+               <name>load-42-snapshot</name>
+               <started>false</started>
+               <attributes>
+                       <snapshot_mode>true</snapshot_mode>
+               </attributes>
+               <output>
+                       <snapshot_outputs>
+                               <output>
+                                       <name>snapshot-1</name>
+                                       <max_size>0</max_size>
+                                       <consumer_output>
+                                               <enabled>true</enabled>
+                                               <destination>
+                                                       <net_output>
+                                                               <control_uri>tcp4://127.0.0.1:5342/</control_uri>
+                                                               
+                                                       </net_output>
+                                               </destination>
+                                       </consumer_output>
+                               </output>
+                       </snapshot_outputs>
+               </output>
+       </session>
+</sessions>
index b9a3412ac967b0809ba3b07887ae29034bad3796..ff1471b814bc5cd36fa058b2d007aeef52ee5861 100755 (executable)
@@ -18,6 +18,7 @@
 TEST_DESC="Load session(s)"
 
 CURDIR=$(dirname $0)/
+CONFIG_DIR="${CURDIR}/configuration"
 TESTDIR=$CURDIR/../../../
 SESSIOND_BIN="lttng-sessiond"
 RELAYD_BIN="lttng-relayd"
@@ -29,7 +30,7 @@ EVENT_NAME="tp:tptest"
 
 DIR=$(readlink -f $TESTDIR)
 
-NUM_TESTS=30
+NUM_TESTS=62
 
 source $TESTDIR/utils/utils.sh
 
@@ -42,7 +43,7 @@ function test_basic_load()
 {
        diag "Test basic load"
 
-       lttng_load "-i $CURDIR/$SESSION_NAME.lttng"
+       lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng"
 
        destroy_lttng_session_ok $SESSION_NAME
 }
@@ -58,7 +59,7 @@ function test_complex_load()
        # custom values.
        start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
 
-       lttng_load "-i $CURDIR/$sess.lttng"
+       lttng_load_ok "-i $CURDIR/$sess.lttng"
 
        # Once loaded, we are suppose to be able to disable certain events/channels
        # thus having a confirmation that it's valid
@@ -97,6 +98,7 @@ function test_complex_load()
        destroy_lttng_session_ok $sess
 
        stop_lttng_relayd
+       rm -rf ${mi_output_file}
 }
 
 function test_all_load()
@@ -107,7 +109,7 @@ function test_all_load()
        # custom values.
        start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
 
-       lttng_load "-a -i $CURDIR"
+       lttng_load_ok "-a -i $CURDIR"
 
        destroy_lttng_session_ok $SESSION_NAME
        destroy_lttng_session_ok "$SESSION_NAME-complex"
@@ -120,10 +122,10 @@ function test_overwrite()
 {
        diag "Test load overwrite"
 
-       lttng_load "-i $CURDIR/$SESSION_NAME.lttng"
+       lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng"
 
        # This one should succeed
-       lttng_load "-f -i $CURDIR $SESSION_NAME"
+       lttng_load_ok "-f -i $CURDIR $SESSION_NAME"
 
        destroy_lttng_session_ok $SESSION_NAME
 }
@@ -132,7 +134,7 @@ function test_trackers()
 {
        diag "Test trackers loading"
 
-       lttng_load "-i $CURDIR/$SESSION_NAME-trackers.lttng"
+       lttng_load_ok "-i $CURDIR/$SESSION_NAME-trackers.lttng"
 
        diag "Test pid tracker"
        local mi_output_file=$(mktemp)
@@ -151,6 +153,153 @@ function test_trackers()
        lttng_untrack_ok "-p 666 -u -s $SESSION_NAME-trackers"
 
        destroy_lttng_session_ok "$SESSION_NAME-trackers"
+       rm -rf ${mi_output_file}
+}
+
+function test_override_url_normal()
+{
+       local local_url_override="file:///tmp/override/to/here"
+       local local_path_override="/tmp/override/to/here"
+       local local_path_compare_value="/tmp/override/to/here/"
+       local stream_url_override="net://127.0.0.1:8172:9817"
+       local stream_url_compare="tcp4://127.0.0.1:8172/ [data: 9817]"
+
+       diag "Test url override for normal session"
+
+       start_lttng_relayd "-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
+
+       local mi_output_file=$(mktemp)
+       if [ $? -ne 0 ]; then
+               break;
+       fi
+
+       # Url of style file://
+       lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${local_url_override}"
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file
+       mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
+
+       test $mi_result = "${local_path_compare_value}"
+       ok $? "Path url file:// override [{$mi_result}, ${local_path_compare_value}]"
+       destroy_lttng_session_ok "$SESSION_NAME"
+
+       # Url of style /
+       lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${local_path_override}"
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file
+       mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
+
+       test $mi_result = "${local_path_compare_value}"
+       ok $? "Path url / override [{$mi_result}, ${local_path_compare_value}]"
+       destroy_lttng_session_ok "$SESSION_NAME"
+
+       # Url of style net://ip:port:port
+       lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${stream_url_override}"
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file
+       mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
+
+       test "$mi_result" = "${stream_url_compare}"
+       ok $? "Path url net://host:port:port override [${mi_result}, ${stream_url_compare}]"
+
+       destroy_lttng_session_ok "$SESSION_NAME"
+       stop_lttng_relayd
+       rm -rf ${mi_output_file}
+}
+
+function test_override_url_snapshot()
+{
+       local url_override="file:///tmp/override/to/here"
+       local path_override="/tmp/override/to/here"
+       local path_compare_value="/tmp/override/to/here/"
+       local stream_url_override="net://127.0.0.1:8172:9817"
+       local stream_url_compare_ctrl="tcp4://127.0.0.1:8172/"
+       local stream_url_compare_data="tcp4://127.0.0.1:9817/"
+       local local_session_name="${SESSION_NAME}-snapshot"
+
+       diag "Test url override for snapshot session"
+
+       start_lttng_relayd "-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
+
+       local mi_output_file=$(mktemp)
+       if [ $? -ne 0 ]; then
+               break;
+       fi
+
+       # Url of style file://
+       lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${url_override}"
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file
+       mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url")
+
+       test $mi_result = "${path_compare_value}"
+       ok $? "Path url file:// override [{$mi_result}, ${path_compare_value}]"
+       destroy_lttng_session_ok "$local_session_name"
+
+       # Url of style /
+       lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${path_override}"
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file
+       mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url")
+
+       test $mi_result = "${path_compare_value}"
+       ok $? "Path url / override [{$mi_result}, ${path_compare_value}]"
+       destroy_lttng_session_ok "$local_session_name"
+
+       # Url of style net://ip:port:port
+       lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${stream_url_override}"
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file
+       mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url")
+
+       test "$mi_result" = "${stream_url_compare_ctrl}"
+       ok $? "Path url ctrl net://host:port:port override [${mi_result}, ${stream_url_compare_ctrl}]"
+
+       mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:data_url")
+
+       test "$mi_result" = "${stream_url_compare_data}"
+       ok $? "Path url data net://host:port:port override [${mi_result}, ${stream_url_compare_data}]"
+
+       destroy_lttng_session_ok "$local_session_name"
+       stop_lttng_relayd
+       rm -rf ${mi_output_file}
+}
+
+function test_override_url_live()
+{
+       local url_override="file:///tmp/override/to/here"
+       local path_override="/tmp/override/to/here"
+       local path_compare_value="/tmp/override/to/here/"
+       local stream_url_override="net://127.0.0.1:8172:9817"
+       local stream_url_compare="tcp4://127.0.0.1:8172/ [data: 9817]"
+       local local_session_name="${SESSION_NAME}-live"
+
+       diag "Test url override for live session"
+
+       start_lttng_relayd "-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
+
+       local mi_output_file=$(mktemp)
+       if [ $? -ne 0 ]; then
+               break;
+       fi
+
+       # Url of style file://
+       # Expect this to fail since live session should never accept local
+       # output.
+       lttng_load_fail "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${url_override}"
+       destroy_lttng_session_fail "$local_session_name"
+
+       # Url of style /
+       # Expect this to fail since live session should never accept local
+       # output.
+       lttng_load_fail "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${path_override}"
+       destroy_lttng_session_fail "$local_session_name"
+
+       # Url of style net://ip:port:port
+       lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${stream_url_override}"
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$local_session_name" > $mi_output_file
+       mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
+
+       test "$mi_result" = "${stream_url_compare}"
+       ok $? "Path url net://host:port:port override [${mi_result}, ${stream_url_compare}]"
+
+       destroy_lttng_session_ok "$local_session_name"
+       stop_lttng_relayd
+       rm -rf ${mi_output_file}
 }
 
 start_lttng_sessiond
@@ -161,6 +310,9 @@ TESTS=(
        test_all_load
        test_overwrite
        test_trackers
+       test_override_url_normal
+       test_override_url_snapshot
+       test_override_url_live
 )
 
 for fct_test in ${TESTS[@]};
index 8e40407aa615de3bd41f2f903bb6e6a4ecb8091a..05d88650e9f369bfd84ed939c405967d2de314b3 100644 (file)
@@ -1139,10 +1139,27 @@ function lttng_save()
 
 function lttng_load()
 {
-       local opts=$1
+       local expected_to_fail=$1
+       local opts=$2
 
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN load $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
-       ok $? "Load command with opts: $opts"
+       ret=$?
+       if [[ $expected_to_fail -eq "1" ]]; then
+               test $ret -ne "0"
+               ok $? "Load command failed as expected with opts: $opts"
+       else
+               ok $ret "Load command with opts: $opts"
+       fi
+}
+
+function lttng_load_ok()
+{
+       lttng_load 0 "$@"
+}
+
+function lttng_load_fail()
+{
+       lttng_load 1 "$@"
 }
 
 function lttng_track()
This page took 0.031854 seconds and 4 git commands to generate.