2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-07-01 10:25:33 +00:00

Test cases for nodeset error handling (#4114)

* Test cases for nodeset
This commit is contained in:
Gᴏɴɢ Jie
2017-10-26 04:28:28 -05:00
committed by Bin Xu
parent 2353abb48a
commit 155ba82a13
11 changed files with 716 additions and 0 deletions

View File

@ -0,0 +1,54 @@
start:nodeset_shell_grub2
description: Verify if `nodeset shell` perform well when part of nodes in a node range have problem. Use grub2 OS loader
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/nodeset/nodeset_shell_grub2
check:rc==0
end
start:nodeset_shell_petitboot
description: Verify if `nodeset shell` perform well when part of nodes in a node range have problem. Use petitboot OS loader
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/nodeset/nodeset_shell_petitboot
check:rc==0
end
start:nodeset_shell_xnba
description: Verify if `nodeset shell` perform well when part of nodes in a node range have problem. Use xnba OS loader
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/nodeset/nodeset_shell_xnba
check:rc==0
end
start:nodeset_osimage_grub2
description: Verify if `nodeset osimage` perform well when part of nodes in a node range have problem. Use grub2 OS loader
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/nodeset/nodeset_osimage_grub2
check:rc==0
end
start:nodeset_osimage_petitboot
description: Verify if `nodeset osimage` perform well when part of nodes in a node range have problem. Use petitboot OS loader
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/nodeset/nodeset_osimage_petitboot
check:rc==0
end
start:nodeset_osimage_xnba
description: Verify if `nodeset osimage` perform well when part of nodes in a node range have problem. Use xnba OS loader
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/nodeset/nodeset_osimage_xnba
check:rc==0
end
start:nodeset_nonexistent_osimage_grub2
description: Verify if `nodeset osimage` perform well when part of nodes in a node range have nonexistent osimage defined in its profile. Use grub2 OS loader
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/nodeset/nodeset_nonexistent_osimage_grub2
check:rc==0
end
start:nodeset_nonexistent_osimage_petitboot
description: Verify if `nodeset osimage` perform well when part of nodes in a node range have nonexistent osimage defined in its profile. Use petitboot OS loader
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/nodeset/nodeset_nonexistent_osimage_petitboot
check:rc==0
end
start:nodeset_nonexistent_osimage_xnba
description: Verify if `nodeset osimage` perform well when part of nodes in a node range have nonexistent osimage defined in its profile. Use xnba OS loader
cmd:/opt/xcat/share/xcat/tools/autotest/testcase/nodeset/nodeset_nonexistent_osimage_xnba
check:rc==0
end

View File

@ -0,0 +1,195 @@
#!/bin/bash
#
# warn_if_bad Put out warning message(s) if $1 has bad RC.
#
# $1 0 (pass) or non-zero (fail).
# $2+ Remaining arguments printed only if the $1 is non-zero.
#
# Incoming $1 is returned unless it is 0
#
function warn_if_bad()
{
local -i rc="$1"
local script="${0##*/}"
# Ignore if no problems
[ "${rc}" -eq "0" ] && return 0
# Broken
shift
echo "${script}: $@" >&2
return "${rc}"
}
#
# exit_if_bad Put out error message(s) if $1 has bad RC.
#
# $1 0 (pass) or non-zero (fail).
# $2+ Remaining arguments printed only if the $1 is non-zero.
#
# Exits with 1 unless $1 is 0
#
function exit_if_bad()
{
warn_if_bad "$@" || exit 1
return 0
}
#
# internal_setup Script setup
#
# Returns 0 on success.
# Exits (not returns) with 1 on failure.
#
function internal_setup()
{
shopt -s extglob
# Trap exit for internal_cleanup function.
trap "internal_cleanup" EXIT
umask 0077
TMP_DIR="$(mktemp -d "/tmp/${0##*/}.XXXXXXXX" 2>/dev/null)"
[ -d "${TMP_DIR}" ]
exit_if_bad "$?" "Make temporary directory failed."
custom_setup
}
#
# internal_cleanup Script cleanup (reached via trap 0)
#
# Destory any temporarily facility created by internal_setup.
#
function internal_cleanup()
{
custom_cleanup
[ -d "${TMP_DIR}" ] && rm -rf "${TMP_DIR}"
}
#
# custom_setup
#
function custom_setup()
{
:
}
#
# custom_cleanup
#
function custom_cleanup()
{
:
}
internal_setup
function make_bogus_grub2_nodes()
{
local i
# grub2
for i in {001..005}
do
mkdef -t node -o tz${i} \
arch=ppc64 cons=hmc groups=lpar mgt=hmc \
netboot=grub2 \
ip=10.99.1.$((10#${i})) \
mac=e6:d4:d2:3a:ad:0$((10#${i})) \
profile=compute os=rhels7.99
done
}
function make_bogus_petitboot_nodes()
{
local i
# petitboot
for i in {001..005}
do
mkdef -t node -o tz${i} \
arch=ppc64le cons=bmc groups=ipmi mgt=ipmi \
netboot=petitboot \
ip=10.99.1.$((10#${i})) \
mac=e6:d4:d2:3a:ad:0$((10#${i})) \
profile=compute os=rhels7.99
done
}
function make_bogus_xnba_nodes()
{
local i
# xnba
for i in {001..005}
do
mkdef -t node -o tz${i} \
arch=x86_64 cons=kvm groups=kvm mgt=kvm \
netboot=xnba \
ip=10.99.1.$((10#${i})) \
mac=e6:d4:d2:3a:ad:0$((10#${i})) \
profile=compute os=rhels7.99
done
}
function destory_bogus_nodes()
{
rmdef -t node tz001+4
}
umask 0022
function make_bogus_ppc64le_osimage()
{
mkdef "rhels7.99-ppc64le-install-compute" \
-u profile=compute provmethod=install \
osvers=rhels7.99 osarch=ppc64le
mkdir -p /install/rhels7.99/ppc64le/ppc/ppc64le
echo blah >/install/rhels7.99/ppc64le/ppc/ppc64le/vmlinuz
echo blah >/install/rhels7.99/ppc64le/ppc/ppc64le/initrd.img
}
function make_bogus_ppc64_osimage()
{
mkdef "rhels7.99-ppc64-install-compute" \
-u profile=compute provmethod=install \
osvers=rhels7.99 osarch=ppc64
mkdir -p /install/rhels7.99/ppc64/ppc/ppc64
echo blah >/install/rhels7.99/ppc64/ppc/ppc64/vmlinuz
echo blah >/install/rhels7.99/ppc64/ppc/ppc64/initrd.img
}
#function make_bogus_ppc64_osimage()
#{
# mkdef "rhels6.99-ppc64-install-compute" \
# -u profile=compute provmethod=install \
# osvers=rhels6.99 osarch=ppc64
# mkdir -p /install/rhels6.99/ppc64/ppc/{chrp,ppc64}
# echo blah >/install/rhels6.99/ppc64/ppc/ppc64/vmlinuz
# echo blah >/install/rhels6.99/ppc64/ppc/ppc64/initrd.img
# echo blah >/install/rhels6.99/ppc64/ppc/chrp/yaboot
#}
function make_bogus_x64_osimage()
{
mkdef "rhels6.99-x86_64-install-compute" \
-u profile=compute provmethod=install \
osvers=rhels6.99 osarch=x86_64
mkdir -p /install/rhels6.99/x86_64/images/pxeboot
echo blah >/install/rhels6.99/x86_64/images/pxeboot/vmlinuz
echo blah >/install/rhels6.99/x86_64/images/pxeboot/initrd.img
}
function destory_bogus_osimages()
{
local o
for o in \
rhels7.99-ppc64le-install-compute \
rhels7.99-ppc64-install-compute \
rhels6.99-ppc64-install-compute \
rhels6.99-x86_64-install-compute
do
rmdef -t osimage ${o}
done
}

View File

@ -0,0 +1,60 @@
#!/bin/bash
BASE_DIR="${0%/*}"
! source "${BASE_DIR}/functions.sh" >/dev/null 2>&1 &&
echo "File \"${BASE_DIR}/functions.sh\" not found" >&2 && exit 1
make_bogus_ppc64_osimage
make_bogus_grub2_nodes
function custom_cleanup()
{
destory_bogus_nodes
destory_bogus_osimages
}
NODESET_STDOUT="${TMP_DIR}/nodeset.out"
NODESET_STDERR="${TMP_DIR}/nodeset.err"
nodeset tz001+4 osimage=rhels7.99-ppc64-install-compute
exit_if_bad "$?" "nodeset command exit with non-zero"
# Make sure all other nodes are good
for node in tz{001..005}
do
[ -f "/tftpboot/boot/grub2/${node}" ]
exit_if_bad "$?" "file not found /tftpboot/boot/grub2/${node}"
done
nodeset tz003 osimage=nonexistent-osimage \
> >(tee "${NODESET_STDOUT}") 2> >(tee "${NODESET_STDERR}")
[ "$?" -ne "0" ]
exit_if_bad "$?" "nodeset command should exit with non-zero"
grep 'annot find the OS image' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
nodeset tz001+4 offline
chdef tz003 provmethod=nonexistent-osimage
exit_if_bad "$?" "chdef command exit with non-zero"
nodeset tz001+4 osimage \
> >(tee "${NODESET_STDOUT}") 2> >(tee "${NODESET_STDERR}")
[ "$?" -ne "0" ]
exit_if_bad "$?" "nodeset command should exit with non-zero"
grep 'tz003: .*annot find the OS image' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
# Make sure all other nodes are good
for node in tz001 tz002 tz004 tz005
do
[ -f "/tftpboot/boot/grub2/${node}" ]
exit_if_bad "$?" "file not found /tftpboot/boot/grub2/${node}"
done
nodeset tz001+4 offline
exit 0

View File

@ -0,0 +1,70 @@
#!/bin/bash
BASE_DIR="${0%/*}"
! source "${BASE_DIR}/functions.sh" >/dev/null 2>&1 &&
echo "File \"${BASE_DIR}/functions.sh\" not found" >&2 && exit 1
make_bogus_ppc64le_osimage
make_bogus_petitboot_nodes
function custom_cleanup()
{
destory_bogus_nodes
destory_bogus_osimages
}
NODESET_STDOUT="${TMP_DIR}/nodeset.out"
NODESET_STDERR="${TMP_DIR}/nodeset.err"
nodeset tz001+4 osimage=rhels7.99-ppc64le-install-compute
exit_if_bad "$?" "nodeset command exit with non-zero"
# Make sure all nodes are good
for node in tz{001..005}
do
[ -f "/tftpboot/petitboot/${node}" ]
exit_if_bad "$?" "file not found /tftpboot/petitboot/${node}"
done
nodeset tz003 osimage=nonexistent-osimage \
> >(tee "${NODESET_STDOUT}") 2> >(tee "${NODESET_STDERR}")
[ "$?" -ne "0" ]
exit_if_bad "$?" "nodeset command should exit with non-zero"
grep 'annot find the OS image' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
nodeset tz001+4 offline
chdef tz003 provmethod=nonexistent-osimage
exit_if_bad "$?" "chdef command exit with non-zero"
nodeset tz001+4 osimage \
> >(tee "${NODESET_STDOUT}") 2> >(tee "${NODESET_STDERR}")
[ "$?" -ne "0" ]
exit_if_bad "$?" "nodeset command should exit with non-zero"
grep 'tz003: .*annot find the OS image' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
nodeset tz001+4 offline
chdef tz003 provmethod=nonexistent-osimage
exit_if_bad "$?" "chdef command exit with non-zero"
nodeset tz001+4 osimage \
> >(tee "${NODESET_STDOUT}") 2> >(tee "${NODESET_STDERR}")
[ "$?" -ne "0" ]
exit_if_bad "$?" "nodeset command should exit with non-zero"
# Make sure all other nodes are good
for node in tz001 tz002 tz004 tz005
do
[ -f "/tftpboot/petitboot/${node}" ]
exit_if_bad "$?" "file not found /tftpboot/petitboot/${node}"
done
nodeset tz001+4 offline
exit 0

View File

@ -0,0 +1,60 @@
#!/bin/bash
BASE_DIR="${0%/*}"
! source "${BASE_DIR}/functions.sh" >/dev/null 2>&1 &&
echo "File \"${BASE_DIR}/functions.sh\" not found" >&2 && exit 1
make_bogus_x64_osimage
make_bogus_xnba_nodes
function custom_cleanup()
{
destory_bogus_nodes
destory_bogus_osimages
}
NODESET_STDOUT="${TMP_DIR}/nodeset.out"
NODESET_STDERR="${TMP_DIR}/nodeset.err"
nodeset tz001+4 osimage=rhels6.99-x86_64-install-compute
exit_if_bad "$?" "nodeset command exit with non-zero"
# Make sure all nodes are good
for node in tz{001..005}
do
[ -f "/tftpboot/xcat/xnba/nodes/${node}" ]
exit_if_bad "$?" "file not found /tftpboot/xcat/xnba/nodes/${node}"
done
nodeset tz003 osimage=nonexistent-osimage \
> >(tee "${NODESET_STDOUT}") 2> >(tee "${NODESET_STDERR}")
[ "$?" -ne "0" ]
exit_if_bad "$?" "nodeset command should exit with non-zero"
grep 'annot find the OS image' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
nodeset tz001+4 offline
chdef tz003 provmethod=nonexistent-osimage
exit_if_bad "$?" "chdef command exit with non-zero"
nodeset tz001+4 osimage \
> >(tee "${NODESET_STDOUT}") 2> >(tee "${NODESET_STDERR}")
[ "$?" -ne "0" ]
exit_if_bad "$?" "nodeset command should exit with non-zero"
grep 'tz003: .*annot find the OS image' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
# Make sure all other nodes are good
for node in tz001 tz002 tz004 tz005
do
[ -f "/tftpboot/xcat/xnba/nodes/${node}" ]
exit_if_bad "$?" "file not found /tftpboot/xcat/xnba/nodes/${node}"
done
nodeset tz001+4 offline
exit 0

View File

@ -0,0 +1,44 @@
#!/bin/bash
BASE_DIR="${0%/*}"
! source "${BASE_DIR}/functions.sh" >/dev/null 2>&1 &&
echo "File \"${BASE_DIR}/functions.sh\" not found" >&2 && exit 1
make_bogus_ppc64_osimage
make_bogus_grub2_nodes
function custom_cleanup()
{
destory_bogus_nodes
destory_bogus_osimages
}
chdef tz002 mac=
chdef tz003 arch=
NODESET_STDOUT="${TMP_DIR}/nodeset.out"
NODESET_STDERR="${TMP_DIR}/nodeset.err"
nodeset tz001+4 osimage=rhels7.99-ppc64-install-compute \
> >(tee "${NODESET_STDOUT}") 2> >(tee "${NODESET_STDERR}")
# Check $? != 0
[ "$?" -ne "0" ]
exit_if_bad "$?" "nodeset command should exit with non-zero"
grep 'tz002: .*o MAC address' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
#grep 'tz003: .*o archictecture defined' "${NODESET_STDERR}"
#exit_if_bad "$?" "nodeset command error message checking failed"
# Make sure all other nodes are good
for node in tz001 tz004 tz005
do
[ -f "/tftpboot/boot/grub2/${node}" ]
exit_if_bad "$?" "file not found /tftpboot/boot/grub2/${node}"
done
nodeset tz001+4 offline
exit 0

View File

@ -0,0 +1,51 @@
#!/bin/bash
BASE_DIR="${0%/*}"
! source "${BASE_DIR}/functions.sh" >/dev/null 2>&1 &&
echo "File \"${BASE_DIR}/functions.sh\" not found" >&2 && exit 1
make_bogus_ppc64le_osimage
make_bogus_petitboot_nodes
function custom_cleanup()
{
destory_bogus_nodes
destory_bogus_osimages
}
chdef tz001+4 serialport=0 serialspeed=115200
exit_if_bad "$?" "chdef command failed"
chdef tz002 mac=
chdef tz003 arch=
chdef tz004 serialspeed=
NODESET_STDOUT="${TMP_DIR}/nodeset.out"
NODESET_STDERR="${TMP_DIR}/nodeset.err"
nodeset tz001+4 osimage=rhels7.99-ppc64le-install-compute \
> >(tee "${NODESET_STDOUT}") 2> >(tee "${NODESET_STDERR}")
# Check $? != 0
[ "$?" -ne "0" ]
exit_if_bad "$?" "nodeset command should exit with non-zero"
grep 'tz002: .*o MAC address' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
#grep 'tz003: .*o archictecture defined' "${NODESET_STDERR}"
#exit_if_bad "$?" "nodeset command error message checking failed"
grep 'tz004: .*o serialspeed' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
# Make sure all other nodes are good
for node in tz001 tz005
do
[ -f "/tftpboot/petitboot/${node}" ]
exit_if_bad "$?" "file not found /tftpboot/petitboot/${node}"
done
nodeset tz001+4 offline
exit 0

View File

@ -0,0 +1,51 @@
#!/bin/bash
BASE_DIR="${0%/*}"
! source "${BASE_DIR}/functions.sh" >/dev/null 2>&1 &&
echo "File \"${BASE_DIR}/functions.sh\" not found" >&2 && exit 1
make_bogus_x64_osimage
make_bogus_xnba_nodes
function custom_cleanup()
{
destory_bogus_nodes
destory_bogus_osimages
}
chdef tz001+4 serialport=0 serialspeed=115200
exit_if_bad "$?" "chdef command failed"
chdef tz002 mac=
chdef tz003 arch=
chdef tz004 serialspeed=
NODESET_STDOUT="${TMP_DIR}/nodeset.out"
NODESET_STDERR="${TMP_DIR}/nodeset.err"
nodeset tz001+4 osimage=rhels6.99-x86_64-install-compute \
> >(tee "${NODESET_STDOUT}") 2> >(tee "${NODESET_STDERR}")
# Check $? != 0
[ "$?" -ne "0" ]
exit_if_bad "$?" "nodeset command should exit with non-zero"
grep 'tz002: .*o MAC address' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
#grep 'tz003: .*o archictecture defined' "${NODESET_STDERR}"
#exit_if_bad "$?" "nodeset command error message checking failed"
grep 'tz004: .*o serialspeed' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
# Make sure all other nodes are good
for node in tz001 tz005
do
[ -f "/tftpboot/xcat/xnba/nodes/${node}" ]
exit_if_bad "$?" "file not found /tftpboot/xcat/xnba/nodes/${node}"
done
nodeset tz001+4 offline
exit 0

View File

@ -0,0 +1,39 @@
#!/bin/bash
BASE_DIR="${0%/*}"
! source "${BASE_DIR}/functions.sh" >/dev/null 2>&1 &&
echo "File \"${BASE_DIR}/functions.sh\" not found" >&2 && exit 1
make_bogus_ppc64_osimage
make_bogus_grub2_nodes
function custom_cleanup()
{
destory_bogus_nodes
destory_bogus_osimages
}
chdef tz003 arch=
NODESET_STDOUT="${TMP_DIR}/nodeset.out"
NODESET_STDERR="${TMP_DIR}/nodeset.err"
nodeset tz001+4 shell > >(tee "${NODESET_STDOUT}") 2> >(tee "${NODESET_STDERR}")
# Check $? != 0
[ "$?" -ne "0" ]
exit_if_bad "$?" "nodeset command should exit with non-zero"
grep 'tz003: .*o archictecture defined' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
# Make sure all other nodes are good
for node in tz001 tz002 tz004 tz005
do
[ -f "/tftpboot/boot/grub2/${node}" ]
exit_if_bad "$?" "file not found /tftpboot/boot/grub2/${node}"
done
nodeset tz001+4 offline
exit 0

View File

@ -0,0 +1,46 @@
#!/bin/bash
BASE_DIR="${0%/*}"
! source "${BASE_DIR}/functions.sh" >/dev/null 2>&1 &&
echo "File \"${BASE_DIR}/functions.sh\" not found" >&2 && exit 1
make_bogus_ppc64le_osimage
make_bogus_petitboot_nodes
function custom_cleanup()
{
destory_bogus_nodes
destory_bogus_osimages
}
chdef tz001+4 serialport=0 serialspeed=115200
exit_if_bad "$?" "chdef command failed"
chdef tz003 arch=
chdef tz004 serialspeed=
NODESET_STDOUT="${TMP_DIR}/nodeset.out"
NODESET_STDERR="${TMP_DIR}/nodeset.err"
nodeset tz001+4 shell > >(tee "${NODESET_STDOUT}") 2> >(tee "${NODESET_STDERR}")
# Check $? != 0
[ "$?" -ne "0" ]
exit_if_bad "$?" "nodeset command should exit with non-zero"
grep 'tz003: .*o archictecture defined' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
grep 'tz004: .*o serialspeed' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
# Make sure all other nodes are good
for node in tz001 tz002 tz005
do
[ -f "/tftpboot/petitboot/${node}" ]
exit_if_bad "$?" "file not found /tftpboot/petitboot/${node}"
done
nodeset tz001+4 offline
exit 0

View File

@ -0,0 +1,46 @@
#!/bin/bash
BASE_DIR="${0%/*}"
! source "${BASE_DIR}/functions.sh" >/dev/null 2>&1 &&
echo "File \"${BASE_DIR}/functions.sh\" not found" >&2 && exit 1
make_bogus_x64_osimage
make_bogus_xnba_nodes
function custom_cleanup()
{
destory_bogus_nodes
destory_bogus_osimages
}
chdef tz001+4 serialport=0 serialspeed=115200
exit_if_bad "$?" "chdef command failed"
chdef tz003 arch=
chdef tz004 serialspeed=
NODESET_STDOUT="${TMP_DIR}/nodeset.out"
NODESET_STDERR="${TMP_DIR}/nodeset.err"
nodeset tz001+4 shell > >(tee "${NODESET_STDOUT}") 2> >(tee "${NODESET_STDERR}")
# Check $? != 0
[ "$?" -ne "0" ]
exit_if_bad "$?" "nodeset command should exit with non-zero"
grep 'tz003: .*o archictecture defined' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
grep 'tz004: .*o serialspeed' "${NODESET_STDERR}"
exit_if_bad "$?" "nodeset command error message checking failed"
# Make sure all other nodes are good
for node in tz001 tz002 tz005
do
[ -f "/tftpboot/xcat/xnba/nodes/${node}" ]
exit_if_bad "$?" "file not found /tftpboot/xcat/xnba/nodes/${node}"
done
nodeset tz001+4 offline
exit 0