diff mbox

[4/6] new: environments - add performance tests (as example of usage)

Message ID 1426702230-22085-5-git-send-email-jtulak@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Tulak March 18, 2015, 6:10 p.m. UTC
This patch adds new test category for performance tests, which utilises
the new environment architecture.

There are two simple tests. Currently, both are configured to be quick,
running about 20 seconds, so you can easily try them.

- 001 is for benchmarking readdir speed using xfs_io -c "readdir".
  In this test, an environment is used to generate NUM of empty files in
  a directory. Runtime is
- 002 is a simulation of SQLite, using fio for the testing. It uses no environment
  to show how the modified skeleton from ./new script works by default.

Signed-off-by: Jan ?ulák <jtulak@redhat.com>
---
 check                      |   2 +-
 tests/performance/001      | 111 +++++++++++++++++++++++++++++++++++++++++
 tests/performance/002      | 121 +++++++++++++++++++++++++++++++++++++++++++++
 tests/performance/Makefile |  21 ++++++++
 tests/performance/group    |   7 +++
 5 files changed, 261 insertions(+), 1 deletion(-)
 create mode 100755 tests/performance/001
 create mode 100755 tests/performance/002
 create mode 100644 tests/performance/Makefile
 create mode 100644 tests/performance/group
diff mbox

Patch

diff --git a/check b/check
index 39a9d05..bacb66d 100755
--- a/check
+++ b/check
@@ -59,7 +59,7 @@  then
 fi
 
 SUPPORTED_TESTS="[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]"
-SRC_GROUPS="generic shared"
+SRC_GROUPS="generic shared performance"
 export SRC_DIR="tests"
 export ENV_DIR="environments"
 
diff --git a/tests/performance/001 b/tests/performance/001
new file mode 100755
index 0000000..28c6546
--- /dev/null
+++ b/tests/performance/001
@@ -0,0 +1,111 @@ 
+#! /bin/bash
+# FS QA Test No. 001
+#
+# Performance test.
+# Readdir speed for various amounts of files in a directory.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 RedHat.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+# List of environments this test can use for preparing files for the testing.
+# They are independent of each other (multiple entries = multiple runs).
+# If "none" is given, the test can be run without any environment,
+# ommiting it signifies that the test won't run without any of them.
+#
+# Example: supported_environments="none empty_files full_partition"
+
+supported_environments="empty-files"
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs generic
+_supported_os IRIX Linux
+_require_test
+_disable_output_check
+
+run_test(){
+	# PUT TEST BELOW
+	if ! type xfs_io >/dev/null 2>&1; then 
+		_fail "This test requires xfs_io in PATH."
+	fi
+
+	numbers="1000 5000 10000"
+	for n in $numbers;do
+		export ENV_FILES_NUMBER=$n
+		echo "GUU $TEST_DIR"
+		_environment_require $TEST_DIR
+		er=$?
+		if [ $er -ne 0 ];then
+			# TODO what to do if an environment fails? Continue, or skip 
+			# the rest of this test?
+			continue
+		fi
+
+
+		verbose=true
+
+		# check for xfs_io tool
+		which xfs_io >/dev/null 2>&1
+		if [ $? -ne 0 ];then
+			_fatal "xfs_io tool has to be installed in PATH!"
+		fi
+		echo "# MEASURED_DATA"
+		xfs_io -c "readdir" "$TEST_DIR" |paste -sd ", " -
+		_environment_clean $TEST_DIR
+	done
+
+	# PUT TEST ABOVE
+}
+
+
+# Filter the supported_environments by user input (-eo/-ex arguments)
+# and run the test for all environments in the intersect of
+# the supported and user-allowed environments.
+for environment in $(_filter_environments "$supported_environments")
+do
+	export ENV_NAME="$environment"
+	run_test
+done
+
+# optional stuff if your test has verbose output to help resolve problems
+#echo
+#echo "If failure, check $seqres.full (this) and $seqres.full.ok (reference)"
+
+# success, all done
+status=0
+exit
diff --git a/tests/performance/002 b/tests/performance/002
new file mode 100755
index 0000000..9a316ad
--- /dev/null
+++ b/tests/performance/002
@@ -0,0 +1,121 @@ 
+#! /bin/bash
+# FS QA Test No. 002
+#
+# Performance test for simulating SQLite.
+#
+# Requires FIO.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 YOUR NAME HERE.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+# List of environments this test can use for preparing files for the testing.
+# They are independent of each other (multiple entries = multiple runs).
+# If "none" is given, the test can be run without any environment,
+# ommiting it signifies that the test won't run without any of them.
+#
+# Example: supported_environments="none empty_files full_partition"
+
+supported_environments="none"
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	rm database-sqlite.prerun.txt
+    cd /
+    rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs generic
+_supported_os IRIX Linux
+_require_test
+_disable_output_check
+
+FIO_BIN=fio
+RUNTIME=20
+
+cat <<EOF > $tmp.sqlite.fio
+[global]
+rw=randrw
+rwmixread=80
+size=1G
+directory=$TEST_DIR
+fadvise_hint=0
+direct=1
+blocksize=8k
+numjobs=\$ncpus*2
+time_based
+runtime=$RUNTIME
+ioengine=libaio
+norandommap=1
+exec_prerun=echo 3 > /proc/sys/vm/drop_caches
+group_reporting
+
+[database-sqlite]
+nrfiles=1
+numjobs=1
+ioengine=sync
+lockfile=exclusive
+
+EOF
+
+run_test(){
+	_environment_require $TEST_DIR
+	# PUT TEST BELOW
+
+	if ! type $FIO_BIN >/dev/null 2>&1; then 
+		_fail "Can't run without $FIO_BIN installed."
+	fi
+
+	$FIO_BIN --append-terse $tmp.sqlite.fio
+
+	# PUT TEST ABOVE
+	 _environment_clean $TEST_DIR
+}
+
+
+# Filter the supported_environments by user input (-eo/-ex arguments)
+# and run the test for all environments in the intersect of
+# the supported and user-allowed environments.
+for environment in $(_filter_environments "$supported_environments")
+do
+	export ENV_NAME="$environment"
+    run_test
+done
+
+# optional stuff if your test has verbose output to help resolve problems
+#echo
+#echo "If failure, check $seqres.full (this) and $seqres.full.ok (reference)"
+
+# success, all done
+status=0
+exit
diff --git a/tests/performance/Makefile b/tests/performance/Makefile
new file mode 100644
index 0000000..5a50b07
--- /dev/null
+++ b/tests/performance/Makefile
@@ -0,0 +1,21 @@ 
+#
+# Copyright (c) 2003-2005 Silicon Graphics, Inc.  All Rights Reserved.
+#
+
+TOPDIR = ../..
+include $(TOPDIR)/include/builddefs
+
+PERFORMANCE_DIR = performance
+TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(PERFORMANCE_DIR)
+
+include $(BUILDRULES)
+
+install:
+	$(INSTALL) -m 755 -d $(TARGET_DIR)
+	$(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
+	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 environment $(TARGET_DIR)
+	$(INSTALL) -m 644 [0-9]??.* $(TARGET_DIR)
+
+# Nothing.
+install-dev install-lib:
diff --git a/tests/performance/group b/tests/performance/group
new file mode 100644
index 0000000..1c58e14
--- /dev/null
+++ b/tests/performance/group
@@ -0,0 +1,7 @@ 
+# QA groups control file
+# Defines test groups and nominal group owners
+# - do not start group names with a digit
+# - comment line before each group is "new" description
+#
+001 performance readdir
+002 performance fio db-simulation