Blame TestTools/ib.exp

Packit 857059
# BEGIN_ICS_COPYRIGHT8 ****************************************
Packit 857059
# 
Packit 857059
# Copyright (c) 2015, Intel Corporation
Packit 857059
# 
Packit 857059
# Redistribution and use in source and binary forms, with or without
Packit 857059
# modification, are permitted provided that the following conditions are met:
Packit 857059
# 
Packit 857059
#     * Redistributions of source code must retain the above copyright notice,
Packit 857059
#       this list of conditions and the following disclaimer.
Packit 857059
#     * Redistributions in binary form must reproduce the above copyright
Packit 857059
#       notice, this list of conditions and the following disclaimer in the
Packit 857059
#       documentation and/or other materials provided with the distribution.
Packit 857059
#     * Neither the name of Intel Corporation nor the names of its contributors
Packit 857059
#       may be used to endorse or promote products derived from this software
Packit 857059
#       without specific prior written permission.
Packit 857059
# 
Packit 857059
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit 857059
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 857059
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Packit 857059
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
Packit 857059
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 857059
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Packit 857059
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Packit 857059
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Packit 857059
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 857059
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 857059
# 
Packit 857059
# END_ICS_COPYRIGHT8   ****************************************
Packit 857059
Packit 857059
# [ICS VERSION STRING: unknown]
Packit 857059
Packit 857059
# This is an expect (tcl) library of procedures to aid ib testing
Packit 857059
Packit 857059
## tcl procedures to support testing:
Packit 857059
## =============================================
Packit 857059
Packit 857059
proc test_case_discovered_hosts { host hosts } {
Packit 857059
##
Packit 857059
## test_case_discovered_hosts
Packit 857059
## -------------------
Packit 857059
## execute a test case to determine if hosts can be seen from discovery on
Packit 857059
## given host
Packit 857059
##
Packit 857059
## Usage:
Packit 857059
##	test_case_discovered_hosts host hosts
Packit 857059
## Arguments:
Packit 857059
##	host - host to test
Packit 857059
##	hosts - list of hosts expected to be discovered
Packit 857059
## Returns:
Packit 857059
##	 0 - success
Packit 857059
##	 1 - failure
Packit 857059
## Additional Information:
Packit 857059
##	must be used within a test_suite's body, performs test_case calls
Packit 857059
##	uses case_setup and case_cleanup provided by caller
Packit 857059
##	no item_setup nor item_cleanup used
Packit 857059
	return [ test_case "$host.dsc" "$host can see $hosts" "Verify host can discover $hosts
Packit 857059
via /proc/driver/ics_dsc/gids
Packit 857059
File: TestTools/ib.exp" case_setup case_cleanup {
Packit 857059
		upvar host host
Packit 857059
		upvar hosts hosts
Packit 857059
Packit 857059
		target_root_sh $host
Packit 857059
Packit 857059
		set target_stack [ target_get_stack_type "y" "$host"]
Packit 857059
Packit 857059
		if { "$target_stack" == "OPENIB" } {
Packit 857059
			send_unix_cmd {type opasaquery}
Packit 857059
			if { 0 == [ get_exit_status 60 ] } {
Packit 857059
				#send_unix_cmd "opasaquery -h 0 -p 0 -t fi -o desc 2>&1 |tr 'A-Z' 'a-z' | sed -e 's/^/Node: /'"
Packit 857059
				send_unix_cmd {opasaquery -h 0 -p 0 -t fi -o desc 2>&1 |tr 'A-Z' 'a-z' | sed -e 's/^/Node: /'}
Packit 857059
			} else {
Packit 857059
				#send_unix_cmd {saquery |egrep '^[[:space:]]*NodeDescription\.*'|tr 'A-Z' 'a-z' | sed -e 's/^[[:space:]]*nodedescription\.*/Node: /'}
Packit 857059
				send_unix_cmd {opasaquery |egrep '^[[:space:]]*NodeDescription\.*'|tr 'A-Z' 'a-z' | sed -e 's/^[[:space:]]*nodedescription\.*/Node: /'}
Packit 857059
			}
Packit 857059
			# wait for echo of command so we don't mistake command for any
Packit 857059
			# similarly named hosts
Packit 857059
			expect_list 90 {"sed -e" "Node: /'"} {"not found" "unknown" "Error" "cannot" "usage:" "Usage:"}
Packit 857059
			set expected_host_list {}
Packit 857059
			# for each host we expect to see a line with $h
Packit 857059
			# To support OFED hosts, we need to handle names with HCA-# appended to them.
Packit 857059
			# Ensure that hostnames in the case insensitive manners are supported.
Packit 857059
			set hosts [ string tolower $hosts ]
Packit 857059
            
Packit 857059
			foreach h "$hosts" {
Packit 857059
				lappend expected_host_list "Node: $h\n|Node: $h hfi1_\[0-9\]+\n"
Packit 857059
			}
Packit 857059
			expect_list_orderless 60 0 "$expected_host_list" { "not found" "unknown" "Error" "cannot" "usage:" "Usage:"}
Packit 857059
			check_exit_status 60 0
Packit 857059
			target_root_sh_exit
Packit 857059
		}  else {
Packit 857059
			target_root_sh_exit
Packit 857059
			skip_case "This IB stack is not supported"
Packit 857059
		}
Packit 857059
Packit 857059
	} ]
