From 9bbdf2b49ee31a432a263cc41693a2cddf124d78 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Fri, 15 Dec 2017 02:29:04 -0500 Subject: [PATCH] Add and modify test cases for openbmc hardware control --- .../bundle/hdctrl_openpower_openbmc.bundle | 10 +- .../autotest/testcase/rflash/rflash_openbmc.0 | 5 +- xCAT-test/autotest/testcase/rinv/cases0 | 2 +- xCAT-test/autotest/testcase/rspconfig/cases0 | 231 ++++++++++++++++-- 4 files changed, 229 insertions(+), 19 deletions(-) diff --git a/xCAT-test/autotest/bundle/hdctrl_openpower_openbmc.bundle b/xCAT-test/autotest/bundle/hdctrl_openpower_openbmc.bundle index f7ac6792d..541c303ee 100644 --- a/xCAT-test/autotest/bundle/hdctrl_openpower_openbmc.bundle +++ b/xCAT-test/autotest/bundle/hdctrl_openpower_openbmc.bundle @@ -33,10 +33,17 @@ rspconfig_list_ip rspconfig_list_netmask rspconfig_list_vlan rspconfig_noderange_invalid -rspconfig_set_all rspconfig_set_all_invalid rspconfig_set_vlan rspconfig_set_vlan_invalid +rspconfig_set_hostname_equal_star_with_bmc_is_ip +rspconfig_set_hostname_equal_star_with_bmc_is_hostname +rspconfig_get_hostname +rspconfig_hostname_with_error_input +rspconfig_set_hostname +rspconfig_set_admin_passwd_with_error_input +rspconfig_set_admin_passwd_with_error_origin_password +rspconfig_sshcfg_with_error_input rflash_option_c_without_specify_noderange rflash_option_l_without_specify_noderange rflash_option_a_without_specify_noderange @@ -74,4 +81,3 @@ rpower_softoff rpower_suspend_OpenpowerBmc rpower_wake_OpenpowerBmc rpower_errorcommand_OpenpowerBmc -rpower_wrongpasswd diff --git a/xCAT-test/autotest/testcase/rflash/rflash_openbmc.0 b/xCAT-test/autotest/testcase/rflash/rflash_openbmc.0 index 62a05dd1c..4115fbad5 100644 --- a/xCAT-test/autotest/testcase/rflash/rflash_openbmc.0 +++ b/xCAT-test/autotest/testcase/rflash/rflash_openbmc.0 @@ -446,6 +446,9 @@ cmd:rflash $$CN -d /tmp/bogus123 check:output=~Error: Can't open directory check:output!~Attempting to check:rc != 0 +cmd:rflash $$CN /tmp/bogus123 +check:output=~Error: Invalid option specified +check:rc != 0 cmd:mkdir -p /tmp/bogus123 check:rc == 0 cmd:rflash $$CN /tmp/bogus123 -d @@ -478,7 +481,7 @@ hcp:openbmc cmd:rflash -h check:output =~Usage: check:output =~OpenPOWER OpenBMC specific: -check:output =~ -d.+–no-host-reboot +check:output =~ -d.+no-host-reboot check:output =~ image_id.+--delete check:rc == 0 end diff --git a/xCAT-test/autotest/testcase/rinv/cases0 b/xCAT-test/autotest/testcase/rinv/cases0 index e1a41eecd..37f916efa 100644 --- a/xCAT-test/autotest/testcase/rinv/cases0 +++ b/xCAT-test/autotest/testcase/rinv/cases0 @@ -121,7 +121,7 @@ cmd:chdef $$CN bmcpassword=test check:rc==0 cmd:rinv $$CN all check:rc==1 -check:output=~$$CN: Error: Invalid username or password|Error: ERROR: Incorrect password provided +check:output=~$$CN: Error:.+Invalid username or password|Error: ERROR: Incorrect password provided cmd:cat /tmp/testnode.stanza | chdef -z;rm -rf /tmp/testnode.stanza check:rc==0 end diff --git a/xCAT-test/autotest/testcase/rspconfig/cases0 b/xCAT-test/autotest/testcase/rspconfig/cases0 index da4ddb70f..7b773f1ac 100644 --- a/xCAT-test/autotest/testcase/rspconfig/cases0 +++ b/xCAT-test/autotest/testcase/rspconfig/cases0 @@ -11,7 +11,7 @@ cmd:rspconfig $$CEC iocap check:rc==0 check:output=~$$CEC: iocap: \w+ end -start: + start:rspconfig_time hcp:fsp cmd:rspconfig $$CEC time @@ -42,54 +42,81 @@ check:output=~__GETNODEATTR($$CN,hcp)__: \w+ end start:rspconfig_set_ip -description:rspconfig change openbmc ip +description:To test change openbmc ip separately by rspconfig. should not support and throw out error message Attribute: $$CN-The operation object of rspconfig command -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/rspconfig/rspconfig.sh -i $$CN $NODEIP -check:rc==0 -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/rspconfig/rspconfig.sh -c $$CN ip -check:rc==0 +os:Linux +hcp:openbmc +cmd:rspconfig $$CN ip=__GETNODEATTR($$CN,bmc)__ +check:output=~Error: IP, netmask and gateway must be configured together. +check:rc!=0 end start:rspconfig_ip_invalid description:rspconfig could not change openbmc ip using invalid ip Attribute: $$CN-The operation object of rspconfig command -cmd:rspconfig $$CN ip=ddd +os:Linux +hcp:openbmc +cmd:rspconfig $$CN ip=ddd gateway=0.0.0.0 netmask=255.255.0.0 +check:output=~Error: Invalid parameter for option ip check:rc!=0 end start:rspconfig_ip_null description:rspconfig could not set ip to null Attribute: $$CN-The operation object of rspconfig command +os:Linux +hcp:openbmc cmd:rspconfig $$CN ip= +check:output=~Invalid parameter for option ip +check:rc!=0 +cmd:rspconfig $$CN ip= gateway=0.0.0.0 netmask=255.255.0.0 +check:output=~Invalid parameter for option ip check:rc!=0 end start:rspconfig_set_netmask -description:rspconfig change openbmc netmask +description:To test change openbmc netmask separately by rspconfig. should not support and throw out error message Attribute: $$CN-The operation object of rspconfig command -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/rspconfig/rspconfig.sh -n $$CN netmask -check:rc==0 +os:Linux +hcp:openbmc +cmd:rspconfig $$CN netmask=255.255.0.0 +check:output=~Error: IP, netmask and gateway must be configured together. +check:rc!=0 end start:rspconfig_netmask_invalid despcription:rspconfig could not change openbmc netmask using invalid netmask Attribute: $$CN-The operation object of rspconfig command cmd:rspconfig $$CN netmask=ddd +check:output=~Error: Invalid parameter for option netmask +check:rc!=0 +cmd:rspconfig $$CN netmask=ddd ip=__GETNODEATTR($$CN,bmc)__ gateway=0.0.0.0 +check:output=~Error: Invalid parameter for option netmask +check:rc!=0 +cmd:rspconfig $$CN netmask= ip=__GETNODEATTR($$CN,bmc)__ gateway=0.0.0.0 +check:output=~Error: Invalid parameter for option netmask check:rc!=0 end start:rspconfig_set_gateway -description:rspconfig change openbmc gateway +description:To test change openbmc gateway by rspconfig. should not support and throw out error message Attribute: $$CN-The operation object of rspconfig command -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/rspconfig/rspconfig.sh -g $$CN gateway -check:rc==0 +os:Linux +hcp:openbmc +cmd:rspconfig $$CN gateway=0.0.0.0 +check:output=~Error: IP, netmask and gateway must be configured together. +check:rc!=0 end start:rspconfig_set_vlan description:rspconfig change openbmc gateway Attribute: $$CN-The operation object of rspconfig command -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/rspconfig/rspconfig.sh -v $$CN vlan -check:rc==0 +cmd:rspconfig $$CN vlan=0 +check:output=~Error: Invalid parameter for option vlan +check:rc!=0 +cmd:rspconfig $$CN vlan=111 +check:output=~Error: VLAN must be configured with IP, netmask and gateway +check:rc!=0 end start:rspconfig_set_all @@ -102,29 +129,47 @@ end start:rspconfig_gateway_invalid despcription:rspconfig could not change openbmc gatway using invalid gateway Attribute: $$CN-The operation object of rspconfig command +os:Linux +hcp:openbmc cmd:rspconfig $$CN gateway=ddd +check:output=~Error: Invalid parameter for option gateway +check:rc!=0 +cmd:rspconfig $$CN gateway= ip=__GETNODEATTR($$CN,bmc)__ netmask=255.0.0.0 +check:output=~Error: Invalid parameter for option gateway +check:rc!=0 +cmd:rspconfig $$CN gateway= +check:output=~Error: Invalid parameter for option gateway check:rc!=0 end start:rspconfig_set_vlan_invalid despcription:rspconfig could not change openbmc gatway using invalid vlan Attribute: $$CN-The operation object of rspconfig command +os:Linux +hcp:openbmc cmd:rspconfig $$CN vlan=dddsdsdfs +check:output=~Error: VLAN must be configured with IP, netmask and gateway check:rc!=0 end start:rspconfig_set_all_invalid despcription:rspconfig could not change openbmc gatway using invalid vlan Attribute: $$CN-The operation object of rspconfig command +os:Linux +hcp:openbmc cmd:rspconfig $$CN ip=dsd gateway=ooo netmask=asfsf vlan=dddsdsdfs +check:output=~Error: Invalid parameter check:rc!=0 end start:rspconfig_node_invalid despcription:rspconfig could not do any action using invalid node +os:Linux +hcp:openbmc cmd:test=$(lsdef testnode);if [[ $? -eq 0 ]]; then lsdef -l testnode -z >/tmp/testnode.stanza ;rmdef testnode;fi check:rc==0 cmd:rspconfig testnode ip +check:output=~Error: Invalid nodes and/or groups in noderange check:rc!=0 cmd:if [[ -e /tmp/testnode.stanza ]]; then cat /tmp/testnode.stanza | chdef -z;rm -rf /tmp/testnode.stanza;fi check:rc==0 @@ -132,9 +177,12 @@ end start:rspconfig_noderange_invalid despcription:rspconfig could not do any action using invalid node +os:Linux +hcp:openbmc cmd:test=$(lsdef testnode);if [[ $? -eq 0 ]]; then lsdef -l testnode -z >/tmp/testnode.stanza ;rmdef testnode;fi check:rc==0 cmd:rspconfig testnode,$$CN ip +check:output=~Error: Invalid nodes check:rc!=0 cmd:if [[ -e /tmp/testnode.stanza ]]; then cat /tmp/testnode.stanza | chdef -z;rm -rf /tmp/testnode.stanza;fi check:rc==0 @@ -184,3 +232,156 @@ check:output=~$$CN: BMC Netmask: check:output=~__GETNODEATTR($$CN,bmc)__ end + +start:rspconfig_set_hostname_equal_star_with_bmc_is_ip +description:when bmc=, rspconfig hostname=* should throw out error +os:Linux +hcp:openbmc +#in automation environment, bmc is ip by default. +cmd:lsdef $$CN -i bmc -c +check:rc == 0 +cmd:rspconfig $$CN hostname=* +check:rc == 0 +check:output =~ Invalid OpenBMC Hostname +end + + +start:rspconfig_set_hostname_equal_star_with_bmc_is_hostname +description:when bmc=, rspconfig hostname=* should set bmc_hostname into bmc +os:Linux +hcp:openbmc +cmd:mkdir -p /tmp/rspconfig_set_hostname_equal_star_with_bmc_is_hostname +check:rc == 0 +cmd:lsdef $$CN -z > /tmp/rspconfig_set_hostname_equal_star_with_bmc_is_hostname/$$CN.stanza +check:rc == 0 +cmd:chdef -t node -o bogus_bmc_hostname groups=bmc ip=10.6.17.100 +check:rc == 0 +cmd:makehosts bogus_bmc_hostname +check:rc == 0 +cmd:chdef $$CN bmc=bogus_bmc_hostname +check:rc == 0 +cmd:lsdef $$CN -i bmc -c +check:rc == 0 +cmd:rspconfig $$CN hostname=* +check:rc == 0 +check:output =~$$CN: BMC hostname: bogus_bmc_hostname +cmd:makehosts -d bogus_bmc_hostname +check:rc == 0 +cmd:rmdef bogus_bmc_hostname +check:rc == 0 +cmd:rmdef $$CN +check:rc == 0 +cmd:cat /tmp/rspconfig_set_hostname_equal_star_with_bmc_is_hostname/$$CN.stanza |mkdef -z +check:rc == 0 +cmd:rm -rf /tmp/rspconfig_set_hostname_equal_star_with_bmc_is_hostname +check:rc == 0 +end + +start:rspconfig_get_hostname +description:To test get bmc hostname by rspconfig. +os:Linux +hcp:openbmc +cmd:mkdir -p /tmp/rspconfig_get_hostname +check:rc == 0 +cmd:rspconfig $$CN sshcfg +check:rc == 0 +cmd:ssh __GETNODEATTR($$CN,bmc)__ "hostname" | tee /tmp/rspconfig_get_hostname/working_hostname +check:rc == 0 +cmd:cat /tmp/rspconfig_get_hostname/working_hostname +check:rc == 0 +cmd:rspconfig $$CN hostname |tee /tmp/rspconfig_get_hostname/rspconfig_output +check:rc == 0 +cmd:awk -F':' '/BMC hostname/ {print $3}' /tmp/rspconfig_get_hostname/rspconfig_output |sed s/\\s//g > /tmp/rspconfig_get_hostname/rspconfig_get_hostname +check:rc == 0 +cmd:cat /tmp/rspconfig_get_hostname/rspconfig_get_hostname +cmd:diff /tmp/rspconfig_get_hostname/working_hostname /tmp/rspconfig_get_hostname/rspconfig_get_hostname +check:rc == 0 +cmd:rm -rf /tmp/rspconfig_get_hostname +check:rc == 0 +end + +start:rspconfig_hostname_with_error_input +description: To test with error input, should throw out error message +os:Linux +hcp:openbmc +cmd:rspconfig $$CN hostname bogus +check:output =~Error: Unsupported command +check:rc != 0 +cmd:rspconfig $$CN bogus hostname +check:output =~Error: Unsupported command +check:rc != 0 +cmd:rspconfig $$CN hostname= +check:output =~Error: Invalid parameter for option hostname +check:rc != 0 +end + +start:rspconfig_set_hostname +description:To test set bmc hostname by rspconfig +os:Linux +hcp:openbmc +cmd:mkdir -p /tmp/rspconfig_set_hostname +check:rc == 0 +cmd:rspconfig $$CN sshcfg +check:rc == 0 +cmd:ssh __GETNODEATTR($$CN,bmc)__ "hostname" | tee /tmp/rspconfig_set_hostname/working_hostname +check:rc == 0 +cmd:cat /tmp/rspconfig_set_hostname/working_hostname +check:rc == 0 +cmd:a=$(cat /tmp/rspconfig_set_hostname/working_hostname); rspconfig $$CN hostname=test_$a |tee /tmp/rspconfig_set_hostname/rspconfig_output +check:rc == 0 +cmd:awk -F':' '/BMC hostname/ {print $3}' /tmp/rspconfig_set_hostname/rspconfig_output |sed s/\\s//g > /tmp/rspconfig_set_hostname/rspconfig_get_hostname +check:rc == 0 +cmd:ssh __GETNODEATTR($$CN,bmc)__ "hostname" | tee /tmp/rspconfig_set_hostname/new_working_hostname +check:rc == 0 +cmd:diff /tmp/rspconfig_set_hostname/rspconfig_get_hostname /tmp/rspconfig_set_hostname/new_working_hostname +check:rc == 0 +cmd:diff /tmp/rspconfig_set_hostname/new_working_hostname /tmp/rspconfig_set_hostname/working_hostname +check:rc != 0 +cmd:a=test_$(cat /tmp/rspconfig_set_hostname/working_hostname);b=$(cat /tmp/rspconfig_set_hostname/new_working_hostname);echo "a=$a b=$b";if [ "$a" = "$b" ];then exit 0;else exit 1; fi +check:rc == 0 +cmd:rm -rf /tmp/rspconfig_set_hostname +check:rc == 0 +end + +start:rspconfig_set_admin_passwd_with_error_input +description: To test "rspconfig admin_passwd=xxx,yyy". If the format of "xxx,yyy" is wrong, should throw out error message +os:Linux +hcp:openbmc +cmd:rspconfig $$CN admin_passwd=cluster, +check:output =~Error: Invalid parameter for option admin_passwd +check:rc != 0 +cmd:rspconfig $$CN admin_passwd=,cluster +check:output =~Error: Invalid parameter for option admin_passwd +check:rc != 0 +cmd:rspconfig $$CN admin_passwd=, +check:output =~Error: Invalid parameter for option admin_passwd +check:rc != 0 +cmd:rspconfig $$CN admin_passwd= +check:output =~Error: Invalid parameter for option admin_passwd +check:rc != 0 +cmd:rspconfig $$CN admin_passwd=; +check:output =~Error: Invalid parameter for option admin_passwd +check:rc != 0 +end + +start:rspconfig_set_admin_passwd_with_error_origin_password +description: To test "rspconfig admin_passwd=xxx,yyy". If the original password is wrong, should throw out error message +os:Linux +hcp:openbmc +cmd:rspconfig $$CN admin_passwd=bogus__GETNODEATTR(f6u17,bmcpassword)__,cluster +check:output =~Current BMC password is incorrect +check:rc != 0 +end + +start:rspconfig_sshcfg_with_error_input +description: To test "rspconfig sshcfg" with error input, should throw out error message +os:Linux +hcp:openbmc +cmd:rspconfig $$CN sshcfg aaa +check:output =~Error: Configure sshcfg must be issued without other options. +check:rc != 0 +cmd:rspconfig $$CN hostname sshcfg +check:output =~Error: Configure sshcfg must be issued without other options. +check:rc != 0 +end +