From: Jonathan Rajotte Date: Mon, 19 Sep 2016 17:34:49 +0000 (-0400) Subject: Test: load --override-url X-Git-Tag: v2.9.0-rc1~22 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=192ac418bed152e8655e250e723d3c6b8814c747;p=lttng-tools.git Test: load --override-url Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- diff --git a/configure.ac b/configure.ac index dd7dddc81..ab72dbe5e 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/tests/regression/tools/save-load/Makefile.am b/tests/regression/tools/save-load/Makefile.am index 2913154a1..5cd677620 100644 --- a/tests/regression/tools/save-load/Makefile.am +++ b/tests/regression/tools/save-load/Makefile.am @@ -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 index 000000000..79673fc7f --- /dev/null +++ b/tests/regression/tools/save-load/configuration/Makefile.am @@ -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 index 000000000..6335a5879 --- /dev/null +++ b/tests/regression/tools/save-load/configuration/load-42-live.lttng @@ -0,0 +1,21 @@ + + + + load-42-live + false + + 1000000 + + + + true + + + tcp4://127.0.0.1:5342/ + tcp4://127.0.0.1:5343/ + + + + + + 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 index 000000000..f66ec2ed9 --- /dev/null +++ b/tests/regression/tools/save-load/configuration/load-42-snapshot.lttng @@ -0,0 +1,27 @@ + + + + load-42-snapshot + false + + true + + + + + snapshot-1 + 0 + + true + + + tcp4://127.0.0.1:5342/ + tcp4://127.0.0.1:5343/ + + + + + + + + diff --git a/tests/regression/tools/save-load/test_load b/tests/regression/tools/save-load/test_load index b9a3412ac..ff1471b81 100755 --- a/tests/regression/tools/save-load/test_load +++ b/tests/regression/tools/save-load/test_load @@ -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[@]}; diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 8e40407aa..05d88650e 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -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()