start:go_xcat_update_case1
description:test go_xcat with the option update
label:others,go_xcat
os:Linux
cmd:if xdsh $$CN "zypper -h"; then  xdsh $$CN "zypper remove -y *xCAT*"; elif xdsh $$CN "yum -h";then xdsh $$CN  "yum remove -y *xCAT*"; elif xdsh $$CN "apt-get -h";then xdsh $$CN "apt-get purge perl-xcat xcat-client xcat-server xcat -y"; else echo "Sorry,this is not supported os"; fi
cmd:if grep Ubuntu /etc/*release;then xdsh $$CN "dpkg -l |grep -i perl-xcat";else xdsh $$CN "rpm -qa |grep -i perl-xcat";fi
check:rc!=0
cmd:if xdsh $$CN "grep \"Red Hat\" /etc/*release >/dev/null"; then xdsh $$CN "yum install -y yum-utils bzip2"; fi
check:rc==0
cmd:xdsh $$CN "cd /; rm -rf /xcat-core* /xcat-dep* /go-xcat"
check:rc==0
cmd:xdsh $$CN "cd /; scp -r $$MN:/opt/xcat/share/xcat/tools/go-xcat ./"
check:rc==0
cmd:xdsh $$CN "cd /; scp -r $$MN:/core-*-snap.tar.bz2 /xcat-core.tar.bz2"
check:rc==0
cmd:xdsh $$CN "cd /; scp -r $$MN:/xcat-dep*.tar.bz2 /xcat-dep.tar.bz2"
check:rc==0
cmd:if grep Ubuntu /etc/*release;then code=`lsb_release -sc` && xdsh $$CN "scp -r $$MN:/opt/xcat/share/xcat/tools/autotest/testcase/go_xcat/$code-__GETNODEATTR($$CN,arch)__.sources.list /etc/apt/sources.list"; fi
cmd:if grep Ubuntu /etc/*release;then xdsh $$CN "scp -r $$MN:/etc/hosts /etc/hosts" && xdsh $$CN "scp -r $$MN:/etc/resolv.conf /etc/resolv.conf" && xdsh $$CN "wget -O - http://xcat.org/files/xcat/repos/apt/apt.key | apt-key add -"; fi
check:rc==0
cmd:if grep Ubuntu /etc/*release;then xdsh $$CN "rm -rf /var/lib/apt/lists/* && apt-get clean && apt-get update"; fi
check:rc==0
cmd:if grep Ubuntu /etc/*release;then xdsh $$CN "cd /; ./go-xcat  --xcat-core=$$UBUNTU_MIGRATION2_CORE --xcat-dep=$$UBUNTU_MIGRATION2_DEP -y install";else xdsh $$CN "cd /; ./go-xcat  -x $$MIGRATION1_VERSION -y install";fi
check:rc==0
cmd:xdsh $$CN "source /etc/profile.d/xcat.sh;lsxcatd -v"
check:rc==0
cmd:xdsh $$CN "lsxcatd -v"
check:rc==0
check:output=~Version $$MIGRATION1_VERSION
cmd:xdsh $$CN "rm -rf /tmp/go-xcat.log"
cmd:xdsh $$CN "cd /; ./go-xcat update -y"
check:rc==0
cmd:xdsh $$CN "cat /tmp/go-xcat.log"
check:output=~xCAT has been successfully updated
cmd:xdsh $$CN "source /etc/profile.d/xcat.sh;lsxcatd -v"
check:rc==0
cmd:xdsh $$CN "service xcatd status"
check:rc==0
check:output=~running
cmd:xdsh $$CN "service xcatd stop"
cmd:if grep SUSE /etc/*release;then xdsh $$CN "zypper remove -y *xCAT*" && xdsh $$CN "rm -rf /etc/zypp/repos.d/xCAT-*.repo"; elif grep "Red Hat" /etc/*release;then xdsh $$CN  "yum remove -y *xCAT*" && xdsh $$CN "rm -rf /etc/yum.repos.d/xCAT-*.repo"; elif grep Ubuntu /etc/*release;then xdsh $$CN "apt-get purge perl-xcat xcat-client xcat-server xcat -y" && xdsh $$CN "rm -rf /etc/apt/sources.list.d/xcat-*.list"; fi
check:rc==0
cmd:if grep Ubuntu /etc/*release;then xdsh $$CN "dpkg -l |grep -i perl-xcat";else xdsh $$CN "rpm -qa|grep -i perl-xcat";fi
check:rc!=0
cmd:xdsh $$CN "cd /; rm -rf /xcat-core* /xcat-dep* /go-xcat"
end

