Tests: add tests for the save and load feature
authorDavid Goulet <dgoulet@efficios.com>
Wed, 19 Mar 2014 20:19:04 +0000 (16:19 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 24 Mar 2014 20:08:56 +0000 (16:08 -0400)
This commit integrates the tests to the fast make check.

Fixes #757

Signed-off-by: David Goulet <dgoulet@efficios.com>
configure.ac
tests/fast_regression
tests/regression/tools/Makefile.am
tests/regression/tools/save-load/ /tmp/tmp.eAJ1f0oCZE/test-42/save-42.lttng [new file with mode: 0644]
tests/regression/tools/save-load/Makefile.am [new file with mode: 0644]
tests/regression/tools/save-load/load-42-complex.lttng [new file with mode: 0644]
tests/regression/tools/save-load/load-42.lttng [new file with mode: 0644]
tests/regression/tools/save-load/test_load [new file with mode: 0755]
tests/regression/tools/save-load/test_save [new file with mode: 0755]
tests/utils/utils.sh

index 26f286b06bdd4c48df32ff39a4d8f3fec1f7eb57..ce46a753e7878b10d530de78264e5a19e5d82511 100644 (file)
@@ -426,6 +426,7 @@ AC_CONFIG_FILES([
        tests/regression/tools/snapshots/Makefile
        tests/regression/tools/live/Makefile
        tests/regression/tools/exclusion/Makefile
+       tests/regression/tools/save-load/Makefile
        tests/regression/ust/Makefile
        tests/regression/ust/nprocesses/Makefile
        tests/regression/ust/high-throughput/Makefile
index 40acf5cd71af94f8b05fb9d2ee99fe4f39e87136..e4ac615dc7ce6b9cf0a46a66aa4ddafa2e374235 100644 (file)
@@ -11,6 +11,8 @@ regression/tools/tracefile-limits/test_tracefile_size
 regression/tools/exclusion/test_exclusion
 regression/tools/snapshots/test_ust_fast
 regression/tools/snapshots/test_ust_streaming
+regression/tools/save-load/test_save
+regression/tools/save-load/test_load
 regression/ust/before-after/test_before_after
 regression/ust/buffers-pid/test_buffers_pid
 regression/ust/multi-session/test_multi_session
index f3bdc25f4ee9eb0fab668648d04c49533413b407..84df800758b8f3487f1026f6a6d0c240621dbeb8 100644 (file)
@@ -1 +1 @@
-SUBDIRS = streaming filtering health tracefile-limits snapshots live exclusion
+SUBDIRS = streaming filtering health tracefile-limits snapshots live exclusion save-load
diff --git a/tests/regression/tools/save-load/ /tmp/tmp.eAJ1f0oCZE/test-42/save-42.lttng b/tests/regression/tools/save-load/ /tmp/tmp.eAJ1f0oCZE/test-42/save-42.lttng
new file mode 100644 (file)
index 0000000..be7545c
--- /dev/null
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sessions>
+       <session>
+               <name>save-42</name>
+               <domains>
+                       <domain>
+                               <type>UST</type>
+                               <buffer_type>PER_UID</buffer_type>
+                               <channels>
+                                       <channel>
+                                               <name>chan1</name>
+                                               <enabled>true</enabled>
+                                               <overwrite_mode>DISCARD</overwrite_mode>
+                                               <subbuffer_size>131072</subbuffer_size>
+                                               <subbuffer_count>4</subbuffer_count>
+                                               <switch_timer_interval>0</switch_timer_interval>
+                                               <read_timer_interval>0</read_timer_interval>
+                                               <output_type>MMAP</output_type>
+                                               <tracefile_size>0</tracefile_size>
+                                               <tracefile_count>0</tracefile_count>
+                                               <live_timer_interval>0</live_timer_interval>
+                                               <events>
+                                                       <event>
+                                                               <name>tp:tptest</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                               <loglevel_type>ALL</loglevel_type>
+                                                               <loglevel>-1</loglevel>
+                                                       </event>
+                                               </events>
+                                               <contexts/>
+                                       </channel>
+                               </channels>
+                       </domain>
+               </domains>
+               <started>false</started>
+               <output>
+                       <consumer_output>
+                               <enabled>true</enabled>
+                               <destination>
+                                       <path>/tmp/tmp.eAJ1f0oCZE</path>
+                               </destination>
+                       </consumer_output>
+               </output>
+       </session>
+</sessions>
diff --git a/tests/regression/tools/save-load/Makefile.am b/tests/regression/tools/save-load/Makefile.am
new file mode 100644 (file)
index 0000000..72b3039
--- /dev/null
@@ -0,0 +1,16 @@
+noinst_SCRIPTS = test_save test_load
+EXTRA_DIST = $(noinst_SCRIPTS)
+
+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/load-42-complex.lttng b/tests/regression/tools/save-load/load-42-complex.lttng
new file mode 100644 (file)
index 0000000..e8a360b
--- /dev/null
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sessions>
+       <session>
+               <name>load-42-complex</name>
+               <domains>
+                       <domain>
+                               <type>UST</type>
+                               <buffer_type>PER_UID</buffer_type>
+                               <channels>
+                                       <channel>
+                                               <name>chan3</name>
+                                               <enabled>true</enabled>
+                                               <overwrite_mode>DISCARD</overwrite_mode>
+                                               <subbuffer_size>262144</subbuffer_size>
+                                               <subbuffer_count>4</subbuffer_count>
+                                               <switch_timer_interval>0</switch_timer_interval>
+                                               <read_timer_interval>200000</read_timer_interval>
+                                               <output_type>MMAP</output_type>
+                                               <tracefile_size>0</tracefile_size>
+                                               <tracefile_count>0</tracefile_count>
+                                               <live_timer_interval>1000000</live_timer_interval>
+                                               <events>
+                                                       <event>
+                                                               <name>uevent3*</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                               <loglevel_type>ALL</loglevel_type>
+                                                               <loglevel>-1</loglevel>
+                                                               <exclusions>
+                                                                       <exclusion>uevent3-42</exclusion>
+                                                               </exclusions>
+                                                       </event>
+                                                       <event>
+                                                               <name>uevent3*</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                               <loglevel_type>ALL</loglevel_type>
+                                                               <loglevel>-1</loglevel>
+                                                       </event>
+                                               </events>
+                                               <contexts/>
+                                       </channel>
+                                       <channel>
+                                               <name>chan2</name>
+                                               <enabled>true</enabled>
+                                               <overwrite_mode>DISCARD</overwrite_mode>
+                                               <subbuffer_size>131072</subbuffer_size>
+                                               <subbuffer_count>4</subbuffer_count>
+                                               <switch_timer_interval>0</switch_timer_interval>
+                                               <read_timer_interval>0</read_timer_interval>
+                                               <output_type>MMAP</output_type>
+                                               <tracefile_size>131072</tracefile_size>
+                                               <tracefile_count>14</tracefile_count>
+                                               <live_timer_interval>1000000</live_timer_interval>
+                                               <events>
+                                                       <event>
+                                                               <name>uevent2</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                               <loglevel_type>RANGE</loglevel_type>
+                                                               <loglevel>6</loglevel>
+                                                       </event>
+                                               </events>
+                                               <contexts/>
+                                       </channel>
+                                       <channel>
+                                               <name>chan1</name>
+                                               <enabled>true</enabled>
+                                               <overwrite_mode>DISCARD</overwrite_mode>
+                                               <subbuffer_size>131072</subbuffer_size>
+                                               <subbuffer_count>16</subbuffer_count>
+                                               <switch_timer_interval>0</switch_timer_interval>
+                                               <read_timer_interval>0</read_timer_interval>
+                                               <output_type>MMAP</output_type>
+                                               <tracefile_size>0</tracefile_size>
+                                               <tracefile_count>0</tracefile_count>
+                                               <live_timer_interval>1000000</live_timer_interval>
+                                               <events>
+                                                       <event>
+                                                               <name>uevent1</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                               <loglevel_type>ALL</loglevel_type>
+                                                               <loglevel>-1</loglevel>
+                                                               <filter>$ctx.procname == &quot;test&quot;</filter>
+                                                       </event>
+                                               </events>
+                                               <contexts/>
+                                       </channel>
+                               </channels>
+                       </domain>
+               </domains>
+               <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:8172/</control_uri>
+                                               
+                                       </net_output>
+                               </destination>
+                       </consumer_output>
+               </output>
+       </session>
+</sessions>
diff --git a/tests/regression/tools/save-load/load-42.lttng b/tests/regression/tools/save-load/load-42.lttng
new file mode 100644 (file)
index 0000000..a031aa0
--- /dev/null
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sessions>
+       <session>
+               <name>load-42</name>
+               <domains>
+                       <domain>
+                               <type>UST</type>
+                               <buffer_type>PER_UID</buffer_type>
+                               <channels>
+                                       <channel>
+                                               <name>channel0</name>
+                                               <enabled>true</enabled>
+                                               <overwrite_mode>DISCARD</overwrite_mode>
+                                               <subbuffer_size>131072</subbuffer_size>
+                                               <subbuffer_count>4</subbuffer_count>
+                                               <switch_timer_interval>0</switch_timer_interval>
+                                               <read_timer_interval>0</read_timer_interval>
+                                               <output_type>MMAP</output_type>
+                                               <tracefile_size>0</tracefile_size>
+                                               <tracefile_count>0</tracefile_count>
+                                               <live_timer_interval>0</live_timer_interval>
+                                               <events>
+                                                       <event>
+                                                               <name>*</name>
+                                                               <enabled>true</enabled>
+                                                               <type>TRACEPOINT</type>
+                                                               <loglevel_type>ALL</loglevel_type>
+                                                               <loglevel>-1</loglevel>
+                                                       </event>
+                                               </events>
+                                               <contexts/>
+                                       </channel>
+                               </channels>
+                       </domain>
+               </domains>
+               <started>false</started>
+               <output>
+                       <consumer_output>
+                               <enabled>true</enabled>
+                               <destination>
+                                       <path>/tmp/lttng/load-42-1</path>
+                               </destination>
+                       </consumer_output>
+               </output>
+       </session>
+</sessions>
diff --git a/tests/regression/tools/save-load/test_load b/tests/regression/tools/save-load/test_load
new file mode 100755 (executable)
index 0000000..a58c299
--- /dev/null
@@ -0,0 +1,134 @@
+#!/bin/bash
+#
+# Copyright (C) - 2014 David Goulet <dgoulet@efficios.com>
+#
+# 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="Load session(s)"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../../
+SESSIOND_BIN="lttng-sessiond"
+RELAYD_BIN="lttng-relayd"
+LTTNG_BIN="lttng"
+
+SESSION_NAME="load-42"
+EVENT_NAME="tp:tptest"
+
+DIR=$(readlink -f $TESTDIR)
+
+NUM_TESTS=20
+
+source $TESTDIR/utils/utils.sh
+
+# MUST set TESTDIR before calling those functions
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+function disable_event()
+{
+       local sess_name="$1"
+       local chan_name="$2"
+       local event_name="$3"
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1
+       ok $? "Disable event $event_name for session $sess_name"
+}
+
+function test_basic_load()
+{
+       diag "Test basic load"
+
+       lttng_load "-s $SESSION_NAME -i $CURDIR"
+
+       destroy_lttng_session $SESSION_NAME
+}
+
+function test_complex_load()
+{
+       local sess="$SESSION_NAME-complex"
+       diag "Test complex load"
+
+       # Start relayd with localhost binding. The complex session uses those
+       # custom values.
+       start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
+
+       lttng_load "-s $sess -i $CURDIR"
+
+       # Once loaded, we are suppose to be able to disable certain events/channels
+       # thus having a confirmation that it's valid
+       disable_event $sess chan1 uevent1
+       disable_event $sess chan2 uevent2
+       disable_event $sess chan3 uevent3*
+
+       disable_ust_lttng_channel $sess chan1
+       disable_ust_lttng_channel $sess chan2
+       disable_ust_lttng_channel $sess chan3
+
+       destroy_lttng_session $sess
+
+       stop_lttng_relayd_nocheck
+}
+
+function test_all_load()
+{
+       diag "Test load all sessions"
+
+       # Start relayd with localhost binding. The complex session uses those
+       # custom values.
+       start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
+
+       lttng_load "-a -i $CURDIR"
+
+       destroy_lttng_session $SESSION_NAME
+       destroy_lttng_session "$SESSION_NAME-complex"
+
+       stop_lttng_relayd_nocheck
+}
+
+function test_overwrite()
+{
+       diag "Test load overwrite"
+
+       lttng_load "-s $SESSION_NAME -i $CURDIR"
+
+       # This one should succeed
+       lttng_load "-f -s $SESSION_NAME -i $CURDIR"
+
+       destroy_lttng_session $SESSION_NAME
+}
+
+start_lttng_sessiond
+
+TESTS=(
+       test_basic_load
+       test_complex_load
+       test_all_load
+       test_overwrite
+)
+
+for fct_test in ${TESTS[@]};
+do
+       TRACE_PATH=$(mktemp -d)
+
+       ${fct_test}
+       if [ $? -ne 0 ]; then
+               break;
+       fi
+       # Only delete if successful
+       rm -rf $TRACE_PATH
+done
+
+stop_lttng_sessiond
diff --git a/tests/regression/tools/save-load/test_save b/tests/regression/tools/save-load/test_save
new file mode 100755 (executable)
index 0000000..1f6bbbd
--- /dev/null
@@ -0,0 +1,156 @@
+#!/bin/bash
+#
+# Copyright (C) - 2014 David Goulet <dgoulet@efficios.com>
+#
+# 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="Save session(s)"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../../
+SESSIOND_BIN="lttng-sessiond"
+RELAYD_BIN="lttng-relayd"
+LTTNG_BIN="lttng"
+
+SESSION_NAME="save-42"
+CHANNEL_NAME="chan-save"
+EVENT_NAME="tp:tptest"
+
+DIR=$(readlink -f $TESTDIR)
+
+NUM_TESTS=37
+
+source $TESTDIR/utils/utils.sh
+
+# MUST set TESTDIR before calling those functions
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+# Expected to fail
+function save_lttng_fail()
+{
+       local sess_name=$1
+       local opts=$2
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN save $sess_name $opts >/dev/null 2>&1
+       if [ $? -ne 0 ]; then
+               ok 0 "Session failed to be saved. Expected!"
+       else
+               ok 1 "Session has been saved. NOT expected!"
+       fi
+}
+
+function is_session_saved()
+{
+       local path=$1
+       local name=$2
+
+       [ -f "$path/$name.lttng" ];
+       ok $? "Session $name.lttng file found!"
+}
+
+function test_basic_save()
+{
+       diag "Test basic save"
+
+       create_lttng_session $SESSION_NAME $TRACE_PATH
+       enable_ust_lttng_channel $SESSION_NAME $CHANNEL_NAME
+       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+
+       lttng_save $SESSION_NAME "-o $TRACE_PATH"
+
+       is_session_saved $TRACE_PATH $SESSION_NAME
+
+       destroy_lttng_session $SESSION_NAME
+}
+
+function test_basic_save_all()
+{
+       diag "Test basic save all"
+
+       create_lttng_session $SESSION_NAME-1 $TRACE_PATH
+       create_lttng_session $SESSION_NAME-2 $TRACE_PATH
+       create_lttng_session $SESSION_NAME-3 $TRACE_PATH
+
+       enable_ust_lttng_channel $SESSION_NAME-1 $CHANNEL_NAME
+       enable_ust_lttng_channel $SESSION_NAME-2 $CHANNEL_NAME
+       enable_ust_lttng_channel $SESSION_NAME-3 $CHANNEL_NAME
+
+       enable_ust_lttng_event $SESSION_NAME-1 $EVENT_NAME $CHANNEL_NAME
+       enable_ust_lttng_event $SESSION_NAME-2 $EVENT_NAME $CHANNEL_NAME
+       enable_ust_lttng_event $SESSION_NAME-3 $EVENT_NAME $CHANNEL_NAME
+
+       lttng_save "" "-a -o $TRACE_PATH"
+
+       is_session_saved $TRACE_PATH $SESSION_NAME-1
+       is_session_saved $TRACE_PATH $SESSION_NAME-2
+       is_session_saved $TRACE_PATH $SESSION_NAME-3
+
+       destroy_lttng_session $SESSION_NAME-1
+       destroy_lttng_session $SESSION_NAME-2
+       destroy_lttng_session $SESSION_NAME-3
+}
+
+function test_overwrite()
+{
+       diag "Test overwrite session file"
+
+       create_lttng_session $SESSION_NAME $TRACE_PATH
+       enable_ust_lttng_channel $SESSION_NAME $CHANNEL_NAME
+       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+
+       lttng_save $SESSION_NAME "-o $TRACE_PATH"
+
+       is_session_saved $TRACE_PATH $SESSION_NAME
+
+       destroy_lttng_session $SESSION_NAME
+
+       # Create a new session with same name so we can force the overwrite
+       create_lttng_session $SESSION_NAME $TRACE_PATH
+       enable_ust_lttng_channel $SESSION_NAME $CHANNEL_NAME
+       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+
+       # This one MUST fail
+       save_lttng_fail $SESSION_NAME "-o $TRACE_PATH"
+
+       # This one MUST succeed
+       lttng_save $SESSION_NAME "-f -o $TRACE_PATH"
+
+       is_session_saved $TRACE_PATH $SESSION_NAME
+
+       destroy_lttng_session $SESSION_NAME
+}
+
+start_lttng_sessiond
+
+TESTS=(
+       test_basic_save
+       test_basic_save_all
+       test_overwrite
+)
+
+for fct_test in ${TESTS[@]};
+do
+       TRACE_PATH=$(mktemp -d)
+
+       ${fct_test}
+       if [ $? -ne 0 ]; then
+               break;
+       fi
+       # Only delete if successful
+       #rm -rf $TRACE_PATH
+done
+
+stop_lttng_sessiond
index 88304eb80083629b9e26a729ff046ae8855abda4..a1a26d9df00a67c761ece45efd5ad8eba4f987f7 100644 (file)
@@ -400,6 +400,23 @@ function lttng_snapshot_record ()
        ok $? "Snapshot recorded"
 }
 
+function lttng_save()
+{
+       local sess_name=$1
+       local opts=$2
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN save $sess_name $opts >/dev/null 2>&1
+       ok $? "Session successfully saved"
+}
+
+function lttng_load()
+{
+       local opts=$1
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN load $opts >/dev/null 2>&1
+       ok $? "Load command successful"
+}
+
 function trace_matches ()
 {
        event_name=$1
This page took 0.036422 seconds and 4 git commands to generate.