new files for xCAT test

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7514 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
ellen56 2010-09-20 08:10:57 +00:00
parent 218738339b
commit a05837bdca
44 changed files with 2479 additions and 0 deletions

27
maketestrpm Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
OSNAME=$(uname)
VER=`cat Version`
if [ "$OSNAME" = "AIX" ]
then
source=/opt/freeware/src/packages
echo '.svn' > /tmp/xcat-excludes
tar -X /tmp/xcat-excludes -cf $source/SOURCES/xCAT-test-$VER.tar xCAT-test
gzip -f $source/SOURCES/xCAT-test-$VER.tar
rm -f $source/SRPMS/xCAT-test*rpm $source/RPMS/ppc/xCAT-test*rpm
rpm -ba xCAT-test/xCAT-test.spec
#rpm -ta $source/SOURCES/xCAT-test-$VER.tar.gz
else
if [ -f /etc/redhat-release ]
then
pkg="redhat"
else
pkg="packages"
fi
set -x
tar --exclude=.svn -czhf /usr/src/$pkg/SOURCES/xCAT-test-$VER.tar.gz xCAT-test
rm -f /usr/src/$pkg/SRPMS/xCAT-test-$VER*rpm /usr/src/$pkg/RPMS/noarch/xCAT-test-$VER*rpm
rpmbuild -ta /usr/src/$pkg/SOURCES/xCAT-test-$VER.tar.gz
fi

View File

@ -0,0 +1,40 @@
#add rows to xCAT database table tablename
#[Table_tablename]
#key=value
[Table_passwd]
key=system
username=root
password=cluster
#add object definition to xCAT database
#[Object_objecttype]
#Name=object name
#Attribute=value
[Object_network]
Name=autotest_ent
net=192.168.10.0
mask=255.255.255.0
gateway=192.168.10.2
[Object_node]
Name=w1v3hmc05.ppd.pok.ibm.com
groups=all
nodetype=hmc
mgt=hmc
username=hscroot
password=abc123
[Object_node]
Name=lpar6
hcp=w1v3hmc05.ppd.pok.ibm.com
#script to run before test
[Script_Prev]
#scripts to run after test
[Script_Post]
#varible can be referenced in command and output check string in the test case by $$VARIABLE
#system VARIABLE,xCAT automated test predefined variable
[System]
CN=lpar6 #computenode name
SOURCE=/61L #the source used by mknimimage
SSHPKG=/tmp/xcat/ssh #put additional package and bundle here
MaxLparID=32 #Max LPAR ID on target CEC, used by cases for mkvm,chvm,lsvm,rmvm
#customerize VARIABLE, user can add variable for new cases here
[Custom]
#VARNAME=value

View File

@ -0,0 +1,114 @@
chdef_null
chdef_t_o_attr
chdef_p_t_o_attr
chdef_m_t_o_attr
chdef_z
chdef_t_o_attr_noderange
chdef_t_o_error
chtab_null
chtab_delete
chtab_modify
chvm_null
chvm_p
chvm_attr
chvm_node
chvm_err_node
copycds_iso
copycds_n
copycds_a
copycds_n_a
copycds_a_err
copycds_n_err
geninitrd_i_n_o_p
getmacs_noderange
getmacs_d
getmacs_f_D
gettab_key_table
lsdef_null
lsdef_a
lsdef_t_o_l
lsdef_t_o_l_z
lsdef_t
lsdef_t_i_o
lsdef_t_w
lsdef_t_err
lsvm_null
lsvm_node
lsvm_err_node
makeconservercf_null
makeconservercf_noderange
makeconservercf_d
makedhcp_n
makedhcp_a
makedhcp_a_d
makedhcp_d
mkdef_null
mkdef_t_o_attr
mkdef_f_t_o_attr
mkdef_z
mkdef_t_o_error
mkvm_i_l
nodeadd_noderange
nodeadd_err_symbol
nodech_noderange_table
nodech_noderange_table_comma
nodech_noderange_table_arrow
nodech_noderanage_table_at
nodech_delete
nodech_delete_error
nodech_error_node
nodech_error_table
nodels_null
nodels_H
nodels_noderange
nodels_err_symbol
nodels_err_noderange
noderm_noderange
nodeset_stat
nodeset_noderange
nodestat_noderange
nodestat_err_node
rinv_null
rinv_bus
rinv_config
rinv_serial
rinv_model
rinv_firm
rinv_all
rinv_noderange_err
rmdef_null
rmdef_t_o_attr
rmdef_f_all
rmdef_t_err
rmvm_noderange
rpower_off
rpower_stat
rpower_boot
rpower_on
rpower_reset
rpower_noderange
rpower_noderange_nodeps
rpower_err_noderange
rscan_noderange
rscan_x
rscan_z
rscan_w
rscan_x_w
rscan_z_w
rvitals_temp
rvitals_voltage
rvitals_power
rvitals_state
rvitals_lcds
rvitals_all
rvitals_noderange_err
sinv_c_p_t_r_o
sinv_c_s_p_t_o
tabdump_table
tabdump_d
tabgrep_node
tabrestore_table
xcatstart
xcatstop
xdcp_src_dst
xdcp_P

View File

@ -0,0 +1,81 @@
#Table configuration
[Table_passwd]
key=system
username=root
password=cluster
[Table_site]
key=nameservers
value=192.168.10.1
key=forwarders
value=9.114.1.1
key=domain
value=ppd.pok.ibm.com
[Object_network]
Name=autotest_ent
net=192.168.10.0
mask=255.255.255.0
gateway=192.168.10.3
#Object configuration
[Object_node]
Name=w1v3hmc05.ppd.pok.ibm.com
groups=hmc,all
nodetype=hmc
mgt=hmc
username=hscroot
password=abc123
[Object_node]
Name=Server-9117-MMA-SN10F6F3D
nodetype=fsp
mtm=9117-MMA
serial=10F6F3D
side=A
hcp=9.114.47.165
groups=fsp,all
mgt=hmc
[Object_node]
Name=lpar5
hcp=w1v3hmc05.ppd.pok.ibm.com
netboot=yaboot
tftpserver=192.168.10.1
nfsserver=192.168.10.1
monserver=192.168.10.1
xcatmaster=192.168.10.1
installnic=eth1
primarynic=eth0
arch=ppc64
profile=compute
os=rhels5.4
#system varible for autotest
[System]
CN=lpar5
ISO=/iso/RHEL5.4-Server-20090819.0-ppc-DVD.iso
NETDRIVER=ibmveth #network infterface card driver used by diskless installation
NETBOOTDIR=/opt/xcat/share/xcat/netboot/rh #path of netboot directory, used by diskless installation
MaxLparID=32
[Custom]
#commands run before test
[Script_Prev]
rpm -e xCAT xCAT-server xCAT-client perl-xCAT
rm -rf /etc/xcat
rm -rf /root/.xcat
rm -rf /root/.ssh
rm -rf /install/autoinst
rm -rf /install/postscripts
wget http://xcat.sourceforge.net/yum/devel/core-rpms-snap.tar.bz2
tar jxf core-rpms-snap.tar.bz2
./xcat-core/mklocalrepo.sh
mount -o loop /iso/RHEL5.4-Server-20090819.0-ppc-DVD.iso /iso/1 -t iso9660
yum -y install xCAT
umount /iso/1
rm -f core-rpms-snap.tar.bz2
rm -rf xcat-core
#commands run after test
[Script_Post]

View File

@ -0,0 +1,77 @@
start:chdef_null
cmd:chdef
check:rc==0
check:output=~Usage
end
start:chdef_t_o_attr
cmd:chdef -t network -o testnetwork net=111.222.33.0 mask=255.255.255.254
check:rc==0
cmd:lsdef -t network -l testnetwork
check:rc==0
check:output=~net=111.222.33.0
check:output=~mask=255.255.255.254
cmd:chdef -t network -o testnetwork net=111.222.34.0 mask=255.255.255.254 gateway=111.222.34.1
check:rc==0
cmd:lsdef -t network -l testnetwork
check:rc==0
check:output=~net=111.222.34.0
check:output=~mask=255.255.255.254
check:output=~gateway=111.222.34.1
cmd:rmdef -t network testnetwork
end
start:chdef_p_t_o_attr
cmd:mkdef -t node -o testnode groups=all
check:rc==0
cmd:chdef -p -t node -o testnode groups=aix
check:rc==0
cmd:lsdef -t node -l testnode
check:output=~groups=all,aix
cmd:rmdef -t node testnode
end
start:chdef_m_t_o_attr
cmd:mkdef -t node -o testnode groups=all,testgroup
check:rc==0
cmd:chdef -m -t node -o testnode groups=testgroup
check:rc==0
cmd:lsdef -t node -l testnode
check:output!~testgroup
cmd:rmdef -t node testnode
end
start:chdef_z
cmd:mkdef -t node -o testnode groups=all
check:rc==0
cmd:lsdef -l $$CN -z > /tmp/testnode.stanza
check:rc==0
cmd:perl -pi -e 's/$$CN/testnode/g' /tmp/testnode.stanza
cmd:cat /tmp/testnode.stanza | chdef -z
check:rc==0
cmd:lsdef -l testnode -z > /tmp/testnode1.stanza
check:rc==0
cmd:diff /tmp/testnode.stanza /tmp/testnode1.stanza
check:rc==0
cmd:rm -f /tmp/testnode1.stanza
cmd:rm -f /tmp/testnode.stanza
cmd:rmdef -t node testnode
end
start:chdef_t_o_attr_noderange
cmd:chdef -t node -o orignode mgt=fsp cons=hmc pprofile=orignode groups=lpar,all
check:rc==0
cmd:lsdef -l orignode -z > /tmp/orignode.stanza
check:rc==0
cmd:perl -pi -e 's/orignode/testnode/g' /tmp/orignode.stanza
cmd:cat /tmp/orignode.stanza | chdef -z
check:rc==0
cmd:lsdef -l testnode -z > /tmp/testnode.stanza
check:rc==0
cmd:diff /tmp/orignode.stanza /tmp/testnode.stanza
check:rc==0
cmd:rm -f /tmp/orignode.stanza
cmd:rm -f /tmp/testnode.stanza
cmd:rmdef -t node testnode
cmd:rmdef -t node orignode
end
start:chdef_t_o_error
cmd:chdef -t testtype -o testnode groups=all,aix
check:rc!=0
check:output=~Usage
end

