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 2016 Nexenta Systems, Inc.  All rights reserved.
  16 #
  17 
  18 #
  19 # Test wrapper for NFSgen tests
  20 #
  21 # Necessary environments and configure variables here
  22 #
  23 # Required
  24 #
  25 #       CLIENT2 - the 2nd client for twoclients test
  26 #
  27 #       SETUP   - determine what test you want to run.
  28 #                 always set to 'nfsv4' unless user wants
  29 #                 to manually setup nfs environment. In this
  30 #                 case set to 'none'.
  31 #
  32 #       DNS_DOMAIN, SRV_DNS_DOMAIN, CLT2_DNS_DOMAIN is used
  33 #       to construct full qualified domain name.
  34 #
  35 # Optionals
  36 #
  37 #       SHRDIR  - shared directory on server
  38 #                 (default is "/nfsgen_share")
  39 #
  40 #       MNTDIR  - mount directory on client
  41 #                 (default is "/nfsgen_mount")
  42 #
  43 #       STRESS_TIMEOUT  - By default, the stress test will 
  44 #                         return if execution time exceeds 10800s
  45 #
  46 #       STF_RESULTS     - /var/tmp/nfsgen/results by default
  47 #
  48 #
  49 #
  50 
  51 DOMAIN=localdomain
  52 export STF_SUITE=/opt/nfsgen-tests
  53 #export TESTROOT=$STF_SUITE/bin
  54 export STF_TOOLS=/opt/SUNWstc-stf
  55 export SETUP=nfsv4
  56 export DNS_DOMAIN=$DOMAIN
  57 export SRV_DNS_DOMAIN=$DOMAIN
  58 export CLT2_DNS_DOMAIN=$DOMAIN
  59 PATH=$PATH:/opt/SUNWstc-genutils/bin
  60 PATH=$PATH:/opt/SUNWstc-stf/bin/$(isainfo -n)
  61 export PATH
  62 
  63 #
  64 # Use of LD_LIBRARY_PATH is not a good practise but STF tools
  65 # depends on libstf.so under /opt/SUNWstc-stf and we have to
  66 #
  67 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/SUNWstc-stf/lib/$(isainfo -n)
  68 export LD_LIBRARY_PATH
  69 
  70 ALL='acl delegation file_ops openlock recovery stress'
  71 CLNTRUNFILE=$STF_SUITE/tests/delegation/stf_description
  72 TSRUNFILE=$STF_SUITE/tests/stf_description
  73 
  74 #
  75 # 2nd client IP is required for delegation/twoclients tests
  76 #
  77 usage() {
  78         echo "Usage: $0 [-c ip] ip test"
  79         echo "Where"
  80         echo "   -c     specify the 2nd client IP for twoclients test"
  81         echo "   ip     nfs server IP address"
  82         echo "   test   specified test, run all if not specified"
  83         exit 1
  84 }
  85 
  86 #
  87 # Must be run by root
  88 #
  89 if [ `id -u` -ne 0 ]; then
  90         echo Must run by root
  91         exit 1
  92 fi
  93 
  94 #
  95 # Get client 2 if specified
  96 #
  97 while getopts ":c:" opt; do
  98         case $opt in
  99            c )
 100                 CLIENT2=$OPTARG;;
 101            \?)
 102                 usage();;       
 103         esac
 104 done
 105 shift $(($OPTIND - 1))
 106 
 107 #
 108 # Server is a must
 109 #
 110 if [ $# -lt 1 ]; then
 111         usage
 112 fi
 113 
 114 SERVER=$1
 115 ping $SERVER 5
 116 if [ $? != 0 ]; then
 117         echo Invalid nfs server IP
 118         exit 1
 119 fi
 120 export SERVER
 121 
 122 if [ -z "$CLIENT2" ]; then
 123         CLNTEST="oneclient"
 124 else
 125         ping $CLIENT2
 126         if [ $? != 0 ]; then
 127                 echo Invalid client 2 IP 
 128                 exit 1
 129         fi
 130 
 131         CLNTEST="oneclient twoclients"
 132 fi
 133 eval sed -i "s/^STF_EXECUTE_SUBDIRS=.*/STF_EXECUTE_SUBDIRS='$CLNTEST'/g" $CLNTRUNFILE
 134 
 135 TEST=$2
 136 #
 137 # Bail out if an invalid test is specified
 138 # No test specified == run all
 139 #
 140 if [ -z "TEST" ]; then
 141         TEST="ALL"
 142 elif [ "${ALL#*$TEST}" = "$ALL" ]; then
 143         echo Invalid test is specified
 144         exit 1
 145 fi
 146 eval sed -i "s/^STF_EXECUTE_SUBDIRS=.*/STF_EXECUTE_SUBDIRS='$TEST'/g" $TSRUNFILE
 147 
 148 #
 149 # Setup the server and client
 150 #
 151 stf_configure
 152 
 153 #
 154 # Run the whole test suite with stf_execute
 155 # Run the specified tests via '-r' option
 156 #
 157 stf_execute
 158 
 159 #
 160 # Cleanup
 161 #
 162 stf_unconfigure