From 68ffc340dddc01e138799531b1d5fb4c84e81263 Mon Sep 17 00:00:00 2001 From: litingt Date: Sun, 18 Nov 2018 21:12:36 -0500 Subject: [PATCH 1/7] add http port change case, do task 339 --- xCAT-test/autotest/testcase/httpport/cases0 | 29 +++++++++++++++++++ .../testcase/httpport/change_http_port.sh | 24 +++++++++++++++ .../testcase/httpport/check_wget_files.sh | 25 ++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 xCAT-test/autotest/testcase/httpport/cases0 create mode 100755 xCAT-test/autotest/testcase/httpport/change_http_port.sh create mode 100755 xCAT-test/autotest/testcase/httpport/check_wget_files.sh diff --git a/xCAT-test/autotest/testcase/httpport/cases0 b/xCAT-test/autotest/testcase/httpport/cases0 new file mode 100644 index 000000000..8030ed03c --- /dev/null +++ b/xCAT-test/autotest/testcase/httpport/cases0 @@ -0,0 +1,29 @@ +start:http_port_change +description:Add test cases for bug fix 2629, change http port and then generate genesis (mknb). +label:others +cmd:netstat -nlp|grep -E "apache2|httpd" +check:output =~ 80 +cmd:lsdef -t site -i httpport -c |awk -F"=" '{print $2}' +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/httpport/change_http_port.sh 80 8898 +cmd:netstat -nlp|grep -E "apache2|httpd" +check:output =~ 8898 +check:rc==0 +cmd:chdef -t site httpport=8898 +check:rc==0 +cmd:lsdef -t site -i httpport -c +check:output =~ 8898 +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64le" ]]; then arch=ppc64; else arch=__GETNODEATTR($$CN,arch)__;fi; mknb $arch +check:rc==0 +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/httpport/check_wget_files.sh /tftpboot/pxelinux.cfg/p/ +check:rc==0 +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/httpport/change_http_port.sh 8898 80 +cmd:netstat -nlp|grep -E "apache2|httpd" +check:output =~ 80 +check:rc==0 +cmd:chdef -t site httpport=80 +check:rc==0 +cmd:lsdef -t site -i httpport -c +check:output =~ 80 +check:rc==0 +end diff --git a/xCAT-test/autotest/testcase/httpport/change_http_port.sh b/xCAT-test/autotest/testcase/httpport/change_http_port.sh new file mode 100755 index 000000000..f3b665d6e --- /dev/null +++ b/xCAT-test/autotest/testcase/httpport/change_http_port.sh @@ -0,0 +1,24 @@ +#!/bin/bash +if [ -f "/etc/httpd/conf/httpd.conf" ]; then + config="/etc/httpd/conf/httpd.conf" +elif [ -f "/etc/apache2/ports.conf" ]; then + config="/etc/apache2/ports.conf" +elif [ -f "/etc/apache2/listen.conf" ]; then + config="/etc/apache2/listen.conf" +fi +port=`awk -F' ' '/^[Ll]isten / {print $2}' $config` +echo "The original httpd port is $port in $config" + +echo "start to change httpd listen port to 8898" +sed -i "s/^Listen $1/Listen $2/g" $config +if [ -f "/etc/apache2/sites-enabled/000-default.conf" ]; then + sed -i "s/VirtualHost \*:$1/VirtualHost \*:$2/g" /etc/apache2/sites-enabled/000-default.conf + service apache2 stop + sleep 1 + service apache2 start +else + service httpd stop + sleep 1 + service httpd start +fi +exit diff --git a/xCAT-test/autotest/testcase/httpport/check_wget_files.sh b/xCAT-test/autotest/testcase/httpport/check_wget_files.sh new file mode 100755 index 000000000..d80489a42 --- /dev/null +++ b/xCAT-test/autotest/testcase/httpport/check_wget_files.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# get all filename in specified path +path=$1 +files=$(ls $path) +for filename in $files +do + echo "The file is $filename" + grep 8898 $path$filename + if [ $? != 0 ];then + echo "port 8898 does not exist" + exit 1; + fi + links=$(grep 8898 $path$filename|awk -F " " '{print $2}') + for link in $links + do + wget $link + if [ $? != 0 ];then + echo "wget failed" + exit 1; + else + echo "wget $link succeed" + fi + done +done From b4c6425ee374a1991e8c1ade5b1a266278f45e57 Mon Sep 17 00:00:00 2001 From: litingt Date: Sun, 18 Nov 2018 22:02:42 -0500 Subject: [PATCH 2/7] update according to comments --- xCAT-test/autotest/testcase/httpport/cases0 | 2 +- .../autotest/testcase/httpport/check_wget_files.sh | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xCAT-test/autotest/testcase/httpport/cases0 b/xCAT-test/autotest/testcase/httpport/cases0 index 8030ed03c..cc6b768d4 100644 --- a/xCAT-test/autotest/testcase/httpport/cases0 +++ b/xCAT-test/autotest/testcase/httpport/cases0 @@ -15,7 +15,7 @@ check:output =~ 8898 check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64le" ]]; then arch=ppc64; else arch=__GETNODEATTR($$CN,arch)__;fi; mknb $arch check:rc==0 -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/httpport/check_wget_files.sh /tftpboot/pxelinux.cfg/p/ +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/httpport/check_wget_files.sh /tftpboot/pxelinux.cfg/p/ 8898 check:rc==0 cmd:/opt/xcat/share/xcat/tools/autotest/testcase/httpport/change_http_port.sh 8898 80 cmd:netstat -nlp|grep -E "apache2|httpd" diff --git a/xCAT-test/autotest/testcase/httpport/check_wget_files.sh b/xCAT-test/autotest/testcase/httpport/check_wget_files.sh index d80489a42..6ffd76af7 100755 --- a/xCAT-test/autotest/testcase/httpport/check_wget_files.sh +++ b/xCAT-test/autotest/testcase/httpport/check_wget_files.sh @@ -6,20 +6,20 @@ files=$(ls $path) for filename in $files do echo "The file is $filename" - grep 8898 $path$filename + grep $2 $path$filename if [ $? != 0 ];then - echo "port 8898 does not exist" + echo "port $2 does not exist" exit 1; fi - links=$(grep 8898 $path$filename|awk -F " " '{print $2}') + links=$(grep $2 $path$filename|awk -F " " '{print $2}') for link in $links do wget $link if [ $? != 0 ];then - echo "wget failed" + echo "wget file $link failed" exit 1; else - echo "wget $link succeed" + echo "wget file $link succeed" fi done done From 5311d7c01f49ad6781e8e8f0566d4d9a82846690 Mon Sep 17 00:00:00 2001 From: litingt Date: Sun, 18 Nov 2018 22:06:55 -0500 Subject: [PATCH 3/7] update --- xCAT-test/autotest/testcase/httpport/change_http_port.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/httpport/change_http_port.sh b/xCAT-test/autotest/testcase/httpport/change_http_port.sh index f3b665d6e..527bd290d 100755 --- a/xCAT-test/autotest/testcase/httpport/change_http_port.sh +++ b/xCAT-test/autotest/testcase/httpport/change_http_port.sh @@ -9,7 +9,7 @@ fi port=`awk -F' ' '/^[Ll]isten / {print $2}' $config` echo "The original httpd port is $port in $config" -echo "start to change httpd listen port to 8898" +echo "start to change httpd listen port to $2" sed -i "s/^Listen $1/Listen $2/g" $config if [ -f "/etc/apache2/sites-enabled/000-default.conf" ]; then sed -i "s/VirtualHost \*:$1/VirtualHost \*:$2/g" /etc/apache2/sites-enabled/000-default.conf From 74066fc7f161ba70aac43c9a780a3bc98d7f30ec Mon Sep 17 00:00:00 2001 From: litingt Date: Wed, 21 Nov 2018 01:50:35 -0500 Subject: [PATCH 4/7] update code to test x86_64 arch --- xCAT-test/autotest/testcase/httpport/cases0 | 66 ++++++++++++++++++- .../testcase/httpport/check_wget_files.sh | 25 ------- 2 files changed, 64 insertions(+), 27 deletions(-) delete mode 100755 xCAT-test/autotest/testcase/httpport/check_wget_files.sh diff --git a/xCAT-test/autotest/testcase/httpport/cases0 b/xCAT-test/autotest/testcase/httpport/cases0 index cc6b768d4..dcca66bfb 100644 --- a/xCAT-test/autotest/testcase/httpport/cases0 +++ b/xCAT-test/autotest/testcase/httpport/cases0 @@ -13,9 +13,69 @@ check:rc==0 cmd:lsdef -t site -i httpport -c check:output =~ 8898 check:rc==0 -cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64le" ]]; then arch=ppc64; else arch=__GETNODEATTR($$CN,arch)__;fi; mknb $arch +cmd:dir="/tftpboot/pxelinux.cfg/p";if [ -e "${dir}" ];then mv ${dir} ${dir}".bak"; fi +cmd:mknb ppc64 check:rc==0 -cmd:/opt/xcat/share/xcat/tools/autotest/testcase/httpport/check_wget_files.sh /tftpboot/pxelinux.cfg/p/ 8898 +cmd: #!/bin/bash +# get all filename in specified path +path=/tftpboot/pxelinux.cfg/p/ +files=$(ls $path) +for filename in $files +do + echo "The file is $filename" + grep 8898 $path$filename + if [ $? != 0 ];then + echo "port 8898 does not exist" + exit 1; + fi + links=$(grep 8898 $path$filename|awk -F " " '{print $2}') + for link in $links + do + wget $link + if [ $? != 0 ];then + echo "wget file $link failed" + exit 1; + else + echo "wget file $link succeed" + fi + done +done +check:rc==0 +cmd:dir="/tftpboot/xcat/xnba/nets";if [ -e "${dir}" ];then mv ${dir} ${dir}".bak"; fi +cmd:mknb x86_64 +check:rc==0 +cmd:#!/bin/bash +# get all filename in specified path +path=/tftpboot/xcat/xnba/nets/ +rm -rf $path*.uefi +rm -rf $path*.elilo +files=$(ls $path) +mnip=$(tabdump site |grep -w master |awk -F "," '{print $2}'|sed 's/\"//g') +echo "The mn ip is $mnip" +for filename in $files +do + echo "The file is $filename" + grep 8898 $path$filename + if [ $? != 0 ];then + echo "port 8898 does not exist" + exit 1; + fi + grep "next-server" $path$filename + if [ $? == 0 ];then + sed -i "s/\${next-server}/$mnip/g" $path$filename + fi + links=$(grep 8898 $path$filename|awk -F " " '{print $4}') + for link in $links + do + wget $link + if [ $? != 0 ];then + echo "wget file $link failed" + exit 1; + else + echo "wget file $link succeed" + fi + done +done check:rc==0 cmd:/opt/xcat/share/xcat/tools/autotest/testcase/httpport/change_http_port.sh 8898 80 cmd:netstat -nlp|grep -E "apache2|httpd" @@ -26,4 +86,6 @@ check:rc==0 cmd:lsdef -t site -i httpport -c check:output =~ 80 check:rc==0 +cmd:dir="/tftpboot/pxelinux.cfg/p"; rm -rf $dir; if [ -d ${dir}".bak" ];then mv ${dir}".bak" $dir; fi +cmd:dir="/tftpboot/xcat/xnba/nets"; rm -rf $dir; if [ -d ${dir}".bak" ];then mv ${dir}".bak" $dir; fi end diff --git a/xCAT-test/autotest/testcase/httpport/check_wget_files.sh b/xCAT-test/autotest/testcase/httpport/check_wget_files.sh deleted file mode 100755 index 6ffd76af7..000000000 --- a/xCAT-test/autotest/testcase/httpport/check_wget_files.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# get all filename in specified path -path=$1 -files=$(ls $path) -for filename in $files -do - echo "The file is $filename" - grep $2 $path$filename - if [ $? != 0 ];then - echo "port $2 does not exist" - exit 1; - fi - links=$(grep $2 $path$filename|awk -F " " '{print $2}') - for link in $links - do - wget $link - if [ $? != 0 ];then - echo "wget file $link failed" - exit 1; - else - echo "wget file $link succeed" - fi - done -done From 14c3fe419dc8fea8d76b34f28c8ee82e1a8d8604 Mon Sep 17 00:00:00 2001 From: litingt Date: Thu, 22 Nov 2018 21:41:22 -0500 Subject: [PATCH 5/7] update to add wget uefi file --- xCAT-test/autotest/testcase/httpport/cases0 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/xCAT-test/autotest/testcase/httpport/cases0 b/xCAT-test/autotest/testcase/httpport/cases0 index dcca66bfb..b1be40454 100644 --- a/xCAT-test/autotest/testcase/httpport/cases0 +++ b/xCAT-test/autotest/testcase/httpport/cases0 @@ -40,6 +40,7 @@ do fi done done +rm -rf genesis* check:rc==0 cmd:dir="/tftpboot/xcat/xnba/nets";if [ -e "${dir}" ];then mv ${dir} ${dir}".bak"; fi cmd:mknb x86_64 @@ -47,10 +48,9 @@ check:rc==0 cmd:#!/bin/bash # get all filename in specified path path=/tftpboot/xcat/xnba/nets/ -rm -rf $path*.uefi rm -rf $path*.elilo files=$(ls $path) -mnip=$(tabdump site |grep -w master |awk -F "," '{print $2}'|sed 's/\"//g') +mnip=$(lsdef -t site -i master -c |awk -F"=" '{print $2}') echo "The mn ip is $mnip" for filename in $files do @@ -64,7 +64,13 @@ do if [ $? == 0 ];then sed -i "s/\${next-server}/$mnip/g" $path$filename fi - links=$(grep 8898 $path$filename|awk -F " " '{print $4}') + + if [ "${filename##*.}"x = "uefi"x ];then + links=$(grep 8898 $path$filename|awk -F " " '{print $2}') + else + links=$(grep 8898 $path$filename|awk -F " " '{print $4}') + fi + for link in $links do wget $link @@ -76,6 +82,8 @@ do fi done done +rm -rf genesis* +rm -rf uefi* check:rc==0 cmd:/opt/xcat/share/xcat/tools/autotest/testcase/httpport/change_http_port.sh 8898 80 cmd:netstat -nlp|grep -E "apache2|httpd" From 193e216ca93342de6f51107d66e54ed74c6a48f5 Mon Sep 17 00:00:00 2001 From: litingt Date: Thu, 22 Nov 2018 21:52:07 -0500 Subject: [PATCH 6/7] update to fix a typo --- xCAT-test/autotest/testcase/httpport/cases0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/httpport/cases0 b/xCAT-test/autotest/testcase/httpport/cases0 index b1be40454..8671d0a67 100644 --- a/xCAT-test/autotest/testcase/httpport/cases0 +++ b/xCAT-test/autotest/testcase/httpport/cases0 @@ -83,7 +83,7 @@ do done done rm -rf genesis* -rm -rf uefi* +rm -rf elilo* check:rc==0 cmd:/opt/xcat/share/xcat/tools/autotest/testcase/httpport/change_http_port.sh 8898 80 cmd:netstat -nlp|grep -E "apache2|httpd" From f186b36c3bbaedcea311c95e0b9e102aefd5bb77 Mon Sep 17 00:00:00 2001 From: litingt Date: Fri, 23 Nov 2018 01:45:50 -0500 Subject: [PATCH 7/7] update labels for the case --- xCAT-test/autotest/testcase/httpport/cases0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/httpport/cases0 b/xCAT-test/autotest/testcase/httpport/cases0 index 8671d0a67..a756fbf35 100644 --- a/xCAT-test/autotest/testcase/httpport/cases0 +++ b/xCAT-test/autotest/testcase/httpport/cases0 @@ -1,6 +1,6 @@ start:http_port_change description:Add test cases for bug fix 2629, change http port and then generate genesis (mknb). -label:others +label:mn_only,discovery cmd:netstat -nlp|grep -E "apache2|httpd" check:output =~ 80 cmd:lsdef -t site -i httpport -c |awk -F"=" '{print $2}'