View File

@ -0,0 +1,29 @@
start:chtab_null
cmd:chtab
check:rc!=0
check:output=~Usage
end
start:chtab_delete
cmd:chtab key=rsh_test site.value=/opt/xcat/bin/rcp site.comments="the rcp command" site.disable=no
check:rc==0
cmd:tabdump site | grep rsh_test
check:output=~/opt/xcat/bin/rcp
cmd:chtab -d key=rsh_test site
check:rc==0
cmd:tabdump site | grep rsh_test
check:output!=rsh_test
end
start:chtab_modify
cmd:chtab key=rsh_test site.value=/opt/xcat/bin/rcp site.comments="the rcp command" site.disable=no
check:rc==0
cmd:tabdump site | grep rsh_test
check:output=~/opt/xcat/bin/rcp
check:output=~no
check:output=~the rcp command
cmd:chtab key=rsh_test site.value=/opt/xcat/bin/scp site.disable=yes
check:rc==0
cmd:tabdump site | grep rsh_test
check:output=~/opt/xcat/bin/scp
check:output=~yes
cmd:chtab -d key=rsh_test site
end

View File

@ -0,0 +1,47 @@
start:chvm_null
cmd:chvm
check:rc!=0
check:output=~Usage
end
start:chvm_p
hcp:hmc
cmd:lsvm $$CN > /tmp/autotest.profile
check:rc==0
cmd:mkdef -t node -o testnode mgt=hmc groups=all
cmd:mkvm testnode -i $$MaxLparID -l $$CN
check:rc==0
cmd:perl -pi -e 's/min_mem=\d+/min_mem=1024/g' /tmp/autotest.profile
cmd:cat /tmp/autotest.profile|chvm testnode
check:rc==0
cmd:lsvm testnode
check:output=~min_mem=1024
cmd:chvm testnode -p __GETNODEATTR($$CN, pprofile)__
check:rc==0
check:output=~Success
cmd:lsvm testnode
check:output!~min_mem=1024
cmd:rmvm testnode
cmd:rm -f /tmp/autotest.profile
end
start:chvm_attr
hcp:hmc
cmd:mkdef -t node -o testnode mgt=hmc groups=all
cmd:mkvm testnode -i $$MaxLparID -l $$CN
check:rc==0
cmd:chvm testnode min_mem=1024
check:rc==0
check:output=~Success
cmd:lsvm testnode
check:output=~min_mem=1024
cmd:rmvm testnode
end
start:chvm_node
cmd:chvm $$CN
check:rc!=0
check:output=~Error
end
start:chvm_err_node
cmd:chvm testnode
check:rc!=0
check:output=~Error
end

View File

@ -0,0 +1,54 @@
start:copycds_iso
os:Linux
cmd:umount /mnt/xcat
cmd:copycds $$ISO
check:rc==0
check:output=~Copying media to /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/
check:output=~Media copy operation successful
cmd:ls /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/.treeinfo
check:rc==0
end
start:copycds_n
os:Linux
cmd:umount /mnt/xcat
cmd:copycds -n __GETNODEATTR($$CN,os)__ $$ISO
check:rc==0
check:output=~Copying media to /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/
check:output=~Media copy operation successful
cmd:ls /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/.treeinfo
check:rc==0
end
start:copycds_a
os:Linux
cmd:umount /mnt/xcat
cmd:copycds -a __GETNODEATTR($$CN,arch)__ $$ISO
check:rc==0
check:output=~Copying media to /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/
check:output=~Media copy operation successful
cmd:ls /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/.treeinfo
check:rc==0
end
start:copycds_n_a
os:Linux
cmd:umount /mnt/xcat
cmd:copycds -n __GETNODEATTR($$CN,os)__ -a __GETNODEATTR($$CN,arch)__ $$ISO
check:rc==0
check:output=~Copying media to /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/
check:output=~Media copy operation successful
cmd:ls /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/.treeinfo
check:rc==0
end
start:copycds_a_err
os:Linux
cmd:umount /mnt/xcat
cmd:copycds -a 386 $$ISO
check:rc!=0
check:output=~Error
end
start:copycds_n_err
os:Linux
cmd:umount /mnt/xcat
cmd:copycds -n aix $$ISO
check:rc!=0
check:output=~Error
end

View File

@ -0,0 +1,8 @@
start:geninitrd_i_n_o_p
os:Linux
cmd:copycds $$ISO
cmd:$$NETBOOTDIR/genimage -i __GETNODEATTR($$CN,installnic)__ -n $$NETDRIVER -o __GETNODEATTR($$CN,os)__ -p compute
check:rc==0
cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/initrd.gz
check:rc==0
end

View File

@ -0,0 +1,34 @@
start:getmacs_noderange
cmd:tabdump mac > /tmp/mac.csv
cmd:chtab -d node=$$CN mac
cmd:getmacs $$CN
check:rc==0
check:output=~[a-f0-9A-F]{12}|[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}
cmd:tabdump mac | grep $$CN
check:output=~[a-f0-9A-F]{12}|[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}
cmd:tabrestore /tmp/mac.csv
cmd:rm /tmp/mac.csv
end
start:getmacs_d
cmd:tabdump mac > /tmp/mac.csv
cmd:chtab -d node=$$CN mac
cmd:getmacs $$CN -d
check:rc==0
check:output=~[a-f0-9A-F]{12}|[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}
cmd:tabdump mac | grep $$CN
check:output!~[a-f0-9A-F]{12}|[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}
cmd:tabrestore /tmp/mac.csv
cmd:rm /tmp/mac.csv
end
start:getmacs_f_D
cmd:tabdump mac > /tmp/mac.csv
cmd:chtab -d node=$$CN mac
cmd:getmacs $$CN -f -D
check:rc==0
check:output=~[a-f0-9A-F]{12}|[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}
cmd:tabdump mac | grep $$CN
check:output=~[a-f0-9A-F]{12}|[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}:[a-f0-9A-F]{2}
cmd:tabrestore /tmp/mac.csv
cmd:rm /tmp/mac.csv
cmd:rpower $$CN on
end

View File

@ -0,0 +1,5 @@
start:gettab_key_table
cmd:gettab key=xcatdport site.value
check:rc==0
check:output==3001
end

View File

@ -0,0 +1,53 @@
start:aix_diskless_installation_flat
os:AIX
cmd:mknimimage -V -r -t diskless -s $$SOURCE autotestcosi
check:rc==0
cmd:lsnim | grep autotestcosi
check:rc==0
check:output=~lpp_source
check:output=~spot
check:output=~paging
check:output=~shared_root
cmd:nim -o update -a packages=all -a source=$$SSHPKG autotestcosi_lpp_source
check:rc==0
cmd:mkdir -p /install/nim/installp_bundle
cmd:cp $$SSHPKG/xCATaixCN.bnd /install/nim/installp_bundle/
check:rc==0
cmd:nim -o define -t installp_bundle -a server=master -a location=/install/nim/installp_bundle/xCATaixCN.bnd xCATaixCN
cmd:chdef -t osimage -o autotestcosi installp_bundle="xCATaixCN"
check:rc==0
cmd:xcatchroot -i autotestcosi "/usr/bin/echo root:cluster|/usr/bin/chpasswd -c"
check:rc==0
cmd:mknimimage -u autotestcosi
check:rc==0
cmd:rscan __GETNODEATTR($$CN, hcp)__ -w
check:rc==0
cmd:makeconservercf
check:rc==0
cmd:cat /etc/conserver.cf | grep $$CN
check:output=~$$CN
cmd:getmacs $$CN -f -D
check:rc==0
cmd:mkdsklsnode -i autotestcosi $$CN
check:rc==0
cmd:lsnim | grep $$CN
check:output=~machines
cmd:lsnim -l $$CN
check:output=~diskless or dataless boot is enabled
cmd:cat /etc/bootptab | grep $$CN
check:output=~__GETNODEATTR($$CN, mac)__
cmd:ls -l /tftpboot/$$CN*
check:output=~$$CN
cmd:cat /etc/exports | grep $$CN
check:output=~autotestcosi_shared_root
check:output=~spot/autotestcosi/usr
check:output=~autotestcosi_paging
cmd:rnetboot $$CN
check:rc==0
cmd:sleep 300
cmd:lsdef -l $$CN| grep status
check:output=~booted
cmd:xdsh $$CN date
check:rc==0
check:output=~\d\d:\d\d:\d\d
end

View File

@ -0,0 +1,52 @@
start:aix_full_installation_flat
os:AIX
cmd:mknimimage -V -s $$SOURCE autotest
check:rc==0
cmd:lsnim | grep autotest
check:rc==0
check:output=~lpp_source
check:output=~spot
check:output=~bosinst_data
cmd:nim -o update -a packages=all -a source=$$SSHPKG autotest_lpp_source
check:rc==0
cmd:mkdir -p /install/nim/installp_bundle
cmd:cp $$SSHPKG/xCATaixCN.bnd /install/nim/installp_bundle/
check:rc==0
cmd:nim -o define -t installp_bundle -a server=master -a location=/install/nim/installp_bundle/xCATaixCN.bnd xCATaixCN
cmd:chdef -t osimage -o autotest installp_bundle="xCATaixCN"
check:rc==0
cmd:rscan __GETNODEATTR($$CN, hcp)__ -w
check:rc==0
cmd:makeconservercf
check:rc==0
cmd:cat /etc/conserver.cf | grep $$CN
check:output=~$$CN
cmd:getmacs $$CN -f -D
check:rc==0
cmd:xcat2nim -t node -o $$CN
check:rc==0
cmd:lsnim | grep $$CN
check:output=~machines
cmd:nimnodeset -i autotest $$CN
check:rc==0
cmd:lsnim -l $$CN
check:output=~BOS installation has been enabled
cmd:cat /etc/bootptab | grep $$CN
check:output=~__GETNODEATTR($$CN, mac)__
cmd:ls -l /tftpboot/$$CN*
check:output=~$$CN
cmd:cat /etc/exports | grep $$CN
check:output=~autotest_bosinst_data
check:output=~spot/autotest/usr
check:output=~xcataixscript
check:output=~xCATaixCN.bnd
check:output=~autotest_lpp_source
cmd:rnetboot $$CN
check:rc==0
cmd:sleep 1800
cmd:lsdef -l $$CN| grep status
check:output=~booted
cmd:xdsh $$CN date
check:rc==0
check:output=~\d\d:\d\d:\d\d
end

