From e2939f6605e00f7de36661cc97f3cb4e3af59a44 Mon Sep 17 00:00:00 2001 From: litingt Date: Fri, 11 Jan 2019 02:53:29 -0500 Subject: [PATCH] implement a script to achieve retry mechanism against rinstall --- .../testcase/commoncmd/retry_install.sh | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 xCAT-test/autotest/testcase/commoncmd/retry_install.sh diff --git a/xCAT-test/autotest/testcase/commoncmd/retry_install.sh b/xCAT-test/autotest/testcase/commoncmd/retry_install.sh new file mode 100755 index 000000000..176236dc2 --- /dev/null +++ b/xCAT-test/autotest/testcase/commoncmd/retry_install.sh @@ -0,0 +1,60 @@ +#!/bin/bash +echo "Try to retry rinstall 5 times ......" + +declare -i installsuccess=0 +declare -i a=0 +declare -i tryreinstall=1 +node=$1 +osimage=$2 + +for (( tryreinstall = 1 ; tryreinstall < 6 ; ++tryreinstall )) +do + echo "Try to install $node on the $tryreinstall time..." + + echo "rinstall $node osimage=$osimage" + rinstall $node osimage=$osimage + if [ $? != 0 ];then + echo "rinstall failed, double check xcat command rinstall to see if it is a bug..." + exit 1 + fi + + #sleep while for installation. + sleep 360 + while [ ! `lsdef -l $node|grep status|grep booted` ] + do + sleep 10 + echo "The status is not booted..." + a=++a + if [ $a -gt 400 ];then + a=0 + break + fi + done + + lsdef -l $node|grep status|grep booted + tobooted=$? + echo "The tobooted is $tobooted" + + ping -c 2 $node + pingable=$? + echo "The pingable is $pingable" + + xdsh $node date + canruncmd=$? + echo "The canruncmd is $canruncmd" + + if [[ $canruncmd -eq 0 && $tobooted -eq 0 && $pingable -eq 0 ]];then + echo "The provision succeed on the $tryreinstall time....." + installsuccess=1 + break + fi + +done + +if [ $installsuccess -eq 1 ];then + echo "The provision succeed......" + exit 0 +else + echo "The provision failed......" + exit 1 +fi