xfs
[Top] [All Lists]

re[2]: snapshot regression test try 2

To: Ethan Benson <erbenson@xxxxxxxxxx>, xfs mailing list <linux-xfs@xxxxxxxxxxx>
Subject: re[2]: snapshot regression test try 2
From: Greg Freemyer <freemyer@xxxxxxxxxxxxxxxxx>
Date: Fri, 30 Aug 2002 12:05:22 -0400
Organization: The NorcrossGroup
Sender: linux-xfs-bounce@xxxxxxxxxxx
Ethan,

I quote the variables and move to the tmp dir you suggest.

BTW: A single request to quote all variable references would have saved you 
some typing, but I guess you just made comments as you were reviewing the code.

Greg

 >>  On Thu, Aug 29, 2002 at 07:23:25PM -0400, Greg Freemyer wrote:
 >>  > 
 >>  > Nathan,
 >>  > 
 >>  > I have made a second attempt at the script.
 >>  > 
 >>  > I think it addresses your concerns.

 >>  now im going to nitpick.

 >>  > Someone still needs to do the TODO items, but they don't come up in my
 >>  environment because $SCRATCH_DEV is a LV for me.
 >>  > 
 >>  > Steve Lord has run my previous version to some extent, but I don't know
 >>  if he did it via check, or he just ran the script.
 >>  > 
 >>  > Greg Freemyer
 >>  > Internet Engineer
 >>  > Deployment and Integration Specialist
 >>  > Compaq ASE - Tru64 v4, v5
 >>  > Compaq Master ASE - SAN Architect
 >>  > The Norcross Group
 >>  > www.NorcrossGroup.com
 >>  > 
 >>  > ========  068.out
 >>  > QA output created by 068
 >>  > SUCCESS, COMPLETED ALL ITERATIONS WITH NO TIME OUTS!!!!!!!!!!!!
 >>  > Cleanup beginning
 >>  > ======== 068
 >>  > #! /bin/sh
 >>  > # XFS QA Test No. 068
 >>  > # $Id: 1.1 $
 >>  > #
 >>  > # creator
 >>  > owner=freemyer@xxxxxxxxxxxxxxxxx
 >>  > 
 >>  > seq=`basename $0`
 >>  > echo "QA output created by $seq"
 >>  > 
 >>  > here=`pwd`
 >>  > tmp=/tmp/$$

 >>  very predictable, use tmp=`mktemp -d` || exit 1

 >>  > status=1        # failure is the default!
 >>  > 
 >>  > GENERATE_IO_LOAD=TRUE           # If "FALSE", the dd load loop is
 >>  skipped
 >>  > DELAY_BETWEEN_ITERATIONS=10
 >>  > ITERATIONS=20
 >>  > VG=/dev/VGscratch
 >>  > #SCRATCH_DEV=/dev/xxxx          # Only needed if running by hand,  ie.  
 >> >>  check sets these
 >>  > #SCRATCH_MNT=/scratch           # Only needed if running by hand,  ie.  
 >> >>  check sets these
 >>  > SCRATCH_SNAP_MNT=$tmp.scratch_snap

 >>  quote this:

 >>  SCRATCH_SNAP_MNT="$tmp.scratch_snap"

 >>  > 
 >>  > 
 >>  > _cleanup()
 >>  > {
 >>  > 
 >>  >         echo Cleanup beginning
 >>  > 
 >>  >         rm $tmp.running > /dev/null 2>&1
 >>  >         xfs_freeze -u $SCRATCH_MNT

 >>  quote these variables, you cannot be 100% certain they will not
 >>  contain metacharacters or embedded spaces.

 >>  >         sleep 10      # Give the dd loop time to finish
 >>  > 
 >>  >         # Comment out unless needed.  If needed, wrap with logic to
 >>  ensure the FS is mounted
 >>  >         #Kill off any other possible stray stragglers that may be out
 >>  there.  There should not be any.
 >>  >         # fuser -k -m $SCRATCH_SNAP_MNT/dummy     >/dev/null 2>&1
 >>  >         # fuser -k -m $SCRATCH_MNT/dummy          >/dev/null 2>&1
 >>  > 
 >>  >         wait
 >>  > 
 >>  >         umount $SCRATCH_SNAP_MNT > /dev/null 2>&1
 >>  >         rmdir $SCRATCH_SNAP_MNT > /dev/null 2>&1
 >>  >         umount $SCRATCH_MNT > /dev/null 2>&1
 >>  > 
 >>  >         lvremove -f $VG/scratch_snap > /dev/null 2>&1
 >>  >         lvremove -f $VG/scratch > /dev/null 2>&1
 >>  > 
 >>  > #TODO   vgremove $VG
 >>  > 
 >>  >         rm -f $tmp.*        # if we ever use tmp files

 >>  quote, see above.

 >>  >         trap 0 1 2 3 15
 >>  >         exit $status
 >>  > }
 >>  > 
 >>  > trap "_cleanup" 0 1 2 3 15
 >>  > 
 >>  > 
 >>  > # get standard environment, filters and checks
 >>  > . ./common.rc
 >>  > . ./common.filter
 >>  > 
 >>  > if [ -e $SCRATCH_SNAP_MNT ]; then rm -rf $SCRATCH_SNAP_MNT; fi

 >>  NEVER EVER *EVER* rm -rf a unquoted variable.  apple did this in a
 >>  upgrade script and rm -rf'ed / to many users systems.

 >>  > mkdir $SCRATCH_SNAP_MNT

 >>  quote, see above.

 >>  > if [ $LVM = false ]; then _notrun "This test requires the kernel have
 >>  LVM or EVMS present.  (The EVMS test is still TBD)."; fi

 >>  quote these variables, if $LVM somehow ends up null you will get a
 >>  shell syntax error.

 >>  > # Mount the LV
 >>  > mkdir $SCRATCH_MNT > /dev/null 2&>1
 >>  > 
 >>  > mount $VG/scratch $SCRATCH_MNT
 >>  > 
 >>  > if [ $GENERATE_IO_LOAD != FALSE ];

 >>  quote all of these, see above.

 >>  > then
 >>  >         # Create a large 64 Meg zero filled file on the LV
 >>  >         dd if=/dev/zero of=$SCRATCH_MNT/dummy bs=64k count=1000  >
 >>  /dev/null 2>&1

 >>  ditto

 >>  >         #setup an infinite loop to copy the large file, thus generating
 >>  heavy i/o
 >>  > 
 >>  >         touch $tmp.running

 >>  you should put this tmpfile in a secure directory (created by mktemp -d) 

 >>  >         while [ -f $tmp.running ]
 >>  >         do
 >>  >             dd if=$SCRATCH_MNT/dummy of=$SCRATCH_MNT/junk bs=64k >
 >>  /dev/null 2>&1
 >>  >             rm $SCRATCH_MNT/junk        # This forces metadata updates
 >>  the next time around
 >>  >             sync
 >>  >         done &
 >>  > fi
 >>  > 
 >>  > ii=1
 >>  > 
 >>  > while [ $ii -le $ITERATIONS ]

 >>  quote, see above

 >>  > do
 >>  > 
 >>  >         # echo $ii      Usefull if your are running interactive, but not
 >>  from the xfs test scripts

 >>  printf "\r$ii" might be better for this.

 >>  >         #if the VFS lock patch is present, the calls to xfs_freeze are
 >>  redundant, but should cause no problems
 >>  >         #       OPTIONAL
 >>  >         xfs_freeze -f $SCRATCH_MNT

 >>  quote, see above

 >>  >         if [ $? != 0 ] ; then
 >>  >                 echo xfs_freeze -f $SCRATCH_MNT failed
 >>  >         fi
 >>  >         (
 >>  >                 lvcreate --snapshot --size 1G --name scratch_snap
 >>  $VG/scratch > /dev/null 2>&1
 >>  >                 ret=$?
 >>  >                 if [ $ret != 0 ] ; then
 >>  >                         echo snapshot creation for $SCRATCH_MNT failed
 >>  with return code $ret
 >>  >                 fi
 >>  >         ) &

 >>  ditto ditto ditto.

 >>  >         SNAPSHOT_shell_pid=$!
 >>  > 
 >>  >         #if the Snapshot has not completed in ten minutes, kill it
 >>  >         (
 >>  >                         # I have NOT figured out how to kill the sleep
 >>  600 before it exits naturally.
 >>  >                         # This does not cause a problem, but it clutters
 >>  the ps table.
 >>  >                 sleep 600
 >>  >                         # The kill $TIMEOUT_shell_pid keeps the below
 >>  from occuring
 >>  >                 echo Snapshot Lockup Occured on loop $ii
 >>  >                 xfs_freeze -u $SCRATCH_MNT
 >>  >                 kill $$
 >>  >         ) &
 >>  >         TIMEOUT_shell_pid=$!
 >>  > 
 >>  >         wait $SNAPSHOT_shell_pid
 >>  > 
 >>  >         exec 2> /dev/null               # Send the shells stderr to
 >>  /dev/null
 >>  >         kill $TIMEOUT_shell_pid    #Cancel the timeout
 >>  >         wait $TIMEOUT_shell_pid    # This causes consistent shell
 >>  notification for some unknow reason
 >>  >         exec 2>&1                       # Put it back to the same as
 >>  stdout
 >>  > 
 >>  >         #if the VFS lock patch is present, the calls to xfs_freeze are
 >>  redundant, but should cause no problems
 >>  >         #       OPTIONAL
 >>  >         xfs_freeze -u $SCRATCH_MNT
 >>  >         if [ $? != 0 ] ; then
 >>  >                 echo xfs_freeze -u $SCRATCH_MNT failed
 >>  >         fi
 >>  >         #          MANDANTORY   (end)
 >>  > 
 >>  >         mount -t xfs -o ro,nouuid $VG/scratch_snap $SCRATCH_SNAP_MNT
 >>  >         if [ $? != 0 ] ; then
 >>  >                 echo mount for $SCRATCH_SNAP_MNT failed
 >>  >         fi
 >>  >         umount $SCRATCH_SNAP_MNT
 >>  >         if [ $? != 0 ] ; then
 >>  >                 echo umount for $SCRATCH_SNAP_MNT failed
 >>  >         fi
 >>  >         lvremove -f $VG/scratch_snap > /dev/null 2>&1
 >>  >         if [ $? != 0 ] ; then
 >>  >                echo lvremove for $VG/scratch_snap failed
 >>  >         fi
 >>  > 
 >>  > ii=`expr $ii + 1`
 >>  >         sleep $DELAY_BETWEEN_ITERATIONS # The VG seems to need time to
 >>  stabalize between snapshots
 >>  >                         # With LVM 1.0.3 and XFS 1.1, I have tried this
 >>  at 3600 seconds and still had failures
 >>  > 
 >>  > done

 >>  see above, much more quoting.

 >>  > # success, all done
 >>  > echo SUCCESS, COMPLETED ALL ITERATIONS WITH NO TIME OUTS!!!!!!!!!!!!
 >>  > status=0
 >>  > _cleanup
 >>  > exit 1   # _cleanup should exit, so we should never get here.
 >>  > 

 >>  you can argue that im being pedantic and the lack of quoting will
 >>  probably not matter in this script, but in some cases its just too
 >>  dangerous not to.  proper quoting will make your script much more
 >>  solid and less prone to screwy behavior.  also you should never assume
 >>  that there are not hostile users messing with /tmp.

 >>  -- 
 >>  Ethan Benson
 >>  http://www.alaska.net/~erbenson/

 >>  -- Attached file included as plaintext by Ecartis --

 >>  -----BEGIN PGP SIGNATURE-----
 >>  Version: GnuPG v1.0.6 (GNU/Linux)
 >>  Comment: For info see http://www.gnupg.org

 >>  iEYEARECAAYFAj1vHkMACgkQJKx7GixEevweJgCfdNs2BVhZcg6MUzOazlVrJlXa
 >>  A90AnjhtygOAx/NN9gbrI2LSuwUCnDVj
 >>  =LWj5
 >>  -----END PGP SIGNATURE-----








Greg Freemyer
Internet Engineer
Deployment and Integration Specialist
Compaq ASE - Tru64 v4, v5
Compaq Master ASE - SAN Architect
The Norcross Group
www.NorcrossGroup.com


<Prev in Thread] Current Thread [Next in Thread>