Print this page
7290 ZFS test suite needs to control what utilities it can run
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/test/zfs-tests/tests/functional/replacement/replacement_001_pos.ksh
          +++ new/usr/src/test/zfs-tests/tests/functional/replacement/replacement_001_pos.ksh
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19  #
  20   20  # CDDL HEADER END
  21   21  #
  22   22  
  23   23  #
  24   24  # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  25   25  # Use is subject to license terms.
  26   26  #
  27   27  
  28   28  #
  29      -# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
       29 +# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  30   30  #
  31   31  
  32   32  . $STF_SUITE/include/libtest.shlib
  33   33  . $STF_SUITE/tests/functional/replacement/replacement.cfg
  34   34  
  35   35  #
  36   36  # DESCRIPTION:
  37   37  #       Replacing disks during I/O should pass for supported pools.
  38   38  #
  39   39  # STRATEGY:
↓ open down ↓ 3 lines elided ↑ open up ↑
  43   43  #       3. Verify the integrity of the file system and the resilvering.
  44   44  #
  45   45  
  46   46  verify_runnable "global"
  47   47  
  48   48  function cleanup
  49   49  {
  50   50          if [[ -n "$child_pids" ]]; then
  51   51                  for wait_pid in $child_pids
  52   52                  do
  53      -                        $KILL $wait_pid
       53 +                        kill $wait_pid
  54   54                  done
  55   55          fi
  56   56  
  57   57          if poolexists $TESTPOOL1; then
  58   58                  destroy_pool $TESTPOOL1
  59   59          fi
  60   60  
  61      -        [[ -e $TESTDIR ]] && log_must $RM -rf $TESTDIR/*
       61 +        [[ -e $TESTDIR ]] && log_must rm -rf $TESTDIR/*
  62   62  }
  63   63  
  64   64  log_assert "Replacing a disk during I/O completes."
  65   65  
  66   66  options=""
  67   67  options_display="default options"
  68   68  
  69   69  log_onexit cleanup
  70   70  
  71   71  [[ -n "$HOLES_FILESIZE" ]] && options=" $options -f $HOLES_FILESIZE "
↓ open down ↓ 15 lines elided ↑ open up ↑
  87   87  function replace_test
  88   88  {
  89   89          typeset -i iters=2
  90   90          typeset -i index=0
  91   91          typeset opt=$1
  92   92          typeset disk1=$2
  93   93          typeset disk2=$3
  94   94  
  95   95          typeset i=0
  96   96          while [[ $i -lt $iters ]]; do
  97      -                log_note "Invoking $FILE_TRUNC with: $options_display"
  98      -                $FILE_TRUNC $options $TESTDIR/$TESTFILE.$i &
       97 +                log_note "Invoking file_trunc with: $options_display"
       98 +                file_trunc $options $TESTDIR/$TESTFILE.$i &
  99   99                  typeset pid=$!
 100  100  
 101      -                $SLEEP 1
 102      -                if ! $PS -p $pid > /dev/null 2>&1; then
 103      -                        log_fail "$FILE_TRUNC $options $TESTDIR/$TESTFILE.$i"
      101 +                sleep 1
      102 +                if ! ps -p $pid > /dev/null 2>&1; then
      103 +                        log_fail "file_trunc $options $TESTDIR/$TESTFILE.$i"
 104  104                  fi
 105  105  
 106  106                  child_pids="$child_pids $pid"
 107  107                  ((i = i + 1))
 108  108          done
 109  109  
 110      -        log_must $ZPOOL replace $opt $TESTPOOL1 $disk1 $disk2
      110 +        log_must zpool replace $opt $TESTPOOL1 $disk1 $disk2
 111  111  
 112      -        $SLEEP 10
      112 +        sleep 10
 113  113  
 114  114          for wait_pid in $child_pids
 115  115          do
 116      -                $KILL $wait_pid
      116 +                kill $wait_pid
 117  117          done
 118  118          child_pids=""
 119  119  
 120      -        log_must $ZPOOL export $TESTPOOL1
 121      -        log_must $ZPOOL import -d $TESTDIR $TESTPOOL1
 122      -        log_must $ZFS umount $TESTPOOL1/$TESTFS1
 123      -        log_must $ZDB -cdui $TESTPOOL1/$TESTFS1
 124      -        log_must $ZFS mount $TESTPOOL1/$TESTFS1
      120 +        log_must zpool export $TESTPOOL1
      121 +        log_must zpool import -d $TESTDIR $TESTPOOL1
      122 +        log_must zfs umount $TESTPOOL1/$TESTFS1
      123 +        log_must zdb -cdui $TESTPOOL1/$TESTFS1
      124 +        log_must zfs mount $TESTPOOL1/$TESTFS1
 125  125  
 126  126  }
 127  127  
 128  128  specials_list=""
 129  129  i=0
 130  130  while [[ $i != 2 ]]; do
 131      -        $MKFILE $MINVDEVSIZE $TESTDIR/$TESTFILE1.$i
      131 +        mkfile $MINVDEVSIZE $TESTDIR/$TESTFILE1.$i
 132  132          specials_list="$specials_list $TESTDIR/$TESTFILE1.$i"
 133  133  
 134  134          ((i = i + 1))
 135  135  done
 136  136  
 137  137  #
 138  138  # Create a replacement disk special file.
 139  139  #
 140      -$MKFILE $MINVDEVSIZE $TESTDIR/$REPLACEFILE
      140 +mkfile $MINVDEVSIZE $TESTDIR/$REPLACEFILE
 141  141  
 142  142  for type in "" "raidz" "raidz1" "mirror"; do
 143  143          for op in "" "-f"; do
 144  144                  create_pool $TESTPOOL1 $type $specials_list
 145      -                log_must $ZFS create $TESTPOOL1/$TESTFS1
 146      -                log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL1/$TESTFS1
      145 +                log_must zfs create $TESTPOOL1/$TESTFS1
      146 +                log_must zfs set mountpoint=$TESTDIR1 $TESTPOOL1/$TESTFS1
 147  147  
 148  148                  replace_test "$opt" $TESTDIR/$TESTFILE1.1 $TESTDIR/$REPLACEFILE
 149  149  
 150      -                $ZPOOL iostat -v $TESTPOOL1 | grep "$TESTDIR/$REPLACEFILE"
      150 +                zpool iostat -v $TESTPOOL1 | grep "$TESTDIR/$REPLACEFILE"
 151  151                  if [[ $? -ne 0 ]]; then
 152  152                          log_fail "$REPLACEFILE is not present."
 153  153                  fi
 154  154  
 155  155                  destroy_pool $TESTPOOL1
 156      -                log_must $RM -rf /$TESTPOOL1
      156 +                log_must rm -rf /$TESTPOOL1
 157  157          done
 158  158  done
 159  159  
 160  160  log_pass
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX