Whamcloud - gitweb
LU-14789 tests: make sanity 133f and 133g working
[fs/lustre-release.git] / lustre / tests / racer / dir_remote.sh
index b2d28fb..5e6f197 100755 (executable)
@@ -1,15 +1,24 @@
 #!/bin/bash
+trap 'kill $(jobs -p)' EXIT
 
 DIR=$1
 MAX=$2
 
-MDTCOUNT=${MDSCOUNT:-$(lfs df $DIR 2> /dev/null | grep -c MDT)}
+MDTCOUNT=${MDSCOUNT:-$($LFS df $DIR 2> /dev/null | grep -c MDT)}
 while /bin/true ; do
        remote_dir=$((RANDOM % MAX))
        file=$((RANDOM % MAX))
        mdt_idx=$((RANDOM % MDTCOUNT))
-       mkdir -p $DIR
-       lfs mkdir -i$mdt_idx -c$MDTCOUNT $DIR/$remote_dir 2> /dev/null
-       echo "abcd" > $DIR/$remote_dir/$file 2> /dev/null
-       $LFS getdirstripe $DIR/$remote_dir 2> /dev/null
+
+       if $RACER_ENABLE_STRIPED_DIRS; then
+               # stripe_count in range [1,MDTCOUNT]
+               # $LFS mkdir treats stripe_count 0 and 1 the same
+               stripe_count_opt="-c$((RANDOM % MDTCOUNT + 1))"
+       else
+               stripe_count_opt=""
+       fi
+
+       $LFS mkdir -i$mdt_idx $stripe_count_opt $DIR/$remote_dir 2> /dev/null
+       touch $DIR/$remote_dir/$file 2> /dev/null
+       $LFS getdirstripe $DIR/$remote_dir > /dev/null 2>&1
 done