View File

@ -0,0 +1,42 @@
start:Linux_diskless_installation_flat
os:Linux
cmd:rscan __GETNODEATTR($$CN,hcp)__ -w
check:rc==0
cmd:makedns
check:rc==0
cmd:service named restart
check:rc==0
cmd:nslookup $$CN
check:rc==0
check:output=~Address:\s+\d+.\d+.\d+.\d+
cmd:makeconservercf
check:rc==0
cmd:cat /etc/conserver.cf | grep $$CN
check:output=~$$CN
cmd:getmacs $$CN -f -D
check:rc==0
cmd:makedhcp -n
check:rc==0
cmd:makedhcp -a
check:rc==0
cmd:service dhcpd restart
check:rc==0
cmd:cat /var/lib/dhcpd/dhcpd.leases| grep lpar5
check:output=~lpar5
#cmd:copycds $$ISO
#check:rc==0
cmd:$$NETBOOTDIR/genimage -i __GETNODEATTR($$CN,installnic)__ -n $$NETDRIVER -o __GETNODEATTR($$CN,os)__ -p compute
check:rc==0
cmd:$$NETBOOTDIR/packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__
check:rc==0
cmd:nodeset $$CN netboot
check:rc==0
cmd:rnetboot $$CN
check:rc==0
cmd:sleep 600
cmd:lsdef -l $$CN | grep status
check:output=~booted
cmd:xdsh $$CN date
check:rc==0
check:output=~\d\d:\d\d:\d\d
end

View File

@ -0,0 +1,40 @@
start:Linux_full_installation_flat
os:Linux
cmd:rscan __GETNODEATTR($$CN,hcp)__ -w
check:rc==0
cmd:makedns
check:rc==0
cmd:service named restart
check:rc==0
cmd:nslookup $$CN
check:rc==0
check:output=~Address:\s+\d+.\d+.\d+.\d+
cmd:makeconservercf
check:rc==0
cmd:cat /etc/conserver.cf | grep $$CN
check:output=~$$CN
cmd:getmacs $$CN -f -D
check:rc==0
cmd:makedhcp -n
check:rc==0
cmd:makedhcp -a
check:rc==0
cmd:service dhcpd restart
check:rc==0
cmd:cat /var/lib/dhcpd/dhcpd.leases| grep lpar5
check:output=~lpar5
cmd:copycds $$ISO
check:rc==0
cmd:nodeset $$CN install
check:rc==0
cmd:rnetboot $$CN
check:rc==0
cmd:sleep 1200
cmd:ping $$CN -c 3
check:output=~64 bytes from $$CN
cmd:lsdef -l $$CN | grep status
check:output=~booted
cmd:xdsh $$CN date
check:rc==0
check:output=~\d\d:\d\d:\d\d
end

View File

@ -0,0 +1,101 @@
start:lsdef_null
cmd:mkdef -t node -o testnode groups=all
cmd:lsdef
check:rc==0
check:output=~testnode\s*\(node\)
cmd:rmdef testnode
end
start:lsdef_a
cmd:mkdef -t node -o testnode groups=all
check:rc==0
cmd:mkdef -t network -o testnetwork net=1.2.3.0 mask=255.255.255.0
check:rc==0
cmd:lsdef -a
check:output=~testnode
check:output=~testnetwork
cmd:lsdef --all
check:output=~testnode
check:output=~testnetwork
cmd:rmdef -t network testnetwork
cmd:rmdef -t node testnode
end
start:lsdef_t_o_l
cmd:mkdef -t node -o testnode groups=all
check:rc==0
cmd:mkdef -t network -o testnetwork net=1.2.3.0 mask=255.255.255.0
check:rc==0
cmd:lsdef -t node -l testnode
check:rc==0
check:output=~groups=all
check:output!~testnetwork
cmd:lsdef -t network -l testnetwork
check:rc==0
check:output=~net=1.2.3.0
check:output=~mask=255.255.255.0
check:output!~testnode
cmd:rmdef -t network testnetwork
cmd:rmdef -t node testnode
end
start:lsdef_t_o_l_z
cmd:mkdef -t node -o testnode groups=all
check:rc==0
cmd:mkdef -t network -o testnetwork net=1.2.3.0 mask=255.255.255.0
check:rc==0
cmd:lsdef -t node -l testnode -z
check:rc==0
check:output=~testnode:
check:output=~objtype=node
check:output=~groups=all
cmd:lsdef -t network -l testnetwork -z
check:output=~testnetwork:
check:output=~objtype=network
check:output=~mask=255.255.255.0
check:output=~net=1.2.3.0
cmd:rmdef -t network testnetwork
cmd:rmdef -t node testnode
end
start:lsdef_t
cmd:mkdef -t node -o testnode groups=all
check:rc==0
cmd:mkdef -t network -o testnetwork net=1.2.3.0 mask=255.255.255.0
check:rc==0
cmd:lsdef -t network
check:rc==0
check:output=~testnetwork
check:output!~testnode
cmd:rmdef -t network testnetwork
cmd:rmdef -t node testnode
end
start:lsdef_t_i_o
cmd:mkdef -t network -o testnetwork net=1.2.3.0 mask=255.255.255.0
check:rc==0
cmd:lsdef -t network -i net
check:rc==0
check:output=~net=1.2.3.0
check:output!~mask
cmd:rmdef -t network testnetwork
end
start:lsdef_t_w
cmd:mkdef -t node -o testnode1-testnode2 cons=hmc groups=all
check:rc==0
cmd:mkdef -t node -o testnode3-testnode4 cons=ipmi groups=linux
check:rc==0
cmd:lsdef -t node -w cons==ipmi
check:rc==0
check:output=~testnode3
check:output=~testnode4
check:output!=testnode1
check:output!=testnode2
cmd:lsdef -t node -w cons!~hmc
check:rc==0
check:output=~testnode3
check:output=~testnode4
check:output!=testnode1
check:output!=testnode2
cmd:rmdef -t node testnode1-testnode4
end
start:lsdef_t_err
cmd:lsdef -t test -o test
check:rc!=0
check:output=~Error
end

View File

@ -0,0 +1,16 @@
start:lsvm_null
cmd:lsvm
check:rc!=0
check:output=~Usage
end
start:lsvm_node
hcp:hmc,ivm
cmd:lsvm $$CN
check:rc==0
check:output=~name=$$CN
end
start:lsvm_err_node
cmd:lsvm testnode
check:rc!=0
check:output=~Error
end

View File

@ -0,0 +1,31 @@
start:makeconservercf_null
cmd:chdef -t node -o testnode cons=hmc
cmd:makeconservercf
check:rc==0
cmd:cat /etc/conserver.cf
check:output=~console testnode {
check:output=~ exec /opt/xcat/share/xcat/cons/hmc testnode;
check:output=~}
cmd:rmdef -t node testnode
end
start:makeconservercf_noderange
cmd:chdef -t node -o testnode cons=hmc
cmd:makeconservercf testnode
check:rc==0
cmd:cat /etc/conserver.cf
check:output=~console testnode {
check:output=~ exec /opt/xcat/share/xcat/cons/hmc testnode;
check:output=~}
cmd:rmdef -t node testnode
end
start:makeconservercf_d
cmd:chdef -t node -o testnode cons=hmc
cmd:makeconservercf testnode
check:rc==0
cmd:makeconservercf -d testnode
check:rc==0
cmd:cat /etc/conserver.cf | grep testnode
check:output!~testnode
cmd:rmdef -t node testnode
end

View File

@ -0,0 +1,52 @@
start:makedhcp_n
os:Linux
cmd:mv -f /etc/dhcpd.conf /etc/dhcpd.conf.bak
cmd:makedhcp -n
check:rc==0
cmd:ls /etc/dhcpd.conf
check:rc==0
cmd:ps -e | grep dhcpd
check:rc==0
check:output=~dhcpd
cmd:mv -f /etc/dhcpd.conf.bak /etc/dhcpd.conf
end
start:makedhcp_a
os:Linux
cmd:lsdef -l $$CN -z > /tmp/$$CN.stanza
cmd:chdef -t node -o $$CN mac=11:22:33:44:55:66
cmd:makedhcp -a
check:rc==0
cmd:cat /var/lib/dhcpd/dhcpd.leases
check:output=~$$CN
check:output=~11:22:33:44:55:66
cmd:chdef -t node -o $$CN mac=
cmd:cat /tmp/$$CN.stanza | chdef -z
end
start:makedhcp_a_d
os:Linux
cmd:lsdef -l $$CN -z > /tmp/$$CN.stanza
cmd:chdef -t node -o $$CN mac=11:22:33:44:55:66
cmd:mv -f /etc/dhcpd.conf /etc/dhcpd.conf.bak
cmd:makedhcp -a
cmd:makedhcp -a -d
check:rc==0
cmd:cat /var/lib/dhcpd/dhcpd.leases | grep deleted
check:output=~deleted
cmd:chdef -t node -o $$CN mac=
cmd:cat /tmp/$$CN.stanza | chdef -z
cmd:mv -f /etc/dhcpd.conf.bak /etc/dhcpd.conf
end
start:makedhcp_d
os:Linux
cmd:lsdef -l $$CN -z > /tmp/$$CN.stanza
cmd:chdef -t node -o $$CN mac=11:22:33:44:55:66
cmd:mv -f /etc/dhcpd.conf /etc/dhcpd.conf.bak
cmd:makedhcp -a
cmd:makedhcp -d $$CN
check:rc==0
cmd:cat /var/lib/dhcpd/dhcpd.leases | grep deleted
check:output=~deleted
cmd:chdef -t node -o $$CN mac=
cmd:cat /tmp/$$CN.stanza | chdef -z
cmd:mv -f /etc/dhcpd.conf.bak /etc/dhcpd.conf
end

View File

@ -0,0 +1,52 @@
start:mkdef_null
cmd:mkdef
check:rc!=0
check:output=~Usage
end
start:mkdef_t_o_attr
cmd:mkdef -t node -o testnode,testnode1 groups=all,aix
check:rc==0
cmd:lsdef -i groups testnode
check:rc==0
check:output=~groups=all,aix
cmd:lsdef -i groups testnode1
check:rc==0
check:output=~groups=all,aix
cmd:rmdef -t node -o testnode,testnode1
end
start:mkdef_f_t_o_attr
cmd:mkdef -t node -o testnode groups=all,aix
check:rc==0
cmd:mkdef -f -t node -o testnode nodetype=lpar,osi groups=all
check:rc==0
cmd:lsdef -i groups,nodetype testnode
check:rc==0
check:output=~nodetype=lpar,osi
check:output!=aix
cmd:rmdef -t node -o testnode
end
start:mkdef_z
cmd:mkdef -t node -o orignode mgt=fsp cons=hmc pprofile=orignode groups=lpar,all
check:rc==0
cmd:lsdef -l orignode -z > /tmp/orignode.stanza
check:rc==0
cmd:perl -pi -e 's/orignode/testnode/g' /tmp/orignode.stanza
cmd:cat /tmp/orignode.stanza | mkdef -z
check:rc==0
cmd:lsdef -l testnode -z > /tmp/testnode.stanza
check:rc==0
cmd:diff /tmp/orignode.stanza /tmp/testnode.stanza
check:rc==0
cmd:rm -f /tmp/orignode.stanza
cmd:rm -f /tmp/testnode.stanza
cmd:rmdef -t node testnode
cmd:rmdef -t node orignode
end
start:mkdef_t_o_error
cmd:mkdef -t testtype -o testnode groups=all,aix
check:rc!=0
check:output=~Usage
end

View File

@ -0,0 +1,14 @@
start:mkvm_i_l
hcp:hmc
cmd:mkdef -t node -o testnode1,testnode2 mgt=hmc groups=all
cmd:mkvm testnode1,testnode2 -i $$MaxLparID -l $$CN
check:rc==0
check:output=~testnode1\s*:\s*Success\ntestnode2\s*:\s*Success
cmd:lsvm testnode1
check:rc==0
check:output=~testnode1:.*lpar_name=testnode1,lpar_id=$$MaxLparID
cmd:lsvm testnode2
check:rc==0
check:output=~testnode2:.*lpar_name=testnode2,lpar_id=__INC($$MaxLparID)__
cmd:rmvm testnode1,testnode2
end

View File

@ -0,0 +1,20 @@
start:nodeadd_noderange
cmd:nodeadd testnode1-testnode2 groups="lpar,all" nodetype.nodetype="lpar,osi"
check:rc==0
cmd:lsdef -i groups,nodetype testnode1
check:rc==0
check:output=~testnode1
check:output=~groups=lpar,all
check:output=~nodetype=lpar,osi
cmd:lsdef -i groups,nodetype testnode2
check:rc==0
check:output=~testnode2
check:output=~groups=lpar,all
check:output=~nodetype=lpar,osi
cmd:rmdef -t node -o testnode1-testnode2
end
start:nodeadd_err_symbol
cmd:nodeadd testnode magt=unknown
check:rc!=0
check:output=~Error
end

View File

@ -0,0 +1,74 @@
start:nodech_noderange_table
cmd:chdef -t node -o testnode groups=all,rhels5.4
check:rc==0
cmd:nodech testnode groups=all,rhels5.5 nodetype.os=rhels5.5 nodehm.mgt=hmc
check:rc==0
cmd:lsdef -t node -i groups,os,mgt testnode
check:output=~groups=all,rhels5.5
check:output=~os=rhels5.5
check:output=~mgt=hmc
cmd:rmdef -t node testnode
end
start:nodech_noderange_table_comma
cmd:chdef -t node -o testnode groups=all
check:rc==0
cmd:nodech testnode groups,=rhels5.5
check:rc==0
cmd:lsdef -t node -i groups testnode
check:output=~groups=rhels5.5,all
cmd:rmdef -t node testnode
end
start:nodech_noderange_table_arrow
cmd:chdef -t node -o testnode groups=all,rhels5.5
check:rc==0
cmd:nodech testnode groups^=rhels5.5
check:rc==0
cmd:lsdef -t node -i groups testnode
check:output!=rhels5.5
cmd:rmdef -t node testnode
end
start:nodech_noderanage_table_at
cmd:chdef -t node -o testnode os=hello
check:rc==0
cmd:nodech testnode nodetype.os=@=helloworld
check:rc==0
cmd:lsdef -t node -i os testnode
check:output=~os==helloworld
cmd:rmdef -t node testnode
end
start:nodech_delete
cmd:chdef -t node -o testnode os=hello
check:rc==0
cmd:nodech -d testnode nodetype
check:rc==0
cmd:tabdump nodetype | grep testnode
check:output!~testnode
cmd:rmdef -t node testnode
end
start:nodech_delete_error
cmd:chdef -t node -o testnode os=hello
check:rc==0
cmd:nodech --delete
check:rc!=0
check:output=~Usage
cmd:nodech -d
check:rc!=0
check:output=~Usage
cmd:rmdef -t node testnode
end
start:nodech_error_node
cmd:chdef -t node -o testnode groups=all,rhels5.4
check:rc==0
cmd:nodech testnode1 groups=all,rhels5.5 nodetype.os=rhels5.5 nodehm.mgt=hmc
check:rc!=0
check:output=~Error
cmd:rmdef -t node testnode
end
start:nodech_error_table
cmd:chdef -t node -o testnode groups=all,rhels5.4
check:rc==0
cmd:nodech testnode groups=all,rhels5.5 nodetypes.os=rhels5.5 nodehm.mgt=hmc
check:rc!=0
check:output=~Error
cmd:rmdef -t node testnode
end

View File

@ -0,0 +1,39 @@
start:nodels_null
cmd:chdef -t node -o testnode groups="all,aix"
check:rc==0
cmd:nodels | grep testnode
check:rc==0
check:output=~testnode
cmd:rmdef -t node -o testnode
end
start:nodels_H
cmd:chdef -t node -o testnode groups="all,aix" mgt="hmc"
check:rc==0
cmd:nodels -H all groups mgt | grep testnode
check:rc==0
check:output=~groups:\s*all,aix
check:output=~mgt:\s*hmc
cmd:rmdef -t node -o testnode
end
start:nodels_noderange
cmd:chdef -t node -o testnode groups="all,aix"
check:rc==0
cmd:nodels testnode
check:rc==0
check:output==testnode
cmd:rmdef -t node -o testnode
end
start:nodels_err_symbol
cmd:nodels -H all unknown
check:rc!=0
check:output=~Error
end
start:nodels_err_noderange
cmd:nodels douniwan
check:rc!=0
check:output=~Error
end

View File

@ -0,0 +1,12 @@
start:noderm_noderange
cmd:nodeadd testnode1,testnode2 groups=all
check:rc==0
cmd:lsdef -t node testnode1,testnode2
check:output=~testnode1
check:output=~testnode2
cmd:noderm testnode1,testnode2
check:rc==0
cmd:lsdef -t node testnode1,testnode2
check:output=~Could not find an object named 'testnode1' of type 'node'.
check:output=~Could not find an object named 'testnode2' of type 'node'.
end

View File

@ -0,0 +1,12 @@
start:nodeset_stat
os:Linux
cmd:nodeset $$CN stat
check:rc==0
check:output=~$$CN:\s+[discover|boot|reboot|install|netboot|shell|standby]
end
start:nodeset_noderange
os:Linux
cmd:nodeset $$CN test
check:rc!=0
check:output=~Error
end

View File

@ -0,0 +1,10 @@
start:nodestat_noderange
cmd:nodestat $$CN
check:rc==0
check:output=~noping|sshd|install|snmp|pbs
end
start:nodestat_err_node
cmd:nodestat testnode
check:rc!=0
check:output=~Error
end

View File

@ -0,0 +1,7 @@
start:restartxcatd
os:AIX
cmd:restartxcatd
check:rc==0
check:output=~The xcatd Subsystem was requested to stop
check:output=~The xcatd Subsystem has been started. Subsystem PID is \d+
end

View File

@ -0,0 +1,22 @@
start:reventlog_null
cmd:reventlog
check:rc!=0
check:output=~Usage
end
start:reventlog_all
cmd:reventlog $$CN all
check:rc==0
check:output=~$$CN\s*:\s*.*\d\d/\d\d/\d\d\s*\S+
end
start:reventlog_clear
cmd:reventlog $$CN clear
check:rc==0
check:output=~$$CN\s*:\s*clear
end
start:reventlog_numofentries
cmd:reventlog $$CN 5
check:rc==0
check:output=~$$CN\s*:\s*.*\d\d/\d\d/\d\d\s*\S+
cmd:reventlog $$CN 3 | wc -l
check:output=~\s*3\s*
end

View File

