From 82640b7109ef83ed6cc5054c81d076aa3398d249 Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Fri, 31 Aug 2018 12:25:32 +0530 Subject: cluster/dht: Rework the debug xattr to get hashed subvol The earlier implementation required the file to already exist when trying to get the hashed subvol. The reworked implementation allows a user to get the hashed subvol for any filename, whether it exists or not. Usage: getfattr -n "dht.file.hashed-subvol." Eg:To get the hashed subvol for file-1 inside dir-1 getfattr -n "dht.file.hashed-subvol.file-1" /mnt/gluster/dir1 credit: rgowdapp@redhat.com Change-Id: Iae20bd5f56d387ef48c1c0a4ffa9f692866bf739 fixes: bz#1624244 Signed-off-by: N Balachandran --- tests/basic/distribute/debug-xattrs.t | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/basic/distribute/debug-xattrs.t (limited to 'tests') diff --git a/tests/basic/distribute/debug-xattrs.t b/tests/basic/distribute/debug-xattrs.t new file mode 100644 index 00000000000..6d87c0e8671 --- /dev/null +++ b/tests/basic/distribute/debug-xattrs.t @@ -0,0 +1,54 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../nfs.rc +. $(dirname $0)/../../common-utils.rc + +# Test overview: Test the virtual xattrs dht provides for debugging + +# Test 1 : "dht.file.hashed-subvol." +# Get the hashed subvolume for file1 in dir1 using xattr +# Create file1 in dir1 +# Check if the file is created in the brick returned by xattr + +hashdebugxattr="dht.file.hashed-subvol." + +cleanup + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/$V0-{0..3} +TEST $CLI volume start $V0 + +# Mount using FUSE and create a file +TEST glusterfs -s $H0 --volfile-id $V0 $M0 + +# Test 1 : "dht.file.hashed-subvol." +# Get the hashed subvolume for file1 in dir1 using xattr +# Create file1 in dir1 +# Check if the file is created in the brick returned by xattr +# Create a directory on $M0 + +TEST mkdir $M0/dir1 + +xattrname=$hashdebugxattr"file1" + +hashed=$(getfattr --only-values -n "$xattrname" $M0/dir1) + +# Get the brick path for $hashed +brickpath=$(cat "$M0/.meta/graphs/active/$hashed/options/remote-subvolume") +brickpath=$brickpath"/dir1/file1" + +# Create the file for which we checked the xattr +TEST touch $M0/dir1/file1 +TEST stat $brickpath + +# Non-existent directory +TEST ! getfattr --only-values -n "$xattrname" $M0/dir2 + + +# Cleanup +cleanup + -- cgit