summaryrefslogtreecommitdiffstats
path: root/tests/dht.rc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dht.rc')
-rw-r--r--tests/dht.rc86
1 files changed, 74 insertions, 12 deletions
diff --git a/tests/dht.rc b/tests/dht.rc
index 50c4532617e..6918ebde04b 100644
--- a/tests/dht.rc
+++ b/tests/dht.rc
@@ -1,9 +1,10 @@
#!/bin/bash
+dhthashdebugxattr="dht.file.hashed-subvol."
+
function get_layout()
{
- getfattr -n trusted.glusterfs.dht -e hex $1 2>&1|grep dht |cut -d = -f2
-
+ getfattr -n trusted.glusterfs.dht -e hex $1 2>&1 | grep dht | cut -d = -f2
}
## populates $BRICK1 and $BRICK2 with hashed/cached subvolume. These will be
@@ -15,7 +16,7 @@ function file_has_linkfile()
l=0
while [ $k -lt $BRICK_COUNT ]
do
- stat=`stat $B0/${V0}$k/$1 2>/dev/null`
+ stat=$(stat $B0/${V0}$k/$1 2>/dev/null)
if [ $? -eq 0 ]
then
let l++
@@ -33,7 +34,7 @@ function get_cached_brick()
brick=$BRICK1
while [ $i -lt 3 ]
do
- test=`getfattr -n trusted.glusterfs.dht.linkto -e text $B0/${V0}$brick/$1 2>&1`
+ test=$(getfattr -n trusted.glusterfs.dht.linkto -e text $B0/${V0}$brick/$1 2>&1)
if [ $? -eq 1 ]
then
cached=$brick
@@ -52,7 +53,7 @@ function get_hashed_brick()
brick=$BRICK1
while [ $j -lt 3 ]
do
- test=`getfattr -n trusted.glusterfs.dht.linkto -e text $B0/${V0}$brick/$1 2>&1`
+ test=$(getfattr -n trusted.glusterfs.dht.linkto -e text $B0/${V0}$brick/$1 2>&1)
if [ $? -eq 0 ]
then
hashed=$brick
@@ -66,43 +67,66 @@ function get_hashed_brick()
}
+function cluster_rebalance_completed()
+{
+ val=1
+
+ # Rebalance status will be either "failed" or "completed"
+
+ test=$($CLI_1 volume rebalance $V0 status | grep "in progress" 2>&1)
+ if [ $? -ne 0 ]
+ then
+ val=0
+ fi
+
+ echo $val
+ # Do not *return* the value here. If it's non-zero, that will cause
+ # EXPECT_WITHIN (e.g. in bug-884455.t) to return prematurely, leading to
+ # a spurious test failure. Nothing else checks the return value anyway
+ # (they all check the output) so there's no need for it to be non-zero
+ # just because grep didn't find what we want.
+}
+
function rebalance_completed()
{
val=1
- test=`gluster volume rebalance $V0 status |grep localhost|grep -v "in progress" 2>&1`
+ test=$($CLI volume rebalance $V0 status | grep localhost | grep "completed" 2>&1)
if [ $? -eq 0 ]
then
- val=0
+ val=0
fi
echo $val
- return $val
+ # Do not *return* the value here. If it's non-zero, that will cause
+ # EXPECT_WITHIN (e.g. in bug-884455.t) to return prematurely, leading to
+ # a spurious test failure. Nothing else checks the return value anyway
+ # (they all check the output) so there's no need for it to be non-zero
+ # just because grep didn't find what we want.
}
function remove_brick_completed()
{
val=1
- test=`gluster volume remove-brick $V0 $H0:$B0/${V0}2 status |grep localhost|grep -v "in progress" 2>&1`
+ test=$(gluster volume remove-brick $V0 $H0:$B0/${V0}2 status | grep localhost | grep "completed" 2>&1)
if [ $? -eq 0 ]
then
val=0
fi
echo $val
- return $val
}
function dht_get_linkto_target()
{
local path=$1;
- echo `getfattr -d -m . -e text --only-values --absolute-names --name=trusted.glusterfs.dht.linkto $path`
+ echo $(getfattr -e text --only-values --absolute-names -n trusted.glusterfs.dht.linkto $path)
}
function is_dht_linkfile()
{
local path=$1
retval=0
- local output=`stat --format=%a $path`
+ local output=$(stat -c %a $path)
if [ $output -eq 1000 ]; then
retval=1
fi
@@ -110,3 +134,41 @@ function is_dht_linkfile()
echo $retval
return $retval
}
+
+
+# Given an existing directory on the volume, get the hashed subvol for a file
+# in that directory
+# Input: filename dirpath_on_mount
+
+function dht_get_hash_subvol()
+{
+ local hashed_subvol
+ hashed_subvol=$(getfattr --only-values -n "$dhthashdebugxattr$1" $2 2>/dev/null)
+ echo $hashed_subvol
+}
+
+
+# Find the first filename that hashes to the same subvol
+# as $1
+# Input: subvol_name dirpath_on_mount file_pattern
+
+function dht_first_filename_with_hashsubvol()
+{
+ local in_subvol=$1
+ local in_path=$2
+ local in_hash_subvol
+ local file_pattern=$3
+ local filename
+
+ for i in {1..50}
+ do
+ filename="$file_pattern$i"
+ in_hash_subvol=$(dht_get_hash_subvol "$filename" "$in_path")
+ # echo $in_hash_subvol
+ if [ "$in_subvol" == "$in_hash_subvol" ]; then
+ fn_return_val=$filename
+ return 0
+ fi
+ done
+ return 1
+}