From 5499f716a022845878d1d8832c926f1d61b1290d Mon Sep 17 00:00:00 2001 From: litingt Date: Tue, 7 May 2019 03:34:21 -0400 Subject: [PATCH 1/3] update to add more debug information in case rpower_wrongpasswd --- xCAT-test/autotest/testcase/rpower/rpower_wrongpasswd_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-test/autotest/testcase/rpower/rpower_wrongpasswd_test.sh b/xCAT-test/autotest/testcase/rpower/rpower_wrongpasswd_test.sh index 45b1b1891..766de4673 100755 --- a/xCAT-test/autotest/testcase/rpower/rpower_wrongpasswd_test.sh +++ b/xCAT-test/autotest/testcase/rpower/rpower_wrongpasswd_test.sh @@ -59,6 +59,7 @@ value=""; if [[ $output =~ $value ]];then return 0; else + echo "The expected output is \"$value\" since there password is wrong, but the real output is $output" return 1; fi } From 829a66801a5b6308ad34cc1dce20cae50e53c5ff Mon Sep 17 00:00:00 2001 From: litingt Date: Fri, 10 May 2019 04:29:19 -0400 Subject: [PATCH 2/3] update to add more debug information --- .../rpower/rpower_wrongpasswd_test.sh | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/xCAT-test/autotest/testcase/rpower/rpower_wrongpasswd_test.sh b/xCAT-test/autotest/testcase/rpower/rpower_wrongpasswd_test.sh index 766de4673..e445222ea 100755 --- a/xCAT-test/autotest/testcase/rpower/rpower_wrongpasswd_test.sh +++ b/xCAT-test/autotest/testcase/rpower/rpower_wrongpasswd_test.sh @@ -10,32 +10,41 @@ tabdump passwd |grep $MGT function modify_passwd_table(){ Username=`cat $TMPFILE |awk -F "\"" '{print $4}'`; Passwd=`cat $TMPFILE |awk -F "\"" '{print $6}'`; +echo "Execute \"chtab key=$MGT passwd.password=$Passwd.wrong passwd.username=$Username\"" `chtab key=$MGT passwd.password=$Passwd.wrong passwd.username=$Username`; +echo "The password table is\n"; tabdump passwd; } function add_passwd_table() { `chtab key=$MGT passwd.password=$2 passwd.username=$3`; +echo "Execute \"rpower $1 stat\""; rpower $1 stat if [ $? -eq 0 ];then + echo "Execute \"chtab key=$MGT passwd.password=$2.wrong passwd.username=$3\"" `chtab key=$MGT passwd.password=$2.wrong passwd.username=$3`; + echo "Execute \"tabdump passwd\""; tabdump passwd; else - echo "wrong password"; + echo "rpower $1 stat failed.Wrong password is provided, please check bmc username and password"; fi } function modify_node_definition() { chdef $1 bmcpassword=$2 bmcusername=$3 +echo "Execute \"rpower $1 stat\""; rpower $1 stat if [ $? -eq 0 ];then + echo "Execute \"chdef $1 bmcpassword=$2.wrong bmcusername=$3\"" chdef $1 bmcpassword=$2.wrong bmcusername=$3; + echo "Execute \"tabdump passwd\""; tabdump passwd; else - echo "wrong password"; + echo "rpower $1 stat failed.Wrong password is provided, please check bmc username and password"; fi } function clear_env(){ + echo "Restore test environment..."; if [ -f $TMPFILE ];then Username=`cat $TMPFILE |awk -F "\"" '{print $4}'`; Passwd=`cat $TMPFILE |awk -F "\"" '{print $6}'`; @@ -49,7 +58,7 @@ function clear_env(){ } function check_result(){ output=$(rpower $1 stat 2>&1) -echo output is $output +echo "Execute command \"rpower $1 stat\"" value=""; if [[ `lsdef $1 |grep mgt ` =~ "ipmi" ]];then value="Incorrect password provided"; @@ -63,20 +72,17 @@ value=""; return 1; fi } -echo "0 ARG: $0" SCRIPT=$(readlink -f $0) -echo "SCRIPT=$SCRIPT" TMPFILE="/tmp/xcat-test-`basename $SCRIPT`.tmp" -echo "TMPFILE=$TMPFILE" MGT="" if [[ `lsdef $2 |grep mgt` =~ "ipmi" ]];then MGT="ipmi"; else MGT="openbmc"; fi -echo mgt is $MGT +echo "The node's mgt is defined as $MGT" while [ "$#" -gt "0" ] do case $1 in @@ -134,4 +140,3 @@ do esac done - From 1632353dad1fd6a0869bfebd251cd52e232441d8 Mon Sep 17 00:00:00 2001 From: litingt Date: Thu, 16 May 2019 02:04:29 -0400 Subject: [PATCH 3/3] update to give detailed log information --- .../rpower/rpower_wrongpasswd_test.sh | 82 ++++++++++++------- 1 file changed, 54 insertions(+), 28 deletions(-) diff --git a/xCAT-test/autotest/testcase/rpower/rpower_wrongpasswd_test.sh b/xCAT-test/autotest/testcase/rpower/rpower_wrongpasswd_test.sh index e445222ea..a20d53dcb 100755 --- a/xCAT-test/autotest/testcase/rpower/rpower_wrongpasswd_test.sh +++ b/xCAT-test/autotest/testcase/rpower/rpower_wrongpasswd_test.sh @@ -1,64 +1,88 @@ #!/bin/bash +PATH="/opt/xcat/bin:/opt/xcat/sbin:/opt/xcat/share/xcat/tools:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin" +export PATH + +function runcmd(){ + echo "Run command $*" + result=`$*` + if [[ $? -eq 0 ]];then + echo $result; + echo "Run command $*....[Succeed]\n"; + return 0; + else + echo $result; + echo "Run command $*... [Failed]\n"; + return 1; + fi +} + function check_passwd_table(){ +echo "Run tabdump passwd to check if password with $MGT exists" tabdump passwd |grep $MGT if [ $? -eq 0 ];then `tabdump passwd |grep $MGT>$TMPFILE` else + echo "There is no password in passwd table associated with $MGT" return 1; fi } function modify_passwd_table(){ Username=`cat $TMPFILE |awk -F "\"" '{print $4}'`; Passwd=`cat $TMPFILE |awk -F "\"" '{print $6}'`; -echo "Execute \"chtab key=$MGT passwd.password=$Passwd.wrong passwd.username=$Username\"" -`chtab key=$MGT passwd.password=$Passwd.wrong passwd.username=$Username`; -echo "The password table is\n"; -tabdump passwd; +cmd="chtab key=$MGT passwd.password=$Passwd.wrong passwd.username=$Username"; +runcmd $cmd; +cmd="tabdump passwd"; +runcmd $cmd; } function add_passwd_table() { -`chtab key=$MGT passwd.password=$2 passwd.username=$3`; -echo "Execute \"rpower $1 stat\""; -rpower $1 stat +cmd="chtab key=$MGT passwd.password=$2 passwd.username=$3"; +runcmd $cmd; +cmd="rpower $1 stat"; +runcmd $cmd; if [ $? -eq 0 ];then - echo "Execute \"chtab key=$MGT passwd.password=$2.wrong passwd.username=$3\"" - `chtab key=$MGT passwd.password=$2.wrong passwd.username=$3`; - echo "Execute \"tabdump passwd\""; - tabdump passwd; + cmd="chtab key=$MGT passwd.password=$2.wrong passwd.username=$3"; + runcmd $cmd; + cmd="tabdump passwd"; + runcmd $cmd; else echo "rpower $1 stat failed.Wrong password is provided, please check bmc username and password"; fi } function modify_node_definition() { -chdef $1 bmcpassword=$2 bmcusername=$3 -echo "Execute \"rpower $1 stat\""; -rpower $1 stat +cmd="chdef $1 bmcpassword=$2 bmcusername=$3"; +runcmd $cmd; +cmd="rpower $1 stat"; +runcmd $cmd; if [ $? -eq 0 ];then - echo "Execute \"chdef $1 bmcpassword=$2.wrong bmcusername=$3\"" - chdef $1 bmcpassword=$2.wrong bmcusername=$3; - echo "Execute \"tabdump passwd\""; - tabdump passwd; + runcmd "chdef $1 bmcpassword=$2.wrong bmcusername=$3"; + runcmd "tabdump passwd"; else - echo "rpower $1 stat failed.Wrong password is provided, please check bmc username and password"; + echo "rpower $1 stat failed.Wrong password is provided, please check bmc username and password"; fi } function clear_env(){ - echo "Restore test environment..."; if [ -f $TMPFILE ];then Username=`cat $TMPFILE |awk -F "\"" '{print $4}'`; Passwd=`cat $TMPFILE |awk -F "\"" '{print $6}'`; - chtab key=$MGT passwd.password=$Passwd passwd.username=$Username;tabdump passwd; - chdef $1 bmcpassword= bmcusername=; + cmd="chtab key=$MGT passwd.password=$Passwd passwd.username=$Username"; + runcmd $cmd; + cmd="tabdump passwd"; + runcmd $cmd; + cmd="chdef $1 bmcpassword= bmcusername="; + runcmd $cmd; rm -rf $TMPFILE; else - `chtab -d key=$MGT passwd`; - chdef $1 bmcpassword= bmcusername=; + cmd="chtab -d key=$MGT passwd"; + runcmd $cmd; + cmd="chdef $1 bmcpassword= bmcusername="; + runcmd $cmd; fi } function check_result(){ output=$(rpower $1 stat 2>&1) -echo "Execute command \"rpower $1 stat\"" +echo "rpower $1 stat output is $output" value=""; if [[ `lsdef $1 |grep mgt ` =~ "ipmi" ]];then value="Incorrect password provided"; @@ -68,7 +92,7 @@ value=""; if [[ $output =~ $value ]];then return 0; else - echo "The expected output is \"$value\" since there password is wrong, but the real output is $output" + echo "The expected output is \"$value\" since there password is wrong, but the real output is $output" return 1; fi } @@ -82,7 +106,7 @@ MGT="" else MGT="openbmc"; fi -echo "The node's mgt is defined as $MGT" +echo "The node $2's mgt is defined as $MGT" while [ "$#" -gt "0" ] do case $1 in @@ -110,7 +134,8 @@ do "-apt"|"--addpasswdtable" ) check_passwd_table if [[ $? -eq 0 ]];then - `chtab -d key=ipmi passwd`; + cmd="chtab -d key=ipmi passwd"; + runcmd $cmd; if [[ $? -eq 1 ]];then exit 1 fi @@ -140,3 +165,4 @@ do esac done +