轉(zhuǎn)帖|行業(yè)資訊|編輯:龔雪|2016-03-09 13:17:16.000|閱讀 246 次
概述:本文主要介紹如何進(jìn)行高性能自動化測試的環(huán)境搭建,重點介紹如何部署 Jenkins Server, Chef Server, Chef Client, NTP Server, NTP Client, Yum Server,NFS Server, NFS Client 和 SSH 免密碼登錄,從而幫助讀者了解如何在項目里進(jìn)行高性能自動化測試的環(huán)境部署。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
部署 SSH 免密碼登錄和 Report Server
在進(jìn)行高性能自動化測試的過程中,復(fù)制/移動最終的測試結(jié)果到 Report Server 時會用到 scp,因為它比較安全。但如果每次都要在 script 里輸入密碼,就比較煩了。以下操作將介紹生成密匙對的步驟,從而完成 SSH 免密碼登錄的配置,方便測試結(jié)果被安全迅速的傳送到 Report Server。
如何在實際項目里進(jìn)行高性能自動化測試
根據(jù)以上步驟,您就可以搭建一套可以實現(xiàn)高性能自動化測試的測試環(huán)境,下面介紹下如何在搭建的環(huán)境里進(jìn)行高性能測試。
并行執(zhí)行多個 Chef Client 上的測試
在第二部分介紹了如何部署 Chef Server 和 Chef Client,在此向讀者介紹下如何在 Chef Server 上并行的執(zhí)行多個 Chef Client 上的測試任務(wù),通過在多個 node 上進(jìn)行分布式的并發(fā)測試,從而減少測試時間,提高測試效率。
在此舉例下如何并行的喚起多個 Chef Client 上的 testing,Shell 腳本如下:
<script> #Invoke all chef clients for QAF by multiple thread echo start: `date`; start=`date +%s`; #for function is used to invoke all Chef Clients to test for ((i=1;i<=${#ip[@]};i++)) do { #knife bootstrap command is used to start testing in the Chef Clients knife bootstrap ${ip[$i-1]} -x root --sudo -r "role[client_QAF]" }& Done #wait command is used to wait for all the testing finished in the Chef Clients wait echo end: `date`; end=`date +%s`; #time is used to analysis the testing time time=$[ end -start ]; </script>
shell 腳本自動歸集測試報告
由于測試是分布式的在多個 node 上進(jìn)行的,所以測試完成后,需要將每個 Chef Client 上的測試報告歸集到一起的,在這里就用到了第二部分所介紹的 NFS 自動收集所有 node 上的報告。
在此舉例下如何收集多個 Chef Client 上的 testing report,Shell 腳本如下:
<script> #!/bin/bash range=$1 #initial report folder rm -rf /root/$range/workspace/com.spss.qa.automation/html/* rm -rf /root/$range/workspace/com.spss.qa.automation/test-reports/* #gather report if [ $range = "3.0" ] then cp -rf /root/share/test-reports/3.0/* /root/$range/workspace/com.spss.qa.automation/test-reports cp -rf /root/share/test-reports/2.0/* /root/$range/workspace/com.spss.qa.automation/test-reports else cp -rf /root/share/test-reports/$range/* /root/$range/workspace/com.spss.qa.automation/test-reports fi </script>
發(fā)布測試 report
所有的測試報告都被收集到 Report server 上后,用 Ant 腳本產(chǎn)生 Html report。Ant 腳本如下:
<script> <target name="report"> <junitreport todir="${basedir}/test-reports"> <fileset dir="${basedir}/test-reports"> <include name="TEST-*.xml" /> </fileset> <report format="frames" todir="${basedir}/html" /> </junitreport> </target> </script>
然后通過第二部分介紹的 SSH 免密碼登錄將產(chǎn)生的測試 report 發(fā)布到 Jenkins 上指定的路徑上去,Shell 腳本如下:
<script> #pubilsh report to //9.30.214.85:8080/testStage_$version mkdir -p /root/apache-tomcat-7.0.59/webapps/testStage_$version cp -rf /root/share/html/$range/* /root/apache-tomcat-7.0.59/webapps/testStage_$version cd /root/apache-tomcat-7.0.59/bin ./startup.sh #publish report to build server cd /root/workspace/testStage/share/html/$range/ scp -r * root@9.30.214.84:/$report_path </script>
發(fā)送測試結(jié)果郵件
測試進(jìn)行完成后,Jenkins 會自動給組里人員發(fā)送測試報告郵件,讀者可以按照以下在 Jenkins 里配置郵件收件人和郵件標(biāo)題。
實際項目里收到的測試結(jié)果郵件如下:
項目里遇到的問題以及解決辦法
在此,簡單列舉下如何處理環(huán)境異常的情況:NFS Server 和 NFS Client 之間通信斷掉。當(dāng)節(jié)假日來臨或者 IT 部門維修 VM 的時候,會遇到 VM 被關(guān)機(jī)的情況,人為將 VM 開機(jī)后,NFS Server 和 NFS Client 之間的通信也已經(jīng)被斷掉了。這時候,我們需要做 2 個步驟解決通信被斷掉的問題:
結(jié)束語
本文探索了如何搭建高性能自動化測試環(huán)境, 您可以根據(jù)本文介紹的方法,搭建環(huán)境實現(xiàn)在多個 Chef Client 上并行的進(jìn)行自動化測試,從而減少測試執(zhí)行時間,縮短測試周期,提高測試效率,實現(xiàn)高性能自動化測試。
原文轉(zhuǎn)載自:
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn