Whamcloud - gitweb
LU-7667 tests: Write to unique files in $TMP
[fs/lustre-release.git] / lustre / tests / conf-sanity.sh
index 7a6d88e..accbf27 100755 (executable)
@@ -2992,7 +2992,7 @@ test_43a() {
        [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
 
        ID1=${ID1:-501}
-       USER1=$(cat /etc/passwd | grep :$ID1:$ID1: | cut -d: -f1)
+       USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
        [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1" &&
                return
 
@@ -3811,9 +3811,9 @@ test_52() {
        echo
 
        # backup files
-       echo backup files to $TMP/files
+       echo backup files to $TMP/$tdir
        local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
-       copy_files_xattrs $(hostname) $TMP/files $TMP/file_xattrs $files ||
+       copy_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
                error "Unable to copy files"
 
        umount_client $MOUNT || error "Unable to umount client"
@@ -3853,10 +3853,10 @@ test_52() {
                error "Some entry under /lost+found should be repaired"
 
        # compare files
-       diff_files_xattrs $(hostname) $TMP/files $TMP/file_xattrs $files ||
+       diff_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
                error "Unable to diff files"
 
-       rm -rf $TMP/files $TMP/file_xattrs ||
+       rm -rf $TMP/$tdir $TMP/file_xattrs ||
                error "Unable to delete temporary files"
        do_node $ost1node "rm -rf $ost1tmp" ||
                error "Unable to delete temporary files"
@@ -6293,6 +6293,111 @@ test_91() {
 }
 run_test 91 "evict-by-nid support"
 
+generate_ldev_conf() {
+       # generate an ldev.conf file
+       local ldevconfpath=$1
+       touch $ldevconfpath
+       printf "%s\t-\t%s-MGS0000\t%s\n" \
+               $mgs_HOST \
+               $FSNAME \
+               $(mgsdevname) >> $ldevconfpath
+
+       local mdsfo_host=$mdsfailover_HOST;
+       if [ -z "$mdsfo_host" ]; then
+               mdsfo_host="-"
+       fi
+
+       for num in $(seq $MDSCOUNT); do
+               printf "%s\t%s\t%s-MDT%04d\t%s\n" \
+                       $mds_HOST \
+                       $mdsfo_host \
+                       $FSNAME \
+                       $num \
+                       $(mdsdevname $num) >> $ldevconfpath
+       done
+
+       local ostfo_host=$ostfailover_HOST;
+       if [ -z "$ostfo_host" ]; then
+               ostfo_host="-"
+       fi
+
+       for num in $(seq $OSTCOUNT); do
+               printf "%s\t%s\t%s-OST%04d\t%s\n" \
+                       $ost_HOST \
+                       $ostfo_host \
+                       $FSNAME \
+                       $num \
+                       $(ostdevname $num) >> $ldevconfpath
+       done
+}
+
+generate_nids() {
+       # generate a nids file (mapping between hostname to nid)
+       # looks like we only have the MGS nid available to us
+       # so just echo that to a file
+       local nidspath=$1
+       touch $nidspath
+       echo -e "${mgs_HOST}\t${MGSNID}" >> $nidspath
+}
+
+test_92() {
+       local LDEVCONFPATH=$TMP/ldev.conf
+       local NIDSPATH=$TMP/nids
+
+       echo "Host is $(hostname)"
+
+       generate_ldev_conf $LDEVCONFPATH
+       generate_nids $NIDSPATH
+
+       echo "----- ldev.conf -----"
+       cat $LDEVCONFPATH
+       echo "--- END ldev.conf ---"
+
+       echo "----- /etc/nids -----"
+       cat $NIDSPATH
+       echo "--- END /etc/nids ---"
+
+       # ldev can be in our build tree and if we aren't in a
+       # build tree, use 'which' to try and find it
+       local LDEV=$LUSTRE/scripts/ldev
+       [ ! -f "$LDEV" ] && local LDEV=$(which ldev 2> /dev/null)
+
+       echo "ldev path is $LDEV"
+
+       if [ ! -f "$LDEV" ]; then
+               rm $LDEVCONFPATH $NIDSPATH
+               error "failed to find ldev!"
+       fi
+
+       # echo the mgs nid and compare it to environment variable MGSNID
+       # also, ldev.conf and nids is a server side thing, use the OSS
+       # hostname
+       local output
+       output=$(perl $LDEV -c $LDEVCONFPATH -H \
+                       $ost_HOST -n $NIDSPATH echo %m)
+
+       echo "-- START OF LDEV OUTPUT --"
+       echo -e "$output"
+       echo "--- END OF LDEV OUTPUT ---"
+
+       # ldev failed, error
+       if [ $? -ne 0 ]; then
+               rm $LDEVCONFPATH $NIDSPATH
+               error "ldev failed to execute!"
+       fi
+
+       # need to process multiple lines because of combined MGS and MDS
+       echo -e $output | awk '{ print $2 }' | while read -r line ; do
+               if [ "$line" != "$MGSNID" ]; then
+                       rm $LDEVCONFPATH $NIDSPATH
+                       error "ldev failed mgs nid '$line', expected '$MGSNID'"
+               fi
+       done
+
+       rm $LDEVCONFPATH $NIDSPATH
+}
+run_test 92 "ldev returns MGS NID correctly in command substitution"
+
 if ! combined_mgs_mds ; then
        stop mgs
 fi