@ -0,0 +1,55 @@
start:rinv_null
cmd:rinv
check:rc!=0
check:output=~Usage
end
start:rinv_bus
arch:ppc
cmd:rinv $$CN bus
check:rc==0
check:output=~I/O Bus Information
end
start:rinv_config
arch:ppc
cmd:rinv $$CN config
check:rc==0
check:output=~Machine Configuration Info
check:output=~Number of Processors:\s*\d+
check:output=~Total Memory \(\w+\):\s*\d+
end
start:rinv_serial
arch:ppc
cmd:rinv $$CN serial
check:rc==0
check:output=~Serial Number:\s*\w{7}
end
start:rinv_model
arch:ppc
cmd:rinv $$CN model
check:rc==0
check:output=~Machine Type/Model\s*:\s*\w{4}-\w{3}
end
start:rinv_firm
arch:ppc
cmd:rinv $$CN firm
check:rc==0
check:output=~Release Level\s*:\s*\w+
end
start:rinv_all
arch:ppc
cmd:rinv $$CN all
check:rc==0
check:output=~I/O Bus Information
check:output=~Machine Configuration Info
check:output=~Number of Processors:\s*\d+
check:output=~Total Memory \(\w+\):\s*\d+
check:output=~Serial Number:\s*\w{7}
check:output=~Machine Type/Model\s*:\s*\w{4}-\w{3}
check:output=~Release Level\s*:\s*\w+
end
start:rinv_noderange_err
cmd:rinv testnode
check:rc!=0
check:output=~Error
end

View File

@ -0,0 +1,43 @@
start:rmdef_null
cmd:rmdef
check:rc!=0
check:output=~Usage
end
start:rmdef_t_o_attr
cmd:mkdef -t node -o testnode,testnode1 groups=all,aix
check:rc==0
cmd:lsdef -t node testnode,testnode1
check:output=~testnode
check:output=~testnode1
cmd:rmdef -t node -o testnode,testnode1
check:rc==0
cmd:lsdef -t node testnode,testnode1
check:output=~Could not find an object named 'testnode' of type 'node'.
check:output=~Could not find an object named 'testnode1' of type 'node'.
end
start:rmdef_f_all
cmd:mkdir -p /tmp/db
cmd:dumpxCATdb -p /tmp/db
check:rc==0
cmd:rmdef -f -a
check:rc==0
cmd:XCATBYPASS=yes lsdef -a
check:rc==0
check:output!~group
check:output!~node
check:output!~network
check:output!~osimage
check:output!~policy
check:output!~notification
check:output!~eventlog
check:output!~boottarget
check:output!~firmware
check:output!~monitoring
cmd:XCATBYPASS=yes restorexCATdb -a -p /tmp/db
check:rc==0
end
start:rmdef_t_err
cmd:rmdef -t testtype -o testnode
check:rc!=0
check:output=~Usage
end

View File

@ -0,0 +1,23 @@
start:rmvm_noderange
hcp:hmc
cmd:mkdef -t node -o testnode1,testnode2 mgt=hmc groups=all
cmd:mkvm testnode1,testnode2 -i $$MaxLparID -l $$CN
check:rc==0
cmd:lsvm testnode1,testnode2
check:rc==0
check:output=~testnode1:
check:output=~testnode2:
cmd:rmvm testnode1,testnode2
check:rc==0
check:output=~testnode1:\s*Success
check:output=~testnode2:\s*Success
cmd:lsvm testnode1
check:output=~Invalid nodes
cmd:lsvm testnode2
check:output=~Invalid nodes
cmd:lsdef | grep testnode1
check:output!~testnode1
cmd:lsdef | grep testnode2
check:output!=testnode2
end

View File

@ -0,0 +1,72 @@
start:rpower_off
cmd:rpower $$CN stat
check:ouptut=~Running
cmd:rpower $$CN off
check:rc==0
check:output=~Success
cmd:sleep 30
cmd:rpower $$CN stat
check:output=~Not Activated
cmd:rpower $$CN on
cmd:sleep 300
end
start:rpower_stat
cmd:rpower $$CN stat
check:rc==0
check:output=~Running
cmd:rpower $$CN state
check:rc==0
check:output=~Running
end
start:rpower_boot
cmd:rpower $$CN off
cmd:sleep 30
cmd:rpower $$CN stat
check:output=~Not Activated
cmd:rpower $$CN boot
check:rc==0
check:output=~Success
cmd:sleep 30
cmd:rpower $$CN stat
check:output=~Running
cmd:sleep 300
end
start:rpower_on
cmd:rpower $$CN off
cmd:sleep 30
cmd:rpower $$CN stat
check:output=~Not Activated
cmd:rpower $$CN on
check:rc==0
check:output=~Success
cmd:sleep 30
cmd:rpower $$CN stat
check:output=~Running
cmd:sleep 300
end
start:rpower_reset
cmd:rpower $$CN stat
check:ouptut=~Running
cmd:rpower $$CN reset
check:rc==0
check:output=~Success
cmd:sleep 30
cmd:rpower $$CN stat
check:output=~Running
cmd:sleep 300
end
start:rpower_noderange
cmd:rpower $$CN
check:rc!=0
check:output=~Usage
end
start:rpower_noderange_nodeps
cmd:rpower $$CN --nodeps
check:rc!=0
check:output=~Usage
end
start:rpower_err_noderange
cmd:rpower testnode stat
check:rc!=0
check:output=~Error
end

View File

@ -0,0 +1,77 @@
start:rscan_noderange
hcp:hmc
cmd:rscan __GETNODEATTR($$CN,hcp)__
check:rc==0
check:output=~lpar\s+\w+\s+\d+\s+\w{4}-\w{3}\s+\w{7}\s+[\w|-]+
check:output=~fsp\s+[\w|-]+\s+\w{4}-\w{3}\s+\w{7}
check:output=~hmc\s+__GETNODEATTR($$CN,hcp)__\s+\w{4}-\w{3}\s+\w{7}
end
start:rscan_x
hcp:hmc
cmd:rscan __GETNODEATTR($$CN,hcp)__ -x
check:rc==0
check:output=~<parent>[\w-]+</parent>
end
start:rscan_z
hcp:hmc
cmd:rscan __GETNODEATTR($$CN,hcp)__ -z
check:rc==0
check:output=~hcp=__GETNODEATTR($$CN,hcp)__
end
start:rscan_w
hcp:hmc
cmd:lsdef -t node -l $$CN -z > /tmp/$$CN.stanza
check:rc==0
cmd:perl -pi -e 's/$$CN/testnode/g' /tmp/$$CN.stanza
cmd:cat /tmp/$$CN.stanza | mkdef -z
cmd:rmdef $$CN
cmd:rscan __GETNODEATTR(testnode,hcp)__ -w
check:rc==0
check:output=~lpar\s+\w+\s+\d+\s+\w{4}-\w{3}\s+\w{7}\s+[\w|-]+
check:output=~fsp\s+[\w|-]+\s+\w{4}-\w{3}\s+\w{7}
check:output=~hmc\s+__GETNODEATTR($$CN,hcp)__\s+\w{4}-\w{3}\s+\w{7}
cmd:lsdef -l $$CN
check:rc==0
check:output=~hcp=__GETNODEATTR($$CN,hcp)__
cmd:rmdef $$CN,testnode
cmd:perl -pi -e 's/testnode/$$CN/g' /tmp/$$CN.stanza
cmd:cat /tmp/$$CN.stanza | mkdef -z
cmd:rm -f /tmp/$$CN.stanza
end
start:rscan_x_w
hcp:hmc
cmd:lsdef -t node -l $$CN -z > /tmp/$$CN.stanza
check:rc==0
cmd:perl -pi -e 's/$$CN/testnode/g' /tmp/$$CN.stanza
cmd:cat /tmp/$$CN.stanza | mkdef -z
cmd:rmdef $$CN
cmd:rscan __GETNODEATTR(testnode,hcp)__ -x -w
check:rc==0
check:output=~<parent>[\w-]+</parent>
cmd:lsdef -l $$CN
check:rc==0
check:output=~hcp=__GETNODEATTR($$CN,hcp)__
cmd:rmdef $$CN,testnode
cmd:perl -pi -e 's/testnode/$$CN/g' /tmp/$$CN.stanza
cmd:cat /tmp/$$CN.stanza | mkdef -z
cmd:rm -f /tmp/$$CN.stanza
end
start:rscan_z_w
hcp:hmc
cmd:lsdef -t node -l $$CN -z > /tmp/$$CN.stanza
check:rc==0
cmd:perl -pi -e 's/$$CN/testnode/g' /tmp/$$CN.stanza
cmd:cat /tmp/$$CN.stanza | mkdef -z
cmd:rmdef $$CN
cmd:rscan __GETNODEATTR(testnode,hcp)__ -z -w
check:rc==0
check:output=~parent=[\w-]+
check:lsdef -l $$CN
check:rc==0
check:output=~parent=[\w-]+
cmd:rmdef $$CN,testnode
cmd:perl -pi -e 's/testnode/$$CN/g' /tmp/$$CN.stanza
cmd:cat /tmp/$$CN.stanza | mkdef -z
cmd:rm -f /tmp/$$CN.stanza
end

View File

@ -0,0 +1,42 @@
#Need to test later
start:rspconfig_autopower
hcp:fsp
cmd:rspconfig $$CEC autopower
check:rc==0
check:output=~$$CEC: autopower: \w+
end
start:rspconfig_iocap
hcp:fsp
cmd:rspconfig $$CEC iocap
check:rc==0
check:output=~$$CEC: iocap: \w+
end
start:
start:rspconfig_time
hcp:fsp
cmd:rspconfig $$CEC time
check:rc==0
check:output=~$$CEC: Time: \d\d:\d\d:\d\d
end
start:rspconfig_date
hcp:fsp
cmd:rspconfig $$CEC date
check:rc==0
check:output=~$$CEC: Date: \d\d-\d\d-\d\d\d\d
end
start:rspconfig_decfg
hcp:fsp
cmd:rspconfig $$CEC decfg
check:rc==0
check:output=~$$CEC
check:output=~floating point unit
check:output=~predictive
check:output=~system bus
check:output=~functional
end
start:rspconfig_sshcfg
hcp:hmc
cmd:rspconfig __GETNODEATTR($$CN,hcp)__ sshcfg
check:rc==0
check:output=~__GETNODEATTR($$CN,hcp)__: \w+
end

