1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
|
# BEGIN_ICS_COPYRIGHT8 ****************************************
#
# Copyright (c) 2015, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Intel Corporation nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# END_ICS_COPYRIGHT8 ****************************************
# [ICS VERSION STRING: unknown]
# This is an expect (tcl) library of procedures to aid install testing
## tcl procedures to support testing of install:
## =============================================
proc install_cleanup { } {
##
## install_cleanup
## -------------------
## cleanup temp files and logs in preparation for a new install scenario
## during an rlogin session
##
## Usage:
## install_cleanup
## Additional Information:
## Must have run target_rlogin and target_su before this
## Returns:
## 0 - success
## -code error on failure
unix_cmd 60 0 "rm -f /var/log/ics_ib.log"
unix_cmd 60 0 "rm -f /var/log/opa.log"
unix_cmd 60 0 "rm -f /var/log/opamon"
unix_cmd 200 0 "rm -rf IntelOPA-Basic.*"
unix_cmd 200 0 "rm -rf IntelOPA-IFS.*"
unix_cmd 200 0 "rm -rf IntelOPA-Tools*"
unix_cmd 200 0 "rm -rf IntelOPA-Tests.*"
unix_cmd 60 0 "rm -rf /tmp/opa.log.len /tmp/ics_ib.log.len"
return 0
}
proc install_saveloglen { } {
##
## install_saveloglen
## -------------------
## save log length for use to verify install results
##
## Usage:
## install_saveloglen
## Additional Information:
## Must have run target_rlogin and target_su before this
## Returns:
## 0 - success
## -code error on failure
foreach log {/var/log/opa.log /var/log/ics_ib.log} {
set log_len "/tmp/[exec basename $log].len"
# use sed to get rid of white space
unix_cmd 60 0 "cat $log 2>/dev/null|wc -l | sed -e 's/\[ \\t]//g' > $log_len"
}
return 0
}
proc install_rmloglen { } {
##
## install_rmloglen
## -------------------
## remove log length files created by install_saveloglen
##
## Usage:
## install_rmloglen
## Additional Information:
## Must have run target_rlogin and target_su before this
## Returns:
## 0 - success
## -code error on failure
unix_cmd 60 0 "rm -f /tmp/opa.log.len"
unix_cmd 60 0 "rm -f /tmp/ics_ib.log.len"
return 0
}
proc install_expect_drivers { driver_list { skip_done 0 }} {
##
## install_expect_drivers
## ----------------------
## Check the proper drivers are loaded during an rlogin session
##
## Usage:
## install_expect_drivers driver_list [skip_done]
## Arguments:
## driver_list - list of drivers/ULP names
## skip_done - skip wait for 'Done Installing IB' message
## 0=wait for message
## 1=don't wait for message, default is 0
## Returns:
## 0 - success
## -code error on failure
## Additional Information:
## Does not care what order the drivers are loaded in
expect_progress 600 { "Preparing" "Building" } { "Installing" {OPA Software} } {
"Unable"
"Error"
"Failure"
"invalid"
"Usage"
}
set list {}
foreach driver $driver_list {
lappend list "Installing $driver"
}
if { "$list" != "" } {
# allow 5 minutes per Driver
expect_progress_orderless 300 { "Preparing" "Building" "installing" "Updating" "Copying" } 0 $list {
"Unable"
"Error"
"Failure"
"invalid"
}
}
if { ! $skip_done } {
# "Unable" message could occur if A0 HCA being installed
# allow some extra time for depmod and firmware update
# firmware update can be slow on MAC or if pciconf1 device is used
expect_progress 300 { {[0-9]} "---" "Updating" "Copying" "installing" } { {Done Installing OPA} } {
"Error"
"Failure"
"invalid"
}
}
return 0
}
proc install_uninstall { {uninstall 1} {remove_config 0} { dir "" } } {
##
## install_uninstall
## -----------------
## uninstall any existing version of IB software on the system during an rlogin session
##
## Usage:
## install_uninstall [ uninstall [remove_config [dir]] ]
## Arguments:
## uninstall - should existing installation be uninstalled, default is yes
## remove_config - should existing config files be removed, default is no
## dir - directory to find uninstall in (default is to only use
## opaconfig/ics_ib)
## Returns:
## 0 - success
## -code error on failure
set toolsdir /usr/lib/opa/tools
if { $uninstall } {
# use ics_ib to remove if possible
unix_cmd 240 "" {if [ -f /sbin/opaconfig ]; then /sbin/opaconfig -u; elif [ -f /sbin/ics_ib ]; then /sbin/ics_ib -u; fi }
}
if { $uninstall && "$dir" != "" } {
unix_cmd 240 "" "test -d $dir && (cd $dir; ./INSTALL -u )"
}
if { $remove_config } {
set target_os_type [target_get_os_type]
unix_cmd 60 "" {rm -rf /etc/opa /etc/sysconfig/ipoib.cfg /etc/sysconfig/ics_srp.cfg /etc/sysconfig/ics_inic.cfg /etc/sysconfig/mpi.param /etc/sysconfig/mpi.param.safe /etc/sysconfig/mpi.param.microbench $toolsdir/opafastfabric.conf /etc/dat.conf}
unix_cmd 60 "" {rm -rf /etc/opa-fm/opafm.xml /etc/infiniband/openib.conf /etc/opamon.conf}
unix_cmd 60 "" {rm -rf /etc/sysconfig/network-scripts/ifcfg-eioc[0-9]* /etc/sysconfig/network-scripts/ifcfg-ib[0-9]*}
unix_cmd 60 "" {rm -rf /etc/sysconfig/network/ifcfg-eioc[0-9]* /etc/sysconfig/network/ifcfg-ib[0-9]*}
unix_cmd 60 "" {rm -rf /etc/dapl}
}
return 0
}
proc install_getready { target {uninstall 1} { remove_config 0 } { cleanup 1 } { dir "" }} {
##
## install_getready
## ----------------
## prepare for an install test by login'ing
## cleaning up from any prior install, uninstalling any prior software
##
## Usage:
## install_getready target [uninstall [remove_config [cleanup [dir] ]]]
##
## Arguments:
## target - hostname to rlogin to
## uninstall - should existing installation be uninstalled, default is yes
## remove_config - should existing config files be removed, default is no
## cleanup - should existing installation files and install logs be removed, default is yes
## dir - directory to find uninstall in (default is to only use
## opaconfig/ics_ib)
## Returns:
## 0 - success
## -code error om failure
## Additional Information:
## setup file is sent to /tmp/mysetup.stp
global env
# become root user on target system
target_root_sh $target
install_uninstall $uninstall $remove_config $dir
if { $cleanup } {
install_cleanup
} else {
install_saveloglen
}
return 0
}
proc install_all { target drivers {uninstall 1} {remove_config 0 } {cleanup 1} {cd_device ""} {release ""} { install_opt "-a" } { from_dir "." } {product "IntelOPA-Basic"}} {
##
## install_all
## -----------------
## perform a basic installation of all drivers
##
## Usage:
## install_all target drivers [uninstall [remove_config [cleanup [cd_device [release [install_opt [from_dir]]]]]]]
## Arguments:
## target - hostname to rlogin to
## drivers - list of driver names expected to be installed
## uninstall - should existing installation be uninstalled, default is yes
## remove_config - should existing config files be removed, default is no
## cleanup - should existing installation files and install logs be removed, default is yes
## cd_device - CD device to load from, default is ftp from get_ftp_dir
## release - if ! "", scp $product.$release.tgz to target and install
## install_opt - install options, default is "-a"
## from_dir - where to get $product.*.tgz for scp install
## Returns:
## 0 - success
## -code error on failure
## Additional Information:
## This establishes and closes an rlogin session
global env
if { "$cd_device" == "" && "$release" == "" } {
# will untar below into this directory
set dir [get_install_dir "$product"]
} elseif { "$cd_device" != "" } {
set dir $cd_device
} else {
log_message "scp $from_dir/$product.$release.tgz root@\[$target\]:"
if { [ catch { exec scp $from_dir/$product.$release.tgz root@\[$target\]: } err_str2 ] != 0 } {
error "scp $from_dir/$product.$release.tgz root@\[$target\]: failed: $err_str2"
}
set dir $product.$release
# can't cleanup, will remove the file we just copied
set cleanup 0
}
install_getready $target $uninstall $remove_config $cleanup $dir
if { "$cd_device" == "" && "$release" == "" } {
if { ! [ info exists env(CFG_FTP_SERVER) ]
|| "$env(CFG_FTP_SERVER)" == ""} {
fail_test "Release version not specified"
}
# Fast Fabric always sets release and sets CFG_FTP_SERVER=""
# hence for fast fabric we never use ftp
set release [get_release]
scp_get_file "$env(CFG_SCP_SERVER)" "$env(CFG_SCP_USERID)" "[get_ftp_dir $target]/$product.$release.tgz" "$product.$release.tgz"
send_unix_cmd "tar xvfz $product.$release.tgz; echo DONE"
expect_progress 120 { "doc" "include" "config" "bin" "lib" } { "echo DONE" "DONE" } { "Error " "No such" }
check_exit_status 360 0
} elseif { "$cd_device" == "" && "$release" != "" } {
unix_cmd 200 0 "rm -rf $product.$release"
send_unix_cmd "tar xvfz $product.$release.tgz; echo DONE"
expect_progress 120 { "doc" "include" "config" "bin" "lib" } { "echo DONE" "DONE" } { "Error " "No such" }
check_exit_status 360 0
}
unix_cmd 60 0 "cd $dir"
send_unix_cmd "./INSTALL $install_opt"
set_timeout 60
install_expect_drivers "$drivers"
check_exit_status 60 0
install_check_logs
install_rmloglen
child_cleanup
return 0
}
proc install_check_logs { { log_list { /var/log/ics_ib.log /var/log/opa.log } } { retcode "1" } } {
##
## install_check_logs
## -----------------
## check there are no errors or warnings in the installation log
## during an rlogin session
##
## Usage:
## install_check_logs [log_list] [retcode]
## Arguments:
## log_list - list of log filenames to get, default is opa.log ics_ib.log
## retcode - expected return code from egrep, 0=errors/warnings in log
## 1=no errors/warnings in log, defaults to 1
## Returns:
## 0 - success
## -code error on failure
foreach log $log_list {
send_unix_cmd "\[ -f $log \];"
if { [ get_exit_status 60 ] == 0 } {
set log_len "/tmp/[exec basename $log].len"
send_unix_cmd "\[ -s $log_len \];"
if { [ get_exit_status 60 ] == 0 } {
# allow Unable due to message for A0 HCA
unix_cmd 60 $retcode "tail -n +`cat $log_len` $log|egrep 'Abort|corrupted|Can not'"
} else {
unix_cmd 60 $retcode "egrep 'Abort|corrupted|Can not' $log"
}
}
}
return 0
}
proc install_getready2 { target } {
##
## install_getready2
## ----------------
## prepare for an install test by login'ing
## cleaning up from any prior install
##
## Usage:
## install_getready2 target
##
## Arguments:
## target - hostname to rlogin to
## Returns:
## 0 - success
## -code error om failure
# become root user on target system
target_root_sh $target $usercode $password $root_password
install_cleanup
return 0
}
proc install_get_logs { target { log_list { ics_ib.log opa.log } } { log_dir /var/log } } {
##
## install_get_logs
## ------------------------
## Get the various installation log file
##
## Usage:
## install_get_logs target [log_list] [log_dir]
## Arguments:
## target - hostname to rlogin to
## log_list - list of log filenames to get, default is opa.log ics_ib.log
## log_dir - directory to get log files from, default is /var/log
## Additional Information:
## The login session to the target system is terminated to allow an
## ftp to occur to transfer the file
## This is intended for use as a failure_code handler for test cases
## Errors in getting the log files are ignored (in case the logs don't
## exist)
## The log files gotten are of the form:
## $log_dir/$log
## where $log is an individual entry in log_list
## They are transfered to:
## $test_tmp/$log
global env
global test_tmp
# ignore errors in case the log doesn't exist
foreach log $log_list {
# cleanup any previous sessions
catch { child_cleanup }
#catch { ftp_mget_files $target $env(CFG_USERNAME) $env(CFG_PASSWORD) $log_dir $log $test_tmp ascii }
catch { exec scp root@\[$target\]:$log_dir/$log $test_tmp/ }
}
# cleanup any previous sessions
catch { child_cleanup }
}
|