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 # Define necessary environments and config variables here
20 # prior to invoke TET test runner 'run_test'
21 #
22 # Test wrapper for COMSTAR FC test
23 # FC switch is a must to run the test
24 # The following switch port variable need to be set
25 #
26 # FC_TARGET_SWITCH_PORT
27 #
28 # FC_TARGET_SWITCH_PORT=<FC Switch Model:FC Switch IP:Admin:Passwd:Port1,Port2>
29 # Example: FC_TARGET_SWITCH_PORT=QLOGIC:127.0.0.1:admin:password:1,2
30 #
31 # Initiator and free disks on target are required
32 #
33 export TET_ROOT=/opt/SUNWstc-tetlite
34 export CTI_ROOT=$TET_ROOT/contrib/ctitools
35 export TET_SUITE_ROOT=/opt
36 export CTI_SUITE=$TET_SUITE_ROOT/comstar-tests
37 PATH=$PATH:$CTI_ROOT/bin
38 export PATH
39
40 usage() {
41 echo "Usage: $0 ip switch disk"
42 echo "Where"
43 echo " ip Initiator IP address"
44 echo "switch In form of \"Model:IP:Admin:Passwd:port\""
45 echo " disk c0t0d0s0 c0t1d0s0"
46 exit 1
47 }
48
49 #
50 # Must be run by root
51 #
52 if [ `id -u` -ne 0 ]; then
53 echo Must run by root
54 exit 1
55 fi
56
57 #
58 # At least one disk is required
59 #
60 if [ $# -lt 3 ]; then
61 usage
62 fi
63
64 #
65 # Check heart beat on initiator exit if fails
66 #
67 INITIATOR=$1 # Initiator IP
68 ping $INITIATOR 5
69 if [ $? != 0 ]; then
70 echo "Invalid IP address for Initiator"
71 exit 1
72 fi
73
74 #
75 # Check FC HBA port mode on target and initiator
76 #
77 fcinfo hba-port|grep 'Port Mode'|nawk '{print $3}'|grep Target
78 Tres=$?
79 IHBA="fcinfo hba-port|grep 'Port Mode'|nawk '{print \$3}'|grep Initiator"
80 ssh $INITIATOR "$IHBA"
81 Ires=$?
82
83 if [ $Tres -ne 0 -o $Ires -ne 0 ]; then
84 print Check FC HBA port configuration on the systems
85 exit 1
86 fi
87
88 #
89 # FC switch
90 # There is no easy direct way to validate the switch info
91 # But test will fail if the info entered is not correct
92 #
93 FC_SW=$2
94 NF=`echo $FC_SW | nawk -F":" '{print NF}'`
95 if [ $NF -lt 5 ]; then
96 echo "Invalid FC switch info"
97 exit 1
98 fi
99
100 shift 2
101 DISKS=$@
102
103 #
104 # Initiator needs to have diskomizer package installed
105 #
106 ssh $INITIATOR ls /opt/SUNWstc-diskomizer/bin >/dev/null 2>&1
107 if [ $? -ne 0 ]; then
108 echo "Need to install SUNWstc-diskomizer package on $INITIATOR"
109 exit
110 fi
111
112 #
113 # FC target should have other port provider disabled
114 # to avoid unexpected test results
115 #
116 svcadm disable iscsi/target
117
118 #
119 # Construct block and raw devices
120 #
121 BLKDEVS=
122 RAWDEVS=
123 for d in $DISKS; do
124 BLKDEVS="$BLKDEVS/dev/dsk/$d "
125 RAWDEVS="$RAWDEVS/dev/rdsk/$d "
126 done
127
128 #
129 # Configure
130 #
131 # fc target host topology in fabric switch is a must
132 # QLOGIC and BROCADE fabric switches are supported
133 #
134 run_test -v FC_IHOST=$INITIATOR \
135 -v "BDEVS=\"$BLKDEVS\"" \
136 -v "RDEVS=\"$RAWDEVS\"" \
137 -v FC_TARGET_SWITCH_PORT=$FC_SW \
138 comstar-tests fc_configure
139
140 #
141 # To run the entire test suite
142 #
143 run_test comstar-tests fc
144
145 #
146 # To run individual scenarios (itadm iscsi_auth iscsi_discovery...etc)
147 #
148 # run_test comstar-tests fc/visible:1
149 # run_test comstar-tests fc/visible:1-2
150
151 #
152 # Unconfigure
153 #
154 run_test comstar-tests fc_unconfigure