From 0dce825785f062a15d634c73ea540c658f5fad23 Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 15 Jun 2017 02:32:32 -0400 Subject: [PATCH 1/3] Add testcases for simulator multiple --- .../autotest/testcase/simulator/change_ip.sh | 21 ------ .../testcase/simulator/clear_simulator | 20 +++++- .../testcase/simulator/config_simulator.sh | 58 +++++++++++++++ .../testcase/simulator/setup_simulator | 71 ++++++++++++++++++- 4 files changed, 147 insertions(+), 23 deletions(-) delete mode 100755 xCAT-test/autotest/testcase/simulator/change_ip.sh create mode 100755 xCAT-test/autotest/testcase/simulator/config_simulator.sh diff --git a/xCAT-test/autotest/testcase/simulator/change_ip.sh b/xCAT-test/autotest/testcase/simulator/change_ip.sh deleted file mode 100755 index 59fb80b0a..000000000 --- a/xCAT-test/autotest/testcase/simulator/change_ip.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -flag=$1 -mnhn=$2 -cnhn=$3 - -if [ $flag = "-s" ]; then - cnip=`lsdef $cnhn -i bmc -c | awk -F '=' '{print $2}'` - echo $cnip > "/tmp/simulator" - mnip=`ping $mnhn -c 1 | grep "64 bytes from" |awk -F'(' '{print $2}'|awk -F')' '{print $1}'` - chdef $cnhn bmc=$mnip -elif [ $flag = "-c" ]; then - cnip=`cat /tmp/simulator` - chdef $cnhn bmc=$cnip - process=`ps aux | grep "simulator" | grep "python" | awk -F ' ' '{print $2}'` - if [ $process ]; then - kill $process - fi - rm -rf "openbmc_simulator" -fi -exit $? diff --git a/xCAT-test/autotest/testcase/simulator/clear_simulator b/xCAT-test/autotest/testcase/simulator/clear_simulator index 61e2207c9..1c3df64c9 100644 --- a/xCAT-test/autotest/testcase/simulator/clear_simulator +++ b/xCAT-test/autotest/testcase/simulator/clear_simulator @@ -1,5 +1,23 @@ start:clear_openbmc_simulator description:clear evironment -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/change_ip.sh -c $$MN $$CN +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -c $$MN $$CN +check:rc==0 +end + +start:clear_openbmc_simulator_multiple_100 +description:clear evironment that simulate 100 OpenBMCs +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -c $$MN $$CN 100 +check:rc==0 +end + +start:clear_openbmc_simulator_multiple_1000 +description:clear evironment that simulate 1000 OpenBMCs +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -c $$MN $$CN 1000 +check:rc==0 +end + +start:clear_openbmc_simulator_multiple_5000 +description:clear evironment that simulate 5000 OpenBMCs +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -c $$MN $$CN 5000 check:rc==0 end diff --git a/xCAT-test/autotest/testcase/simulator/config_simulator.sh b/xCAT-test/autotest/testcase/simulator/config_simulator.sh new file mode 100755 index 000000000..6f9a1377f --- /dev/null +++ b/xCAT-test/autotest/testcase/simulator/config_simulator.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +flag=$1 +mnhn=$2 +cnhn=$3 +nodes=$4 + +mnip=`ping $mnhn -c 1 | grep "64 bytes from" |awk -F'(' '{print $2}'|awk -F')' '{print $1}'` +if [ $nodes ]; then + nic=`ip -4 -o a | grep $mnip | awk -F ' ' '{print $2}'` + + if [ $nodes = "1000" ]; then + range=`echo $(echo 10.100.{1..10}.{1..100})` + elif [ $nodes = "5000" ]; then + range=`echo $(echo 10.100.{1..50}.{1..100})` + else + range=`echo $(echo 10.100.{1..10}.{1..10})` + fi +fi + +if [ $flag = "-s" ]; then + if [ $nodes ]; then + lsdef $cnhn -z > /tmp/$cnhn.stanza + rmdef $cnhn + + /root/openbmc_simulator/simulator -n $nic -r $range + + if [ $nodes = "1000" ]; then + chdef -t group $cnhn mgt=openbmc bmc="|\D+(\d+)$|10.100.(1+((\$1)/100)).((\$1)%100+1)|" bmcusername=root bmcpassword=0penBmc + chdef simulator_test_[0-999] groups=$cnhn + elif [ $nodes = "5000" ]; then + chdef -t group $cnhn mgt=openbmc bmc="|\D+(\d+)$|10.100.(1+((\$1)/100)).((\$1)%100+1)|" bmcusername=root bmcpassword=0penBmc + chdef simulator_test_[0-4999] groups=$cnhn + else + chdef -t group $cnhn mgt=openbmc bmc="|\D+(\d+)$|10.100.(1+((\$1)/10)).((\$1)%10+1)|" bmcusername=root bmcpassword=0penBmc + chdef simulator_test_[0-99] groups=$cnhn + fi + else + cnip=`lsdef $cnhn -i bmc -c | awk -F '=' '{print $2}'` + echo $cnip > "/tmp/simulator" + mnip=`ping $mnhn -c 1 | grep "64 bytes from" |awk -F'(' '{print $2}'|awk -F')' '{print $1}'` + chdef $cnhn bmc=$mnip + /root/openbmc_simulator/simulator + fi +elif [ $flag = "-c" ]; then + if [ $nodes ]; then + /root/openbmc_simulator/simulator -c -n $nic -r $range + rmdef $cnhn + cat /tmp/$cnhn.stanza | mkdef -z + else + /root/openbmc_simulator/simulator -c + cnip=`cat /tmp/simulator` + chdef $cnhn bmc=$cnip + fi + + rm -rf /root/openbmc_simulator +fi +exit $? diff --git a/xCAT-test/autotest/testcase/simulator/setup_simulator b/xCAT-test/autotest/testcase/simulator/setup_simulator index 6a4bb71f6..e69f8c562 100644 --- a/xCAT-test/autotest/testcase/simulator/setup_simulator +++ b/xCAT-test/autotest/testcase/simulator/setup_simulator @@ -19,6 +19,75 @@ cmd:cd /root/ && git clone git@github.com:xuweibj/openbmc_simulator.git check:rc==0 cmd:/root/openbmc_simulator/simulator & check:rc==0 -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/change_ip.sh -s $$MN $$CN +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -s $$MN $$CN +check:rc==0 +end + +start:setup_openbmc_simulator_multiple_100 +description:install dependent packaages, setup and start 100 openbmc simulator +cmd:#!/bin/bash +os=`cat /etc/*release*` +if [[ "$os" =~ "Red Hat" ]] || [[ "$os" =~ "suse" ]]; then + yum install git -y + if [ $? != 0 ]; then + exit 1 + fi +elif [[ "$os" =~ "ubuntu" ]]; then + apt-get install git -y + if [ $? != 0 ]; then + exit 1 + fi +fi +exit 0 +check:rc==0 +cmd:cd /root/ && git clone git@github.com:xuweibj/openbmc_simulator.git +check:rc==0 +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -s $$MN $$CN 100 +check:rc==0 +end + +start:setup_openbmc_simulator_multiple_1000 +description:install dependent packaages, setup and start 1000 openbmc simulator +cmd:#!/bin/bash +os=`cat /etc/*release*` +if [[ "$os" =~ "Red Hat" ]] || [[ "$os" =~ "suse" ]]; then + yum install git -y + if [ $? != 0 ]; then + exit 1 + fi +elif [[ "$os" =~ "ubuntu" ]]; then + apt-get install git -y + if [ $? != 0 ]; then + exit 1 + fi +fi +exit 0 +check:rc==0 +cmd:cd /root/ && git clone git@github.com:xuweibj/openbmc_simulator.git +check:rc==0 +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -s $$MN $$CN 1000 +check:rc==0 +end + +start:setup_openbmc_simulator_multiple_5000 +description:install dependent packaages, setup and start 5000 openbmc simulator +cmd:#!/bin/bash +os=`cat /etc/*release*` +if [[ "$os" =~ "Red Hat" ]] || [[ "$os" =~ "suse" ]]; then + yum install git -y + if [ $? != 0 ]; then + exit 1 + fi +elif [[ "$os" =~ "ubuntu" ]]; then + apt-get install git -y + if [ $? != 0 ]; then + exit 1 + fi +fi +exit 0 +check:rc==0 +cmd:cd /root/ && git clone git@github.com:xuweibj/openbmc_simulator.git +check:rc==0 +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -s $$MN $$CN 5000 check:rc==0 end From a246b048c57c95f3a5725c55afbc42166f2c9d58 Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 15 Jun 2017 21:23:53 -0400 Subject: [PATCH 2/3] modified depending on comments --- .../testcase/simulator/clear_simulator | 6 +- .../testcase/simulator/config_simulator.sh | 42 ++++++---- .../testcase/simulator/setup_simulator | 76 +------------------ 3 files changed, 33 insertions(+), 91 deletions(-) diff --git a/xCAT-test/autotest/testcase/simulator/clear_simulator b/xCAT-test/autotest/testcase/simulator/clear_simulator index 1c3df64c9..03c442fd9 100644 --- a/xCAT-test/autotest/testcase/simulator/clear_simulator +++ b/xCAT-test/autotest/testcase/simulator/clear_simulator @@ -6,18 +6,18 @@ end start:clear_openbmc_simulator_multiple_100 description:clear evironment that simulate 100 OpenBMCs -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -c $$MN $$CN 100 +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -c $$MN $$CN $$bmcusername $$bmcpasswd 100 check:rc==0 end start:clear_openbmc_simulator_multiple_1000 description:clear evironment that simulate 1000 OpenBMCs -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -c $$MN $$CN 1000 +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -c $$MN $$CN $$bmcusername $$bmcpasswd 1000 check:rc==0 end start:clear_openbmc_simulator_multiple_5000 description:clear evironment that simulate 5000 OpenBMCs -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -c $$MN $$CN 5000 +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -c $$MN $$CN $$bmcusername $$bmcpasswd 5000 check:rc==0 end diff --git a/xCAT-test/autotest/testcase/simulator/config_simulator.sh b/xCAT-test/autotest/testcase/simulator/config_simulator.sh index 6f9a1377f..715d4cfd0 100755 --- a/xCAT-test/autotest/testcase/simulator/config_simulator.sh +++ b/xCAT-test/autotest/testcase/simulator/config_simulator.sh @@ -1,9 +1,11 @@ #!/bin/bash -flag=$1 -mnhn=$2 -cnhn=$3 -nodes=$4 +flag=$1 # -s:setup simulator -c:clear simulator env +mnhn=$2 # MN hostname +cnhn=$3 # CN hostname +username=$4 # bmcusername +password=$5 # bmcpassword +nodes=$6 # number of IPs want to config mnip=`ping $mnhn -c 1 | grep "64 bytes from" |awk -F'(' '{print $2}'|awk -F')' '{print $1}'` if [ $nodes ]; then @@ -14,27 +16,37 @@ if [ $nodes ]; then elif [ $nodes = "5000" ]; then range=`echo $(echo 10.100.{1..50}.{1..100})` else - range=`echo $(echo 10.100.{1..10}.{1..10})` + range=`echo $(echo 10.100.1.{1..100})` fi fi if [ $flag = "-s" ]; then + os=`cat /etc/*release*` + if [[ "$os" =~ "Red Hat" ]] || [[ "$os" =~ "suse" ]]; then + yum install git -y + if [ $? != 0 ]; then + echo "Install git Failed" + exit 1 + fi + elif [[ "$os" =~ "ubuntu" ]]; then + apt-get install git -y + if [ $? != 0 ]; then + echo "Install git Failed" + exit 1 + fi + fi + + cd /root/ && git clone git@github.com:xuweibj/openbmc_simulator.git + if [ $nodes ]; then lsdef $cnhn -z > /tmp/$cnhn.stanza rmdef $cnhn /root/openbmc_simulator/simulator -n $nic -r $range - if [ $nodes = "1000" ]; then - chdef -t group $cnhn mgt=openbmc bmc="|\D+(\d+)$|10.100.(1+((\$1)/100)).((\$1)%100+1)|" bmcusername=root bmcpassword=0penBmc - chdef simulator_test_[0-999] groups=$cnhn - elif [ $nodes = "5000" ]; then - chdef -t group $cnhn mgt=openbmc bmc="|\D+(\d+)$|10.100.(1+((\$1)/100)).((\$1)%100+1)|" bmcusername=root bmcpassword=0penBmc - chdef simulator_test_[0-4999] groups=$cnhn - else - chdef -t group $cnhn mgt=openbmc bmc="|\D+(\d+)$|10.100.(1+((\$1)/10)).((\$1)%10+1)|" bmcusername=root bmcpassword=0penBmc - chdef simulator_test_[0-99] groups=$cnhn - fi + node_end=$[nodes-1] + chdef -t group $cnhn mgt=openbmc bmc="|\D+(\d+)$|10.100.(1+((\$1)/100)).((\$1)%100+1)|" bmcusername=$username bmcpassword=$password + chdef simulator_test_[0-$node_end] groups=$cnhn # use CN hostname as group, so when run command against CN will rpower against all nodes added here else cnip=`lsdef $cnhn -i bmc -c | awk -F '=' '{print $2}'` echo $cnip > "/tmp/simulator" diff --git a/xCAT-test/autotest/testcase/simulator/setup_simulator b/xCAT-test/autotest/testcase/simulator/setup_simulator index e69f8c562..8ab412829 100644 --- a/xCAT-test/autotest/testcase/simulator/setup_simulator +++ b/xCAT-test/autotest/testcase/simulator/setup_simulator @@ -1,93 +1,23 @@ start:setup_openbmc_simulator description:install dependent packaages, setup and start openbmc simulator -cmd:#!/bin/bash -os=`cat /etc/*release*` -if [[ "$os" =~ "Red Hat" ]] || [[ "$os" =~ "suse" ]]; then - yum install git -y - if [ $? != 0 ]; then - exit 1 - fi -elif [[ "$os" =~ "ubuntu" ]]; then - apt-get install git -y - if [ $? != 0 ]; then - exit 1 - fi -fi -exit 0 -check:rc==0 -cmd:cd /root/ && git clone git@github.com:xuweibj/openbmc_simulator.git -check:rc==0 -cmd:/root/openbmc_simulator/simulator & -check:rc==0 cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -s $$MN $$CN check:rc==0 end start:setup_openbmc_simulator_multiple_100 description:install dependent packaages, setup and start 100 openbmc simulator -cmd:#!/bin/bash -os=`cat /etc/*release*` -if [[ "$os" =~ "Red Hat" ]] || [[ "$os" =~ "suse" ]]; then - yum install git -y - if [ $? != 0 ]; then - exit 1 - fi -elif [[ "$os" =~ "ubuntu" ]]; then - apt-get install git -y - if [ $? != 0 ]; then - exit 1 - fi -fi -exit 0 -check:rc==0 -cmd:cd /root/ && git clone git@github.com:xuweibj/openbmc_simulator.git -check:rc==0 -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -s $$MN $$CN 100 +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -s $$MN $$CN $$bmcusername $$bmcpasswd 100 check:rc==0 end start:setup_openbmc_simulator_multiple_1000 description:install dependent packaages, setup and start 1000 openbmc simulator -cmd:#!/bin/bash -os=`cat /etc/*release*` -if [[ "$os" =~ "Red Hat" ]] || [[ "$os" =~ "suse" ]]; then - yum install git -y - if [ $? != 0 ]; then - exit 1 - fi -elif [[ "$os" =~ "ubuntu" ]]; then - apt-get install git -y - if [ $? != 0 ]; then - exit 1 - fi -fi -exit 0 -check:rc==0 -cmd:cd /root/ && git clone git@github.com:xuweibj/openbmc_simulator.git -check:rc==0 -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -s $$MN $$CN 1000 +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -s $$MN $$CN $$bmcusername $$bmcpasswd 1000 check:rc==0 end start:setup_openbmc_simulator_multiple_5000 description:install dependent packaages, setup and start 5000 openbmc simulator -cmd:#!/bin/bash -os=`cat /etc/*release*` -if [[ "$os" =~ "Red Hat" ]] || [[ "$os" =~ "suse" ]]; then - yum install git -y - if [ $? != 0 ]; then - exit 1 - fi -elif [[ "$os" =~ "ubuntu" ]]; then - apt-get install git -y - if [ $? != 0 ]; then - exit 1 - fi -fi -exit 0 -check:rc==0 -cmd:cd /root/ && git clone git@github.com:xuweibj/openbmc_simulator.git -check:rc==0 -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -s $$MN $$CN 5000 +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/simulator/config_simulator.sh -s $$MN $$CN $$bmcusername $$bmcpasswd 5000 check:rc==0 end From a8ee4aaee8b59d03072f1d36c7d625255f112b19 Mon Sep 17 00:00:00 2001 From: XuWei Date: Fri, 16 Jun 2017 01:30:02 -0400 Subject: [PATCH 3/3] modified depending on comments --- .../testcase/simulator/config_simulator.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/xCAT-test/autotest/testcase/simulator/config_simulator.sh b/xCAT-test/autotest/testcase/simulator/config_simulator.sh index 715d4cfd0..80860227a 100755 --- a/xCAT-test/autotest/testcase/simulator/config_simulator.sh +++ b/xCAT-test/autotest/testcase/simulator/config_simulator.sh @@ -7,17 +7,21 @@ username=$4 # bmcusername password=$5 # bmcpassword nodes=$6 # number of IPs want to config +if [ $nodes -gt 10000 ]; then + echo "Unsupported number of nodes: $nodes" + exit 1 +fi + mnip=`ping $mnhn -c 1 | grep "64 bytes from" |awk -F'(' '{print $2}'|awk -F')' '{print $1}'` if [ $nodes ]; then nic=`ip -4 -o a | grep $mnip | awk -F ' ' '{print $2}'` - if [ $nodes = "1000" ]; then - range=`echo $(echo 10.100.{1..10}.{1..100})` - elif [ $nodes = "5000" ]; then - range=`echo $(echo 10.100.{1..50}.{1..100})` - else - range=`echo $(echo 10.100.1.{1..100})` + ((a=$nodes/100)) + ((b=$nodes%100)) + if [ $b -eq 0 ]; then + b=100 fi + range=`for((i=1;i<=$a;i++)); do for((m=1;m<=$b;m++)); do echo -n "10.100.$i.$m ";done; done` fi if [ $flag = "-s" ]; then