summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xrun-tests.sh8
-rw-r--r--tests/basic/afr/self-heal.t12
-rw-r--r--tests/bugs/bug-1111490.t4
-rwxr-xr-xtests/bugs/bug-857330/normal.t2
-rwxr-xr-xtests/bugs/bug-857330/xml.t2
-rw-r--r--tests/include.rc22
-rwxr-xr-xtests/utils/create-files.py2
-rwxr-xr-xtests/utils/gfid-access.py1
-rwxr-xr-xtests/utils/pidof.py45
10 files changed, 81 insertions, 18 deletions
diff --git a/.gitignore b/.gitignore
index fad3fb794ee..a0a242e05a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@ log
# Generated files
tests/env.rc
+tests/utils/libcxattr.pyc
dht_layout_unittest
mem_pool_unittest
tests/utils/arequal-checksum
diff --git a/run-tests.sh b/run-tests.sh
index 8db2ce7035c..bcf2a69a5cc 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -60,6 +60,14 @@ function check_dependencies()
MISSING="$MISSING pidof"
fi
+ # check for psutil python package
+ test `uname -s` == "Darwin" || test `uname -s` == "FreeBSD" && {
+ pip show psutil | grep -q psutil >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ MISSING="$MISSING psutil"
+ fi
+ }
+
## If dependencies are missing, warn the user and abort
if [ "x$MISSING" != "x" ]; then
test "x${force}" != "xyes" && echo "Aborting."
diff --git a/tests/basic/afr/self-heal.t b/tests/basic/afr/self-heal.t
index acdd6b73ca0..d02820ca624 100644
--- a/tests/basic/afr/self-heal.t
+++ b/tests/basic/afr/self-heal.t
@@ -59,7 +59,7 @@ TEST ls $B0/brick0/def/ghi/file2.txt
TEST ls $B0/brick0/jkl/mno/file.txt
TEST ! ls $B0/brick0/abc/ghi
EXPECT "$NEW_UID$NEW_GID" stat -c %u%g $B0/brick0/abc/def/file_abc_def_2.txt
-TEST diff <($AREQUAL_PATH/arequal-checksum -p $B0/brick0 -i .glusterfs) <($AREQUAL_PATH/arequal-checksum -p $B0/brick1 -i .glusterfs)
+TEST diff <(arequal-checksum -p $B0/brick0 -i .glusterfs) <(arequal-checksum -p $B0/brick1 -i .glusterfs)
#Cleanup
TEST rm -rf $M0/*
@@ -83,7 +83,7 @@ EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0
#check heal has happened in the correct direction
TEST test -d $B0/brick0/file
-TEST diff <($AREQUAL_PATH/arequal-checksum -p $B0/brick0 -i .glusterfs) <($AREQUAL_PATH/arequal-checksum -p $B0/brick1 -i .glusterfs)
+TEST diff <(arequal-checksum -p $B0/brick0 -i .glusterfs) <(arequal-checksum -p $B0/brick1 -i .glusterfs)
#Cleanup
TEST rm -rf $M0/*
@@ -106,7 +106,7 @@ EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0
#check heal has happened in the correct direction
EXPECT "777" stat -c %a $B0/brick0/file
-TEST diff <($AREQUAL_PATH/arequal-checksum -p $B0/brick0 -i .glusterfs) <($AREQUAL_PATH/arequal-checksum -p $B0/brick1 -i .glusterfs)
+TEST diff <(arequal-checksum -p $B0/brick0 -i .glusterfs) <(arequal-checksum -p $B0/brick1 -i .glusterfs)
#Cleanup
TEST rm -rf $M0/*
@@ -130,7 +130,7 @@ EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0
#check heal has happened in the correct direction
EXPECT "$NEW_UID$NEW_GID" stat -c %u%g $B0/brick0/file
-TEST diff <($AREQUAL_PATH/arequal-checksum -p $B0/brick0 -i .glusterfs) <($AREQUAL_PATH/arequal-checksum -p $B0/brick1 -i .glusterfs)
+TEST diff <(arequal-checksum -p $B0/brick0 -i .glusterfs) <(arequal-checksum -p $B0/brick1 -i .glusterfs)
#Cleanup
TEST rm -rf $M0/*
@@ -161,7 +161,7 @@ EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0
#check heal has happened in the correct direction
EXPECT 0 stat -c %s $B0/brick1/file
-TEST diff <($AREQUAL_PATH/arequal-checksum -p $B0/brick0 -i .glusterfs) <($AREQUAL_PATH/arequal-checksum -p $B0/brick1 -i .glusterfs)
+TEST diff <(arequal-checksum -p $B0/brick0 -i .glusterfs) <(arequal-checksum -p $B0/brick1 -i .glusterfs)
#Cleanup
TEST rm -rf $M0/*
@@ -209,7 +209,7 @@ EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0
#check heal has happened in the correct direction
TEST test -f $B0/brick0/hard_link_to_file
TEST test -h $B0/brick0/link_to_file
-TEST diff <($AREQUAL_PATH/arequal-checksum -p $B0/brick0 -i .glusterfs) <($AREQUAL_PATH/arequal-checksum -p $B0/brick1 -i .glusterfs)
+TEST diff <(arequal-checksum -p $B0/brick0 -i .glusterfs) <(arequal-checksum -p $B0/brick1 -i .glusterfs)
#Cleanup
TEST rm -rf $M0/*
diff --git a/tests/bugs/bug-1111490.t b/tests/bugs/bug-1111490.t
index 39aa0f9a69e..7b13c8798ec 100644
--- a/tests/bugs/bug-1111490.t
+++ b/tests/bugs/bug-1111490.t
@@ -16,7 +16,7 @@ TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0
# create file with specific gfid
uuid=`uuidgen`
-EXPECT "File creation OK" python2 $(dirname $0)/../utils/gfid-access.py $M0 ROOT file0 $uuid file
+EXPECT "File creation OK" gfid-access.py $M0 ROOT file0 $uuid file
# check gfid
EXPECT "$uuid" getfattr -m . --only-values -n glusterfs.gfid.string $M0/file0
@@ -27,6 +27,6 @@ TEST umount $M0
TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 --aux-gfid-mount
# touch the file again (gfid-access.py handles errno)
-EXPECT "File creation OK" python2 $(dirname $0)/../utils/gfid-access.py $M0 ROOT file0 $uuid file
+EXPECT "File creation OK" gfid-access.py $M0 ROOT file0 $uuid file
cleanup;
diff --git a/tests/bugs/bug-857330/normal.t b/tests/bugs/bug-857330/normal.t
index 44635a19e42..b7409078775 100755
--- a/tests/bugs/bug-857330/normal.t
+++ b/tests/bugs/bug-857330/normal.t
@@ -14,7 +14,7 @@ TEST $CLI volume start $V0;
TEST glusterfs -s $H0 --volfile-id=$V0 $M0;
-TEST python2 $(dirname $0)/../../utils/create-files.py --multi -b 10 -d 10 -n 10 $M0;
+TEST create-files.py --multi -b 10 -d 10 -n 10 $M0;
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
diff --git a/tests/bugs/bug-857330/xml.t b/tests/bugs/bug-857330/xml.t
index 2029c343093..bacca453dbe 100755
--- a/tests/bugs/bug-857330/xml.t
+++ b/tests/bugs/bug-857330/xml.t
@@ -15,7 +15,7 @@ TEST $CLI volume start $V0;
TEST glusterfs -s $H0 --volfile-id=$V0 $M0;
-TEST python2 $(dirname $0)/../../utils/create-files.py --multi -b 10 -d 10 -n 10 $M0;
+TEST create-files.py --multi -b 10 -d 10 -n 10 $M0;
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
diff --git a/tests/include.rc b/tests/include.rc
index 6b933b036f7..38f713ae73a 100644
--- a/tests/include.rc
+++ b/tests/include.rc
@@ -25,6 +25,8 @@ MOUNT_TYPE_FUSE="fuse.glusterfs"
GREP_MOUNT_OPT_RO="grep (ro"
GREP_MOUNT_OPT_RW="grep (rw"
+PATH=$PATH:${PWD}/tests/utils
+
case $OSTYPE in
Linux)
H0=${H0:=`hostname --fqdn`}; # hostname
@@ -256,6 +258,12 @@ which killall > /dev/null || {
}
}
+which pidof > /dev/null || {
+ pidof() {
+ pidof.py $1
+ }
+}
+
stat -c %s /dev/null > /dev/null 2>&1 || {
stat() {
local format=""
@@ -322,17 +330,17 @@ function cleanup()
# unregister nfs and related services from portmapper/rpcbind
## nfs
- rpcinfo -d 100003 3
+ rpcinfo -d 100003 3 2>/dev/null || true;
## mountd
- rpcinfo -d 100005 1
- rpcinfo -d 100005 3
+ rpcinfo -d 100005 1 2>/dev/null || true;
+ rpcinfo -d 100005 3 2>/dev/null || true;
## nlockmgr
- rpcinfo -d 100021 1
- rpcinfo -d 100021 4
+ rpcinfo -d 100021 1 2>/dev/null || true;
+ rpcinfo -d 100021 4 2>/dev/null || true;
## nfs_acl
- rpcinfo -d 100227 3
+ rpcinfo -d 100227 3 2>/dev/null || true;
- type cleanup_lvm &>/dev/null && cleanup_lvm
+ type cleanup_lvm &>/dev/null && cleanup_lvm || true;
case `uname -s` in
Linux)
diff --git a/tests/utils/create-files.py b/tests/utils/create-files.py
index 0d937eff978..05cf1279999 100755
--- a/tests/utils/create-files.py
+++ b/tests/utils/create-files.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2
# This script was developed by Vijaykumar Koppad (vkoppad@redhat.com)
# The latest version of this script can found at
diff --git a/tests/utils/gfid-access.py b/tests/utils/gfid-access.py
index 25fe35bf50b..4fd4b6dfa8d 100755
--- a/tests/utils/gfid-access.py
+++ b/tests/utils/gfid-access.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python2
#
# Copyright (c) 2011-2014 Red Hat, Inc. <http://www.redhat.com>
# This file is part of GlusterFS.
diff --git a/tests/utils/pidof.py b/tests/utils/pidof.py
new file mode 100755
index 00000000000..575b899b6cc
--- /dev/null
+++ b/tests/utils/pidof.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+import sys
+
+try:
+ import psutil
+except ImportError:
+ print("Please install psutil --> pip install psutil")
+ sys.exit(1)
+
+def pmap_find(p, name):
+ for m in p.memory_maps(grouped=True):
+ if m.path.endswith("%s.so" % name):
+ return True
+ continue
+ return False
+
+def pidof(processname):
+ for p in psutil.process_iter():
+ if p.pid == 0:
+ continue
+ if "gluster" in processname:
+ if processname == "glusterd" and pmap_find(p, "glusterd"):
+ print (p.pid)
+ if processname == "glusterfs" and pmap_find(p, "client"):
+ print (p.pid)
+ if processname == "glusterfsd" and pmap_find(p, "posix-acl"):
+ print (p.pid)
+ continue
+ if processname.strip() == p.name():
+ print (p.pid)
+
+def main(argv):
+ if len(argv) < 2:
+ sys.stderr.write("Usage: %s <processname>\n" % (argv[0],))
+ return 1
+ try:
+ pidof(argv[1])
+ except Exception as err:
+ print err
+ sys.stderr.write("Please be root - %s\n" % err);
+ sys.exit(1)
+
+if __name__ == "__main__":
+ main(sys.argv)