View File

@ -0,0 +1,40 @@
start:rvitals_temp
cmd:rvitals $$CN temp
check:rc==0
check:output=~System Temperature
end
start:rvitals_voltage
hcp:hmc,ivm,fsp,ipmi
cmd:rvitals $$CN voltage
check:rc==0
check:output=~Frame Voltages
end
start:rvitals_power
cmd:rvitals $$CN power
check:rc==0
check:output=~Current Power Status:\s*(on|off)
end
start:rvitals_state
cmd:rvitals $$CN state
check:rc==0
check:output=~System State:
end
start:rvitals_lcds
hcp:hmc,ivm,fsp,ipmi
cmd:rvitals $$CN lcds
check:rc==0
check:output=~Current LCD
end
start:rvitals_all
cmd:rvitals $$CN all
check:rc==0
check:output=~System Temperature
check:output=~Frame Voltages
check:output=~Current Power Status:\s*(on|off)
check:output=~System State:
end
start:rvitals_noderange_err
cmd:rvitals testnode
check:rc!=0
check:output=~Error
end

View File

@ -0,0 +1,17 @@
start:sinv_c_p_t_r_o
cmd:xdsh $$CN rpm -qa | xdshbak > /tmp/sinv.template
check:rc==0
cmd:sinv $$CN -c "xdsh $$CN rpm -qa" -p /tmp/sinv.template -t 2 -r -o /tmp/sinv.output
check:rc==0
cmd:cat /tmp/sinv.output
check:output=~$$CN
cmd:rm -f /tmp/sinv.template /tmp/sinv.output
end
start:sinv_c_s_p_t_o
cmd:sinv $$CN -c "xdsh $$CN rpm -qa" -s $$CN -p /tmp/sinv.template -t 2 -o /tmp/sinv.output
check:rc==0
cmd:cat /tmp/sinv.output
check:output=~$$CN
cmd:rm -f /tmp/sinv.template /tmp/sinv.output
end

View File

@ -0,0 +1,10 @@
start:tabdump_table
cmd:tabdump site | grep xcatiport
check:rc==0
check:output=="xcatiport","3002",,
end
start:tabdump_d
cmd:tabdump -d site | grep xcatiport
check:rc==0
check:output=~xcatiport
end

View File

@ -0,0 +1,8 @@
start:tabgrep_node
cmd:mkdef -t node testnode groups=all
check:rc==0
cmd:tabgrep testnode
check:rc==0
check:output=~nodelist
cmd:rmdef -t node testnode
end

View File

@ -0,0 +1,13 @@
start:tabrestore_table
cmd:tabdump site > /tmp/site.csv
check:rc==0
cmd:chtab key=xcatdport site.value=3333
check:rc==0
cmd:tabrestore /tmp/site.csv
check:rc==0
cmd:tabdump site > /tmp/site1.csv
check:rc==0
cmd:diff /tmp/site1.csv /tmp/site.csv
check:rc==0
cmd:rm -f /tmp/site.csv /tmp/site1.csv
end

View File

@ -0,0 +1,20 @@
start:xdcp_src_dst
cmd:xdsh $$CN rm -f /tmp/hosts
cmd:xdcp $$CN /etc/hosts /tmp/hosts
check:rc==0
cmd:xdsh $$CN cat /tmp/hosts > /tmp/hosts
cmd:perl -pi -e 's/$$CN: //g' /tmp/hosts
cmd:diff /tmp/hosts /etc/hosts
check:rc==0
cmd:xdsh $$CN rm -f /tmp/hosts
cmd:rm -f /tmp/hosts
end
start:xdcp_P
cmd:xdcp $$CN -P /etc/inittab /tmp/
check:rc==0
cmd:xdsh $$CN cat /etc/inittab > /tmp/inittab1
cmd:perl -pi -e 's/$$CN: //g' /tmp/inittab1
cmd:diff /tmp/inittab._$$CN /tmp/inittab1
check:rc==0
cmd:rm -f /tmp/inittab._$$CN /tmp/inittab1
end

View File

