summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorLoic Dachary <loic@dachary.org>2013-03-04 14:42:08 +0100
committerLoic Dachary <loic@dachary.org>2013-04-02 13:10:37 +0200
commit574051f8da0a30073a7d5da880878ee3c941721b (patch)
tree35d8705b76635dc413d8552821c334c7ef3ea057 /qa
parentdd19d693e6528c70167958ebc57e075200a08803 (diff)
downloadceph-574051f8da0a30073a7d5da880878ee3c941721b.tar.gz
unit tests for FileStore::_detect_fs when running on ext4
unit tests are added in test/filestore/store_test.cc for the FileStore::_detect_fs method, when using ext4. It tests the following situations: * without user_xattr, ext4 fails * mounted with user_xattr, ext4 fails if filestore_xattr_use_omap is false * mounted with user_xattr, ext4 succeeds if filestore_xattr_use_omap is true The tests are grouped in an ext4 dedicated class TEST(EXT4StoreTest, _detect_fs) The qa/workunits/filestore/filestore.sh script is added to prepare the environment required for the unit tests ( create an image file, formats it with ext4 etc.). It runs ceph_test_filestore with a sudo to allow it to mount(2) and umount(2) the ext4 file system. It is called with ceph_test_filestore --gtest_filter=EXT4StoreTest.* to only run the ext4 dependent tests. The filestore.sh script is meant to be used as part of teuthology in order to increase the code coverage for src/os/FileStore.cc. It is self tested and can be checked from the source directory with CEPH_TEST_FILESTORE=../../../src/ceph_test_filestore filestore.sh TEST http://tracker.ceph.com/issues/4321 refs #4321 Signed-off-by: Loic Dachary <loic@dachary.org>
Diffstat (limited to 'qa')
-rwxr-xr-xqa/workunits/filestore/filestore.sh80
1 files changed, 80 insertions, 0 deletions
diff --git a/qa/workunits/filestore/filestore.sh b/qa/workunits/filestore/filestore.sh
new file mode 100755
index 00000000000..f951a37ec95
--- /dev/null
+++ b/qa/workunits/filestore/filestore.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
+#
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program 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 Library Public License for more details.
+#
+set -e
+
+export PATH=/sbin:$PATH
+
+: ${VERBOSE:=false}
+: ${EXT4:=$(which mkfs.ext4)}
+: ${EXT3:=$(which mkfs.ext3)}
+: ${XFS:=$(which mkfs.xfs)}
+: ${BTRFS:=$(which mkfs.btrfs)}
+: ${CEPH_TEST_FILESTORE:=ceph_test_filestore}
+: ${FILE_SYSTEMS:=EXT4} # EXT3 XFS BTRFS
+: ${DEBUG:=}
+
+function EXT4_test() {
+ local dir="$1"
+
+ if [ -z "$EXT4" ] ; then
+ echo "mkfs command for ext4 is missing. On Debian GNU/Linux try apt-get install e2fsprogs" >&2
+ return 1
+ fi
+
+ local disk="$dir/disk.img"
+
+ truncate --size=1G $disk || return 1
+ mkfs.ext4 -q -F $disk || return 2
+ mkdir -p $dir/mountpoint || return 3
+ MOUNTPOINT=$dir/mountpoint DISK=$disk sudo -E $CEPH_TEST_FILESTORE --gtest_filter=EXT4StoreTest.* $DEBUG || return 4
+}
+
+function main() {
+ local dir=$(mktemp --directory)
+
+ trap "sudo umount $dir/mountpoint || true ; rm -fr $dir" EXIT QUIT INT
+
+ for fs in $FILE_SYSTEMS ; do
+ ${fs}_test $dir || return 2
+ done
+}
+
+if [ "$1" = TEST ]
+then
+ set -x
+ set -o functrace
+ PS4=' ${FUNCNAME[0]}: $LINENO: '
+
+ DEBUG='--log-to-stderr=true --debug-filestore=20'
+
+ function run_test() {
+ dir=/tmp/filestore
+ rm -fr $dir
+ mkdir $dir
+ EXT4_test $dir || return 1
+
+ FILE_SYSTEMS=EXT4
+ main || return 2
+ }
+
+ run_test
+else
+ main
+fi
+# Local Variables:
+# compile-command: "CEPH_TEST_FILESTORE=../../../src/ceph_test_filestore filestore.sh TEST"
+# End: