start:makehosts_h
description:makehosts -h
cmd:makehosts -h
check:rc==0
check:output=~Usage
end

start:makehosts_help
description:makehosts --help
cmd:makehosts --help
check:rc==0
check:output=~Usage
end

start:makehosts_null
description:makehosts 
cmd:cp -f /etc/hosts /etc/hosts.xcatbakautotest
cmd:chtab node=nouse_compute hosts.ip="|node(\d+)|1.2.3.(\$1+0)|" hosts.hostnames="|(.*)|(\$1).cluster.net|"
check:rc==0
cmd:mkdef -t node -o node01,node02 groups="nouse_compute"
check:rc==0
cmd:sleep 30
cmd:XCATBYPASS=1 makehosts 
check:rc==0
cmd:sleep 30
cmd:cat /etc/hosts
check:output=~1.2.3.2 
check:output=~1.2.3.1 
check:output=~node01
check:output=~node02
cmd:chtab -d node=nouse_compute hosts
cmd:rmdef node01
cmd:rmdef node02
cmd:mv -f /etc/hosts.xcatbakautotest /etc/hosts
end

start:makehosts_l
cmd:cp -f /etc/hosts /etc/hosts.xcatbakautotest
cmd:chtab node=nouse_compute hosts.ip="|node(\d+)|1.2.3.(\$1+0)|" hosts.hostnames="|(.*)|(\$1).cluster.net|"
check:rc==0
cmd:chdef -t node -o node01,node02 groups="nouse_compute"
check:rc==0
cmd:sleep 30
cmd:XCATBYPASS=1 makehosts -l
check:rc==0
cmd:sleep 30
cmd:cp -f /etc/hosts /tmp/hosts
cmd:cat /tmp/hosts|awk '{print $2}'
check:output=~node01.cluster.net
check:output=~node02.cluster.net
cmd:chtab -d node=nouse_compute hosts
cmd:rmdef node01
cmd:rmdef node02
cmd:mv -f /etc/hosts.xcatbakautotest /etc/hosts
cmd:rm -rf /tmp/hosts
end

start:makehosts_d
cmd:cp -f /etc/hosts /etc/hosts.xcatbakautotest
cmd:chtab node=compute hosts.ip="|node(\d+)|1.2.3.(\$1+0)|" hosts.hostnames="|(.*)|(\$1).cluster.net|"
check:rc==0
cmd:chdef -t node -o node01 groups="compute"
check:rc==0
cmd:sleep 30
cmd:makehosts node01 
check:rc==0
cmd:cat /etc/hosts > /tmp/1
cmd:sleep 30
cmd:XCATBYPASS=1 makehosts -d node01
check:rc==0
cmd:cat /etc/hosts > /tmp/2
cmd:diff /tmp/1 /tmp/2
check:output=~node01.cluster.net
cmd:chtab -d node=compute hosts
cmd:rmdef node01
cmd:mv -f /etc/hosts.xcatbakautotest /etc/hosts
cmd:rm -f /tmp/1 /tmp/2
end

start:makehosts_n
cmd:cp -f /etc/hosts /etc/hosts.xcatbakautotest
cmd:chtab node=nouse_compute hosts.ip="|node(\d+)|1.2.3.(\$1+0)|" hosts.hostnames="|(.*)|(\$1).cluster.net|"
check:rc==0
cmd:chdef -t node -o node01 groups="nouse_compute"
check:rc==0
cmd:sleep 30
cmd:XCATBYPASS=1 makehosts -n
check:rc==0
cmd:sleep 30
cmd:cat /etc/hosts
cmd:sleep 30
cmd:cp -f /etc/hosts /tmp/hosts
cmd:cat /tmp/hosts |wc -l
check:rc==0
cmd:cat /tmp/hosts
check:output=~node01.cluster.net
cmd:chtab -d node=nouse_compute hosts
cmd:rmdef node01
cmd:cp /etc/hosts /hosts
cmd:mv -f /etc/hosts.xcatbakautotest /etc/hosts
cmd:rm -rf /tmp/hosts
end

start:makehosts_n_noderange
cmd:cp -f /etc/hosts /etc/hosts.xcatbakautotest
cmd:chtab node=compute hosts.ip="|node(\d+)|1.2.3.(\$1+0)|" hosts.hostnames="|(.*)|(\$1).cluster.net|"
check:rc==0
cmd:chdef -t node -o node01 groups="compute"
check:rc==0
cmd:sleep 30
cmd:XCATBYPASS=1 makehosts -n node01
check:rc==0
cmd:sleep 30
cmd:cp /etc/hosts /tmp/hosts -f
cmd:cat /tmp/hosts |wc -l
check:rc==0
check:output==2
cmd:cat /tmp/hosts
check:output=~node01.cluster.net
cmd:chtab -d node=compute hosts
cmd:rmdef node01
cmd:mv -f /etc/hosts.xcatbakautotest /etc/hosts
cmd:cat /etc/hosts| grep -v node01 > /tmp/1
cmd:mv -f /tmp/1 /etc/hosts 
cmd:rm -rf /tmp/hosts
end

start:makehost_n_r
descriptions:modify makehosts testcases according to special node name eg:s01 and s01r* . for issue #2717 and #2683
cmd:cp -f /etc/hosts /etc/hosts.xcatbakautotest
cmd:lsdef s01;if [ $? -eq 0 ]; then lsdef -l s01 -z >/tmp/s01.standa ;rmdef s01;fi
check:rc==0
cmd:lsdef s01r1b01;if [ $? -eq 0 ]; then lsdef -l s01r1b01 -z >/tmp/s01r1b01.standa ;rmdef s01r1b01;fi
check:rc==0
cmd:nodeadd s01 groups=service; chdef s01 ip=70.2.0.254;nodeadd s01r1b01 groups=compute; chdef s01r1b01 ip=80.2.0.254;makehosts
check:rc==0
cmd:a=0;while true; do [ $a -eq 60 ] && exit 1;rc=`cat /etc/hosts`;if [[ $rc =~ "70.2.0.254 s01" ]] && [[ $rc =~ "80.2.0.254 s01r1b01" ]];then exit 0;else a=$[$a+1];sleep 1;echo $a;fi;done
check:rc==0
cmd:makehosts s01
check:rc==0
cmd:cat /etc/hosts
cmd:a=0;while true; do [ $a -eq 60 ] && exit 1;rc=`cat /etc/hosts`;if [[ $rc =~ "70.2.0.254 s01" ]] && [[ $rc =~ "80.2.0.254 s01r1b01" ]];then exit 0;else a=$[$a+1];sleep 1;echo $a;fi;done
check:rc==0
cmd:makehosts service
check:rc==0
cmd:a=0;while true; do [ $a -eq 60 ] && exit 1;rc=`cat /etc/hosts`;if [[ $rc =~ "70.2.0.254 s01" ]] && [[ $rc =~ "80.2.0.254 s01r1b01" ]];then exit 0;else a=$[$a+1];sleep 1;echo $a;fi;done
check:rc==0
cmd:cat /etc/hosts
cmd:makehosts -d s01
check:rc==0
cmd:a=0;while true; do [ $a -eq 60 ] && exit 1;rc=`cat /etc/hosts`;if !([[  $rc =~ "70.2.0.254 s01"  ]]) && [[  $rc =~ "80.2.0.254 s01r1b01" ]];then exit 0;else a=$[$a+1];sleep 1;echo $a;fi;done
check:rc==0
cmd:cat /etc/hosts
cmd:makehosts
check:rc==0
cmd:makehosts -d service 
check:rc==0
cmd:a=0;while true; do [ $a -eq 60 ] && exit 1;rc=`cat /etc/hosts`;if !([[  $rc =~ "70.2.0.254 s01"  ]]) && [[  $rc =~ "80.2.0.254 s01r1b01" ]];then exit 0;else a=$[$a+1];sleep 1;echo $a;fi;done
check:rc==0
cmd:cat /etc/hosts
cmd:makehosts
check:rc==0
cmd:makehosts -d s01r1b01
check:rc==0
cmd:a=0;while true; do [ $a -eq 60 ] && exit 1;rc=`cat /etc/hosts`;if [[  $rc =~ "70.2.0.254 s01"  ]] && !([[  $rc =~ "80.2.0.254 s01r1b01" ]]);then exit 0;else a=$[$a+1];sleep 1;echo $a;fi;done
check:rc==0
cmd:cat /etc/hosts
cmd:if [ -e /tmp/s01.standa ]; then rmdef s01; cat /tmp/s01.standa | mkdef -z; rm -rf /tmp/s01.standa; else rmdef s01;fi
check:rc==0
cmd:if [ -e /tmp/s01r1b01.standa ]; then rmdef s01r1b01; cat /tmp/s01r1b01.standa | mkdef -z; rm -rf /tmp/s01r1b01.standa;else rmdef s01r1b01; fi
check:rc==0
cmd:mv -f /etc/hosts.xcatbakautotest /etc/hosts
end