@ -0,0 +1,122 @@
=head1 NAME
B<xcattest> - Run xcat test cases.
=head1 B<SYNOPSIS>
B<xcattest> [B<-?|-h>]
B<xcattest> [B<-f> I<configure file>] [B<-b> I<case bundle list>] [B<--restore>]
B<xcattest> [B<-f> I<configure file>] [B<-t> I<case list>] [B<--restore>]
B<xcattest> [B<-f> I<configure file>] [B<-c> I<cmd list>] [B<-l>] [B<--restore>]
=head1 B<DESCRIPTION>
This command is used to run xCAT automated test and output the result to /opt/xcat/share/xcat/tool/xcat/result. All test cases is in the directory /opt/xcat/share/xcat/tools/autotest. Now there are some cases for basic function of xCAT. Each case has a unique case name. The cases for I<command> is place in directory /opt/xcat/share/xcat/tools/autotest/I<command>. When xcattest is run with -c , it will run all cases in the specified directory. User can add custom cases in the corresponding directory or add new directory if there is no corresponding directory.
=head1 OPTIONS
B<-?|-h> Display usage message.
B<-f> I<configure file>
Read configuration information from the configure file, default configure file is /opt/xcat/share/xcat/tools/autotest/default.conf. See /opt/xcat/share/xcat/tools/autotest/*.conf.template for example.
B<-b> I<case bundle list>
Comma separated list of file which contains cases which will be run. Default to run all cases.
B<-t> I<case list>
Comma separated list of cases which will be run. Default to run all cases.
B<-c> I<cmd list>
Comma separated list of commands which the related cases will be run. Default to run all cases.
B<-l>
Display all available cases.
B<--restore>
Restore test environment after test.
=head1 RETURN VALUE
0 The command completed successfully.
1 An error has occurred.
=head1 TEST CASE
The cases is specified as:
#required, case name
B<start>:case name
#optional, precondition
B<os>:AIX|Linux
#optional, precondition
B<arch>:ppc/x86
#optional, precondition
B<hcp>:hmc/mm/bmc/fsp
#required, command need to run
B<cmd>:comand
#optional, check return code of last executed command
B<check:rc> == or != <I>return code
#optional, check output of last executed command
B<check:output>== or != or =~ or !~ I<output check string>
end
The I<output check string> can be regular expression.
=head1 EXAMPLES
1. To run all test cases related command rpower:
B<xcattest -c /tmp/config -c rpower>
2. To run custom bundle:
B<xcattest -l > /tmp/custom.bundle>
B<edit custom.bundle>
B<xcattest -b custom.bundle>
3. To run specified test cases, and restore test environment after test.
B<xcattest -t lsdef_t_o_l_z --restore>
4. To add a new case to test chvm. In the example, we assume that the min_mem should not be equal to 16 in the lpar profile of computenode. The case name is chvm_custom. It create a test lpar named testnode firstly, that change the min_mem of the lpar to 16 using chvm, then check if min_mem have changed correctly. At last, the testnode be remove to ensure no garbage produced in the cases.
B<add a new file filename in /opt/xcat/share/xcat/tools/autotest/chvm>
B<edit filename>
I<start:chvm_custom>
I<hcp:hmc>
I<cmd:lsvm $$CN > /tmp/autotest.profile>
I<check:rc==0>
I<cmd:mkdef -t node -o testnode mgt=hmc groups=all>
I<cmd:mkvm testnode -i $$MaxLparID -l $$CN>
I<check:rc==0>
I<cmd:perl -pi -e 's/min_mem=\d+/min_mem=16/g' /tmp/autotest.profile>
I<cmd:cat /tmp/autotest.profile|chvm testnode>
I<check:rc==0>
I<cmd:lsvm testnode>
I<check:output=~min_mem=16>
I<cmd:rmvm testnode>
I<cmd:rm -f /tmp/autotest.profile>
I<end>
=head1 INLINE FUNCTION
There are some inline functions in the automated test tool. The function can be called in test cases as __FUNCTIONNAME(PARAMTERLIST)__. The function can be used in I<command> and I<output check string>.
The functions are:
1. B<GETNODEATTR(nodename, attribute)> To get the value of specified node's attribute
2. B<INC(digit)> To get value of digit+1.
For example:
To run rscan command with hcp point of compute node specified in configuration file
cmd: rscan __GETNODEATTR($$CN, hcp)__ -z
=head1 FILES
/opt/xcat/bin/xcattest

82
xCAT-test/xCAT-test.spec Normal file
View File

@ -0,0 +1,82 @@
Summary: xCAT automated test tool
Name: xCAT-test
Version: %(cat Version)
Release: snap%(date +"%Y%m%d%H%M")
Epoch: 4
License: EPL
Group: Applications/System
Source: xCAT-test-%(cat Version).tar.gz
Packager: IBM Corp.
Vendor: IBM Corp.
Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}}
Prefix: /opt/xcat
BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root
# AIX will build with an arch of "ppc"
%ifos linux
BuildArch: noarch
%endif
Provides: xCAT-test = %{version}
%description
Provides automated test tool and buckets to help test xCAT commands automatically.
%prep
%setup -q -n xCAT-test
%build
# Convert pods to man pages and html pages
mkdir -p share/man/man1
mkdir -p share/doc/man1
pod2man pods/man1/xcattest.1.pod > share/man/man1/xcattest.1
pod2html pods/man1/xcattest.1.pod > share/doc/man1/xcattest.1.html
%install
# The install phase puts all of the files in the paths they should be in when the rpm is
# installed on a system. The RPM_BUILD_ROOT is a simulated root file system and usually
# has a value like: /var/tmp/xCAT-test-2.0-snap200802270932-root
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{prefix}/bin
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/tools/autotest
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/man/man1
set +x
cp xcattest $RPM_BUILD_ROOT/%{prefix}/bin
chmod 755 $RPM_BUILD_ROOT/%{prefix}/bin/*
# These were built dynamically in the build phase
cp share/man/man1/* $RPM_BUILD_ROOT/%{prefix}/share/man/man1
chmod 444 $RPM_BUILD_ROOT/%{prefix}/share/man/man1/*
#cp -r share/doc/* $RPM_BUILD_ROOT/%{prefix}/share/doc
#chmod 755 $RPM_BUILD_ROOT/%{prefix}/share/doc/*
# These were built dynamically during the build phase
# cp share/doc/man1/* $RPM_BUILD_ROOT/%{prefix}/share/doc/man1
#chmod 644 $RPM_BUILD_ROOT/%{prefix}/share/doc/man1/*
#cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-autotest
#chmod 644 $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-autotest/*
cp -r autotest $RPM_BUILD_ROOT/%{prefix}/share/xcat/tools
set -x
%clean
# This step does not happen until *after* the %files packaging below
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
#%doc LICENSE.html
# Just package everything that has been copied into RPM_BUILD_ROOT
%{prefix}
%changelog
* Tue Sep 14 2010 - Airong Zheng <zhengar@us.ibm.com>
- "Create xCAT autotest package"
%post
%preun

690
xCAT-test/xcattest Executable file
View File

@ -0,0 +1,690 @@
#!/usr/bin/env perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
use strict;
use warnings;
use Getopt::Long;
use Data::Dumper;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr';
}
use lib "$::XCATROOT/lib/perl";
my $rootdir = "$::XCATROOT/share/xcat/tools/autotest";
my $needhelp = 0;
my $configfile = "$rootdir/default.conf";
my $bundle_list = undef;
my $case_list = undef;
my $cmd_list = undef;
my $needshow = 0;
my $restore = 0;
my $ret = 0;
if (
!GetOptions("h|?" => \$needhelp,
"f=s" => \$configfile,
"b=s" => \$bundle_list,
"t=s" => \$case_list,
"c=s" => \$cmd_list,
"l" => \$needshow,
"restore"=>\$restore)
)
{
&usage;
exit 1;
}
if ($needhelp)
{
&usage;
exit 0;
}
#load case to $cases
# key type
#$cases[x](x>0): hash
# name string
# os:AIX/Linux string
# arch:ppc64/x386 string
# hcp:hmc/mm/bmc/fsp string
# cmd: array
# check: array
my @cases=();
if($needshow){
&loadcase;
exit 0;
}
my $resultdir = "$rootdir/result";
#Create result directory
mkdir $resultdir unless -d $resultdir;
# create a log
my $timestamp = `date +"%Y%m%d%H%M%S"`;
open(LOG, ">$resultdir/xcattest.log.$timestamp")
or die "Can't open logfile for writing: $!";
&log_this("xCAT automated test started at " . scalar(localtime()));
open(LOG_ERR, ">$resultdir/failedcases.$timestamp")
or die "Can't open error logfile for writing: $!";
#read config file
#config{object}{type}{name}{attr}
#config{table}{name}{entry}{key}
#config{script_prev}->[]
#config{script_post}->[]
#config{var}{varname}
my %config=();
$ret = &getConfig;
if($ret != 0){
goto EXIT;
}
$ret = &init;
if($ret != 0){
goto EXIT;
}
#loading and check cases
$ret = &loadcase;
if($ret != 0){
goto EXIT;
}
#run case
&runcase;
EXIT:
if($restore){
&uninit;
}
&log_this("\nxCAT automated test finished at " . scalar(localtime()));
&log_this("Please check results in the $resultdir, \nand see $resultdir/failedcases.$timestamp file for failed cases.");
close(LOG);
close(LOG_ERR);
exit 0;
# end main
#
# logger
#
sub log_this
{
if($needshow){
return;
}
print LOG join("\n", @_), "\n";
print join("\n", @_), "\n";
}
sub log_error
{
print LOG_ERR join("\n", @_), "\n";
}
sub getConfig
{
log_this("******************************");
log_this("Reading Configure");
log_this("******************************");
if(!(-e $configfile)){
log_this("Warning: The xCAT test Configure file doesn't exist!");
return 0;
}
my $type = undef; #Script_Prev,Script_Post,Table,Object,System,Custom
my $sub_type = undef; # The string after $type_
# Script-->
# Script_Prev
# Script_Post
# Table--->
# Table_xxxxx
# Object-->
# Object_xxxx
# System---->
# Custom---->
my $name = undef;
my $attr = undef;
my $value = undef;
my $c = 0;
my $cmd = undef;
my $mgt_name = undef;
open(FILE, "$configfile") or die "can't to open $configfile";
while(my $line = <FILE>) {
$line = &trim($line);
next if(length($line) == 0);
#Table name can not contain "_"
if($line =~ /\[\s*(\w+)\_(\w+)\s*\]/) {
$type = $1;
$sub_type = $2;
$name = undef;
$c = 0;
}elsif($line =~ /\[\s*System|Custom\s*\]/){
$type = "Varible";
}elsif ($type eq "Table") {
##TABLE BLOCK##
if($line =~ /(\w+)\s*=\s*([\w\.\-]+)/) {
$attr = $1;
$value = $2;
if($name&&($config{table}{$sub_type}{$name}{__KEY__} ne $attr)){
$config{table}{$sub_type}{$name}{$attr}=$value;
} else {
$name = $value;
$config{table}{$sub_type}{$name}{__KEY__}=$attr;
}
}
}elsif ($type eq "Object") {
##OBJECT BLOCK##
if($line =~ /(\w+)\s*=\s*([\w\.\-]+)/) {
$attr = $1;
$value = $2;
if($attr eq "Name"){
$name = $value;
} elsif(!defined($name)){
print "Please give name for Object\n";
close FILE;
return 1;
} else {
$config{object}{$sub_type}{$name}{$attr}=$value;
}
}
}elsif ($type eq "Script") {
##SCRIPT_BLOCK##
if($sub_type eq "Prev") {
$config{script_prev}->[$c] = $line;
$c = $c + 1;
}
elsif ($sub_type eq "Post") {
$config{script_post}->[$c] = $line;
$c = $c + 1;
}
} elsif ($type eq "Varible") {
##NODE_BLOCK##
if($line =~ /(\w+)\s*=\s*([\w\.\-\/]+)/) {
$config{var}{$1} = $2;
}
}
}
if(exists $config{object}){
foreach my $type (keys %{$config{object}}){
foreach my $name (keys %{$config{object}{$type}}){
log_this("OBJECT:$name,TYPE:$type");
foreach my $attr (keys %{$config{object}{$type}{$name}}){
log_this(" $attr = $config{object}{$type}{$name}{$attr};");
}
}
}
}
if(exists $config{table}){
foreach my $type (keys %{$config{table}}){
log_this("TABLE:$type");
foreach my $name (keys %{$config{table}{$type}}){
log_this(" $config{table}{$type}{$name}{__KEY__} = $name");
foreach my $attr (keys %{$config{table}{$type}{$name}}){
if($attr ne '__KEY__'){
log_this(" $attr = $config{table}{$type}{$name}{$attr}");
}
}
log_this("\n");
}
}
}
if(exists $config{script_prev}){
log_this("Script_Prev:");
foreach $cmd (@{$config{script_prev}}){
log_this(" $cmd");
}
}
if(exists $config{script_post}){
log_this("Script_Prev:");
foreach $cmd (@{$config{script_post}}){
log_this(" $cmd");
}
}
if(exists $config{var}){
log_this("Varible:");
foreach my $varname (keys %{$config{var}}){
log_this(" $varname = $config{var}{$varname}");
}
}
close FILE;
return 0;
}
sub init
{
log_this("******************************");
log_this("initialize xCAT test evironment");
log_this("******************************");
my $cmd = undef;
foreach $cmd (@{$config{script_prev}}){
log_this("$cmd");
&runcmd($cmd);
if($::RUNCMD_RC != 0){
&log_this("Fail to run $cmd");
return 1;
}
}
if(exists $config{object}){
foreach my $type (keys %{$config{object}}){
foreach my $name (keys %{$config{object}{$type}}){
$cmd = "chdef -t $type -o $name";
foreach my $attr (keys %{$config{object}{$type}{$name}}){
$cmd = $cmd." $attr=$config{object}{$type}{$name}{$attr}";
}
log_this($cmd);
runcmd($cmd);
if($::RUNCMD_RC != 0){
log_this("Fail to run $cmd");
return 1;
}
}
}
}
if(exists $config{table}){
foreach my $type (keys %{$config{table}}){
foreach my $name (keys %{$config{table}{$type}}){
$cmd = "chtab $config{table}{$type}{$name}{__KEY__}=$name";
foreach my $attr (keys %{$config{table}{$type}{$name}}){
if($attr ne '__KEY__'){
$cmd = $cmd." $type.$attr=$config{table}{$type}{$name}{$attr}";
}
}
log_this($cmd);
&runcmd($cmd);
if($::RUNCMD_RC != 0){
&log_this("Fail to run $cmd");
return 1;
}
}
}
}
if(!exists $config{var}{OS}){
my @output = runcmd("uname");
$config{var}{OS} = $output[0];
log_this("Detecting: OS = $config{var}{OS}");
}
if(!exists $config{var}{ARCH}){
if(!exists $config{var}{CN}){
$config{var}{ARCH} = "Unknown";
log_this("No compute node defined,can't get ARCH of compute node");
} else {
$config{var}{ARCH} = getnodeattr($config{var}{CN},"arch");
if($config{var}{ARCH} =~ /ppc/){
$config{var}{ARCH} = 'ppc';
}elsif($config{var}{ARCH}=~/86/){
$config{var}{ARCH} = 'x86';
}
log_this("Detecting: ARCH = $config{var}{ARCH}");
}
}
if(!exists $config{var}{HCP}){
if(!exists $config{var}{CN}){
$config{var}{HCP} = "Unknown";
log_this("No compute node defined,can't get HCP TYPE of compute node");
} else {
$config{var}{HCP} = getnodeattr($config{var}{CN}, "mgt");
log_this("Detecting: HCP = $config{var}{HCP}");
}
}
return 0;
}
sub uninit
{
log_this("******************************");
log_this("un-initialize xCAT test evironment");
log_this("******************************");
my $cmd = undef;;
if(exists $config{object}){
foreach my $type (keys %{$config{object}}){
foreach my $name (keys %{$config{object}{$type}}){
$cmd = "rmdef -t $type -o $name";
log_this($cmd);
runcmd($cmd);
if($::RUNCMD_RC != 0){
log_this("Fail to run $cmd");
return 1;
}
}
}
}
if(exists $config{table}){
foreach my $type (keys %{$config{table}}){
foreach my $name (keys %{$config{table}{$type}}){
$cmd = "chtab -d $config{table}{$type}{$name}{__KEY__}=$name $type";
log_this($cmd);
runcmd($cmd);
if($::RUNCMD_RC != 0){
log_this("Fail to run $cmd");
return 1;
}
}
}
}
foreach $cmd (@{$config{script_post}}){
log_this($cmd);
runcmd($cmd);
if($::RUNCMD_RC != 0){
log_this("Fail to run $cmd");
return 1;
}
}
return 0;
}
sub loadcase
{
log_this("******************************");
log_this("loading test cases");
log_this("******************************");
my $casedir = "/opt/xcat/share/xcat/tools/autotest/testcase";
my @files = ();
if($cmd_list){
my @cmds = split /,/,$cmd_list;
for my $cmd (@cmds){
push (@files, glob("$casedir/$cmd/*"));
}
} else {
@files = glob("$casedir/*/*");
}
my $file;
my $line;
my $i = 0;
my $j = -1;
my $z = 0;
my $skip = 0;
my @caserange = ();
my @rightcase = ();
my @notrightcase = ();
if($bundle_list){
my @bundles = split /,/, $bundle_list;
foreach my $bundle (@bundles){
if(!open(FILE, "<$rootdir/bundle/$bundle")){
log_this("can't open $rootdir/bundle/$bundle");
return 1;
}
while($line=<FILE>){
$line = trim($line);
next if(length($line) == 0);
push(@caserange, $line);
}
close(FILE);
}
}
if($case_list){
@caserange = split /,/, $case_list;
}
foreach $file (@files){
if(!open(FILE, "<$file")){
log_this("can't open $file");
return 1;
}
while($line=<FILE>){
$line = &trim($line);
next if(length($line) == 0);
if($line =~ /^start\s*:\s*(\w+)/){
$skip = 0;
my $name = $1;
if( $caserange[0] && !(grep {/^$name$/} @caserange)){
$skip = 1;
next;
}
$j = -1;
$cases[$i]={};
$cases[$i]->{name}=$name;
$cases[$i]->{filename}=$file;
if(!$needshow){
$cases[$i]->{cmd}=[];
$cases[$i]->{check}=[];
push(@rightcase, $name);
}else{
$skip = 1;
$i = $i + 1;
}
}elsif($line =~ /^os\s*:\s*(\w[\w\,]+)/){
next if $skip;
$cases[$i]->{os}=$1;
if($cases[$i]->{os} !~ /$config{var}{OS}/){
push(@notrightcase, $cases[$i]->{name});
pop(@rightcase);
$skip = 1;
}
}elsif($line =~ /^arch\s*:\s*(\w[\w\,]+)/){
next if $skip;
$cases[$i]->{arch}=$1;
if($cases[$i]->{arch} !~ /$config{var}{ARCH}/){
push(@notrightcase, $cases[$i]->{name});
pop(@rightcase);
$skip = 1;
}
}elsif($line =~ /^hcp\s*:\s*(\w[\w\,]+)/){
next if $skip;
$cases[$i]->{hcp}=$1;
if($cases[$i]->{hcp} !~ /$config{var}{HCP}/){
push(@notrightcase, $cases[$i]->{name});
pop(@rightcase);
$skip = 1;
}
}elsif($line =~ /^cmd\s*:\s*([\$\w].+)/){
next if $skip;
$j = $j + 1;
$z = 0;
$cases[$i]->{cmd}->[$j]=&getvar($1);
if($cases[$i]->{cmd}->[$j] eq ''){
close(FILE);
return 1;
}
}elsif($line =~ /^check\s*:\s*(\w.+)/){
next if $skip;
$cases[$i]->{check}->[$j][$z] = &getvar($1);
if($cases[$i]->{check}->[$j][$z] eq ''){
close(FILE);
return 1;
}
$z = $z + 1;
}elsif($line =~ /^end/){
next if $skip;
$i = $i + 1;
}
}
close(FILE);
}
if($needshow){
foreach my $case (@cases){
print "$case->{name}\n";
}
return 0;
}
log_this("To run:", @rightcase);
log_this("Not to run:", @notrightcase);
return 0;
}
sub getnodeattr
{
my ($node, $attr) = @_;
my @output = runcmd("lsdef -t node -o $node -i $attr");
if($::RUNCMD_RC){
return "Unknown";
}else{
foreach my $output1 (@output){
if($output1 =~ /$attr=(\w.+)/){
return $1;
}
}
}
return "Unknown";
}
#to remove space and comment
sub trim
{
my $str = shift @_;
if($str){
$str =~ s/^\s+|#.+|\s+$//g;
}
return $str;
}
sub getvar
{
my $str = shift @_;
while($str =~ /\$\$(\w+)/){
my $varname = $1;
if(exists ($config{var}{$varname})){
$str =~ s/\$\$$varname/$config{var}{$varname}/g;
} else {
log_this("Error:can't get varible $varname");
return '';
}
}
return $str;
}
sub getfunc
{
my $str = shift @_;
my $func = undef;
my @para = ();
my $parameter = undef;
my $value = undef;
while($str =~ /__(\w+)\(([\s\,\w\$]*)\)__/){
$func = $1;
$parameter = $2;
@para = split /\s*,\s*/, trim($parameter);
if($func eq "GETNODEATTR"){
$value= getnodeattr(@para);
if($value eq "Unknown"){
$value = '';
}
}elsif($func eq "INC"){
$value = $para[0] + 1;
}
$str =~ s/__$func\($parameter\)__/$value/g;
}
return $str;
}
sub runcase
{
log_this("******************************");
log_this("Start to run test cases");
log_this("******************************");
my @output = ();
my $rc = 0;
my $j = 0;
my $z = 0;
my $lvalue = undef;
my $rvalue = undef;
my $op = undef;
my $failed = 0;
my $total = 0;
my $failnum = 0;
foreach my $case (@cases){
my @record = ();
$failed = 0;
$j = 0;
$total = $total + 1;
log_this("------START:$$case{name}------");
push @record, "------START:$$case{name}------";
push @record, "FILENAME:$$case{filename}";
foreach my $cmd (@{$$case{cmd}}){
$cmd = getfunc($cmd);
log_this("\nRUN:$cmd");
push(@record, "\nRUN:$cmd");
@output = &runcmd($cmd);
$rc = $::RUNCMD_RC;
log_this("RETURN: rc = $rc","OUTPUT:",@output);
push(@record,("RETURN rc = $rc","OUTPUT:",@output));
foreach my $check (@{$$case{check}->[$j]}){
if($failed){
last;
}
if($check =~ /rc\s*([=!]+)\s*(\d+)/){
$lvalue = $rc;
$op = $1;
$rvalue = $2;
if((($op eq '!=') && ($lvalue == $rvalue))
||(($op eq '==') && ($lvalue != $rvalue))){
$failed = 1;
}
if($failed){
log_this("CHECK:rc $op $rvalue\t[Failed]");
push(@record, "CHECK:rc $op $rvalue\t[Failed]");
last;
} else {
log_this("CHECK:rc $op $rvalue\t[Pass]");
push(@record, "CHECK:rc $op $rvalue\t[Pass]");
}
} elsif ($check =~ /output\s*([=!~]+)\s*(\S.*)/){
$lvalue = join ("\n",@output);
$op = $1;
$rvalue = $2;
$rvalue = getfunc($rvalue);
if((($op eq '=~' )&&($lvalue !~ /$rvalue/))
||(($op eq '!~')&&($lvalue =~ /$rvalue/))
||(($op eq '==')&&($lvalue ne $rvalue))
||(($op eq '!=')&&($lvalue eq $rvalue))){
$failed = 1;
}
if($failed){
log_this("CHECK:output $op $rvalue\t[Failed]");
push(@record, "CHECK:output $op $rvalue\t[Failed]");
last;
} else {
log_this("CHECK:output $op $rvalue\t[Pass]");
push(@record, "CHECK:output $op $rvalue\t[Pass]");
}
}
}
$j = $j + 1;
}
log_this("------END:$$case{name}------");
push (@record,"------END:$$case{name}------");
if($failed){
$failnum = $failnum + 1;
log_error(@record);
}
}
log_this("\n\n");
log_this("------Total: $total , Failed: $failnum------");
}
sub runcmd
{
my ($cmd) = @_;
my $rc = 0;
$::RUNCMD_RC = 0;
my $outref = [];
@$outref = `$cmd 2>&1`;
if ($?)
{
$rc = $? ;
$::RUNCMD_RC = $rc;
}
chomp(@$outref);
return @$outref;
}
sub usage
{
print "Usage:xcattest - Run xcat test cases.\n";
print " xcattest [-?|-h]\n";
print " xcattest [-f configure file] [-b case bundle list] [--restore]\n";
print " xcattest [-f configure file] [-t case list] [--restore]\n";
print " xcattest [-f configure file] [-c cmd list] [-l] [--restore]\n";
print "\n";
return;
}