summaryrefslogtreecommitdiffstats
path: root/tests/dht.rc
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2018-09-12 18:19:09 +0530
committerN Balachandran <nbalacha@redhat.com>2018-09-17 06:24:15 +0000
commitfb836edec5f0bd805c302497d78fa85937d9d4dc (patch)
treef9549f9c6775bcd4f699dd3f54327bbaed26791c /tests/dht.rc
parent2b157eb97117511c5a47f2227aab81bff90cf32f (diff)
tests/dht: Add tests for file create
Test dht file creates Change-Id: I7aba710f4911432bd3b86834efecae8f01e4052f updates: bz#1628194 Signed-off-by: N Balachandran <nbalacha@redhat.com>
Diffstat (limited to 'tests/dht.rc')
-rw-r--r--tests/dht.rc39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/dht.rc b/tests/dht.rc
index 53b00645e66..6918ebde04b 100644
--- a/tests/dht.rc
+++ b/tests/dht.rc
@@ -1,5 +1,6 @@
#!/bin/bash
+dhthashdebugxattr="dht.file.hashed-subvol."
function get_layout()
{
@@ -133,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
+}