Packit 857059
}
Packit 857059
Packit 857059
Packit 857059
proc test_case_verify_topology { host local_topology_file remote_topology_dir} {
Packit 857059
##
Packit 857059
## test_case_verify_topology
Packit 857059
## -------------------
Packit 857059
## execute a test case to determine if the topology of the cluster has changed
Packit 857059
##
Packit 857059
## See README file in dsc directory for more information
Packit 857059
##
Packit 857059
## Usage:
Packit 857059
##	test_case_verify_topology
Packit 857059
## Arguments:
Packit 857059
##	host - sm host
Packit 857059
##      local_topolgy_file - path and name of the saved topology file
Packit 857059
##      remote_topology_dir - where to scp file on the SM host
Packit 857059
## Returns:
Packit 857059
##	 0 - success, no change in topology
Packit 857059
##	 1 - failure, topology has changed
Packit 857059
## Additional Information:
Packit 857059
##	must be used within a test_suite's body, performs test_case calls
Packit 857059
##	uses case_setup and case_cleanup provided by caller
Packit 857059
##	no item_setup nor item_cleanup used
Packit 857059
	return [ test_case "verifytopology.dsc" "Verify topology of SM $host" "Verify topology of sm $host with $local_topology_file
Packit 857059
File: TestTools/ib.exp" case_setup case_cleanup {
Packit 857059
		upvar host host
Packit 857059
		upvar local_topology_file local_topology_file
Packit 857059
		upvar remote_topology_dir remote_topology_dir
Packit 857059
Packit 857059
                set path [split "$local_topology_file" /]
Packit 857059
                set topology_file_name [lindex $path [llength $path]-1]
Packit 857059
                set remote_topology_file [join "$remote_topology_dir $topology_file_name" "/"]      
Packit 857059
Packit 857059
                if { [file exists $local_topology_file] == 0 } {
Packit 857059
		    error "Error: topology file $local_topology_file could not be found"
Packit 857059
                } 
Packit 857059
Packit 857059
                if { [ catch { exec scp $local_topology_file root@$host:$remote_topology_dir } msg ] } {
Packit 857059
		    error "Failed to scp $local_topology_file to $host:$remote_topology_dir: $msg"
Packit 857059
		}
Packit 857059
Packit 857059
		target_root_sh $host
Packit 857059
Packit 857059
                send_unix_cmd "opareport -o verifynodes -T $remote_topology_file; echo DONE"            
Packit 857059
                expect_list 60 { "Getting" "DONE" } { "[1-9][0-9]* Missing" "[1-9][0-9]* Unexpected" "[1-9][0-9]* Duplicate" "[1-9][0-9]* Different" }
Packit 857059
                check_exit_status 60 0
Packit 857059
                send_unix_cmd "rm -f $remote_topology_file"
Packit 857059
Packit 857059
                target_root_sh_exit
Packit 857059
        } ]
Packit 857059
}