1 #!/usr/bin/ksh
   2 
   3 #
   4 # This file and its contents are supplied under the terms of the
   5 # Common Development and Distribution License ("CDDL"), version 1.0.
   6 # You may only use this file in accordance with the terms of version
   7 # 1.0 of the CDDL.
   8 #
   9 # A full copy of the text of the CDDL should have accompanied this
  10 # source.  A copy of the CDDL is also available via the Internet at
  11 # http://www.illumos.org/license/CDDL.
  12 #
  13 
  14 #
  15 # Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  16 #
  17 
  18 #
  19 # Test wrapper for NFS sharemnt tests
  20 #
  21 # Requirements
  22 #        - valid unique host names in /etc/hosts files
  23 #        - enable nfsmapid_domain on the server 
  24 #        - setup root ssh and allow root rlogin without passwd
  25 #          by setting PermitRootLogin entry in sshd_config
  26 #
  27 # Define necessary environments and config variables here
  28 #
  29 export STF_SUITE=/opt/nfssharemnt-tests
  30 export STC_NFSUTILS=$STF_SUITE
  31 export RUNFILE=$STF_SUITE/tests/stf_description
  32 PATH=$PATH:$STF_SUITE/include                   # replace rsh with ssh
  33 PATH=$PATH:/opt/SUNWstc-stf/bin/$(isainfo -n)   # stf_ tools
  34 PATH=$PATH:/opt/SUNWstc-genutils/bin            # genutils tools
  35 PATH=$PATH:/opt/SUNWstc-checkenv/bin            # checkenv tools
  36 export PATH
  37 
  38 usage() {
  39         echo "Usage: $0 ip tests"
  40         echo "Where"
  41         echo "   ip     nfs server IP address"
  42         echo "   tests  tests to run separated by space"
  43         echo "          run all if not specified"
  44         exit 1
  45 }
  46 
  47 #
  48 # Must be run by root
  49 #
  50 if [ `id -u` -ne 0 ]; then
  51         echo Must run by root
  52         exit 1
  53 fi
  54 
  55 #
  56 # IP is a must
  57 #
  58 if [ $# -lt 1 ]; then
  59         usage
  60 fi
  61 
  62 SERVER=$1
  63 ping $SERVER 5
  64 if [ $? != 0 ]; then
  65         echo Invalid nfs server is specified
  66         exit 1
  67 fi
  68 
  69 shift
  70 TESTS=$@
  71 #
  72 # Some global environments
  73 # Modify test specific config.vars to reset test specific envs
  74 #
  75 ALL="accesslist basic misc_opts nfslogd sharetab shmnt_file stress"
  76 SHRTAB_REBOOT="TRUE"    # for sharetab test
  77 NUM_SHARES=4000         # for stress test
  78 STRESS_TIMEOUT=10800    # for stress test
  79 export SERVER SHRTAB_REBOOT NUM_SHARES STRESS_TIMEOUT
  80 
  81 if [ -z "$TESTS" ]; then        # run all
  82         TESTS=$ALL
  83 fi
  84 
  85 #
  86 # Override STF test log setup
  87 #
  88 STF_LOGDIR=/var/tmp/nfssharemnt-tests/results
  89 export STF_LOGDIR
  90 
  91 #
  92 # Set RUNFILE to run test
  93 #
  94 for t in `echo $TESTS`; do
  95         #
  96         # Is test valid?
  97         #
  98         if [ "${ALL#*$t}" = "$ALL" ]; then
  99                 echo $t is not a valid test, skip
 100                 continue
 101         fi
 102         #       
 103         # Reset STF_EXECUTE_SUBDIRS in RUNFILE
 104         # to run the test
 105         #
 106         eval sed -i "s/^STF_EXECUTE_SUBDIRS=.*/STF_EXECUTE_SUBDIRS='$t'/g" $RUNFILE
 107         #
 108         # Configure test
 109         #
 110         stf_configure
 111 
 112         #
 113         # Run test
 114         #
 115         stf_execute
 116 
 117         #
 118         # Unconfigure test
 119         #
 120         stf_unconfigure
 121 
 122         #
 123         # Save individual test log
 124         #
 125         mv $STF_LOGDIR/journal* $STF_LOGDIR/$t.$(date +%Y%m%d%H%M)
 126 done