1 Star 0 Fork 2

凹凸曼打小怪兽/wenjian

forked from banzhuanxiaodoubi/wenjian 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
run_openeuler_at.sh 16.02 KB
一键复制 编辑 原始数据 按行查看 历史
banzhuanxiaodoubi 提交于 2022-12-02 11:24 . wenjiane2
#!/bin/bash
export VERSION=$1
export jobids=
exepath=$(dirname $0)
save_flag=0
case_num=0
passed_num=0
error_num=0
function run_testjob() {
local total_try_num=5
echo "start to connect openQA ,run test job"
declare -i index=0
while true; do
ids=$(python "${exepath}"/openeuler_at_operation.py start "${VERSION}")
if [ "x${ids}" == "xerror" ]; then
sleep 30
if [ $index -eq ${total_try_num} ]; then
echo "Failed to connect openQA to run test job"
exit 1
fi
index=$index+1
else
echo "connect to connect openQA ,run test job successfully!"
export jobids=${ids}
break
fi
done
}
function save_qcow() {
mkdir -p /var/www/html/hdd/
if [ "${VERSION}" == "openEuler-Mainline-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-Mainline-aarch64.qcow2 /var/www/html/hdd/openEuler-Mainline-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-Mainline-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-Mainline-x86_64.qcow2 /var/www/html/hdd/openEuler-Mainline-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-SP1-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-SP1-aarch64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-SP1-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-SP1-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-SP1-x86_64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-SP1-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-SP1-netinst-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-SP1-netinst-aarch64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-SP1-netinst-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-SP1-netinst-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-SP1-netinst-x86_64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-SP1-netinst-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-Next-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-Next-aarch64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-Next-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-Next-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-Next-x86_64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-Next-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-Next-netinst-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-Next-netinst-aarch64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-Next-netinst-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-Next-netinst-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-Next-netinst-x86_64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-Next-netinst-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-21.09-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-21.09-aarch64.qcow2 /var/www/html/hdd/openEuler-21.09-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-21.09-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-21.09-x86_64.qcow2 /var/www/html/hdd/openEuler-21.09-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-SP2-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-SP2-aarch64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-SP2-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-SP2-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-SP2-x86_64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-SP2-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-SP2-netinst-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-SP2-netinst-aarch64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-SP2-netinst-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-SP2-netinst-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-SP2-netinst-x86_64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-SP2-netinst-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-Mainline-netinst-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-Mainline-netinst-aarch64.qcow2 /var/www/html/hdd/openEuler-Mainline-netinst-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-Mainline-netinst-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-Mainline-netinst-x86_64.qcow2 /var/www/html/hdd/openEuler-Mainline-netinst-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.09-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.09-aarch64.qcow2 /var/www/html/hdd/openEuler-20.09-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.09-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.09-x86_64.qcow2 /var/www/html/hdd/openEuler-20.09-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-SP3-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-SP3-aarch64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-SP3-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-SP3-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-SP3-x86_64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-SP3-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-SP3-netinst-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-SP3-netinst-aarch64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-SP3-netinst-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-20.03-LTS-SP3-netinst-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-20.03-LTS-SP3-netinst-x86_64.qcow2 /var/www/html/hdd/openEuler-20.03-LTS-SP3-netinst-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-22.03-LTS-Next-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-22.03-LTS-Next-aarch64.qcow2 /var/www/html/hdd/openEuler-22.03-LTS-Next-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-22.03-LTS-Next-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-22.03-LTS-Next-x86_64.qcow2 /var/www/html/hdd/openEuler-22.03-LTS-Next-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-22.03-LTS-Next-netinst-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-22.03-LTS-Next-netinst-aarch64.qcow2 /var/www/html/hdd/openEuler-22.03-LTS-Next-netinst-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-22.03-LTS-Next-netinst-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-22.03-LTS-Next-netinst-x86_64.qcow2 /var/www/html/hdd/openEuler-22.03-LTS-Next-netinst-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-22.03-LTS-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-22.03-LTS-aarch64.qcow2 /var/www/html/hdd/openEuler-22.03-LTS-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-22.03-LTS-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-22.03-LTS-x86_64.qcow2 /var/www/html/hdd/openEuler-22.03-LTS-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-22.03-LTS-netinst-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-22.03-LTS-netinst-aarch64.qcow2 /var/www/html/hdd/openEuler-22.03-LTS-netinst-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-22.03-LTS-netinst-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-22.03-LTS-netinst-x86_64.qcow2 /var/www/html/hdd/openEuler-22.03-LTS-netinst-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-22.09-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-22.09-aarch64.qcow2 /var/www/html/hdd/openEuler-22.09-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-22.09-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-22.09-x86_64.qcow2 /var/www/html/hdd/openEuler-22.09-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-22.03-LTS-netinst-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-22.09-netinst-aarch64.qcow2 /var/www/html/hdd/openEuler-22.09-netinst-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-Desktop-22.09-aarch64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-Desktop-22.09-aarch64.qcow2 /var/www/html/hdd/openEuler-Desktop-22.09-aarch64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
elif [ "${VERSION}" == "openEuler-Desktop-22.09-x86_64-dvd" ]; then
scp root@172.168.131.95:/var/lib/openqa/factory/hdd/openEuler-Server-Desktop-22.09-x86_64.qcow2 /var/www/html/hdd/openEuler-Desktop-22.09-x86_64.qcow2
if [ $? -ne 0 ]; then
return 1
fi
fi
return 0
}
function get_json_value() {
local json=$1
local key=$2
num=1
local value=$(echo "${json}" | awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'${key}'\042/){print $(i+1)}}}' | tr -d '"' | sed -n ${num}p)
echo "${value}"
}
function get_status() {
result_str=
done_num=0
array=(${jobids//+/ })
for jobid in ${array[@]}; do
set -e
value=$(curl -s http://172.168.131.95/api/v1/jobs/$jobid/details)
set +e
if [ x"$value" == x ]; then
return 1
fi
job_state=$(get_json_value "${value}" "state")
job_result=$(get_json_value "${value}" "result")
job_test=$(get_json_value "${value}" "TEST")
if [ x"$result_str" == x ]; then
result_str="ids=$jobid,state=$job_state,result=$job_result,test=$job_test"
else
result_str="$result_str ; ids=$jobid,state=$job_state,result=$job_result,test=$job_test"
fi
if [ "$job_state" == "running" ]; then
date_now=$(date +%s)
if ! grep "$jobid" /tmp/"${jobids}"; then
echo "$jobid $date_now" >>/tmp/"${jobids}"
else
date_old=$(grep "$jobid" /tmp/"${jobids}" | awk -F ' ' '{print $2}')
if [ $((date_now - date_old)) -gt 2400 ]; then
set -xe
echo "$jobid timeout,restart job $jobid"
restart_ids=$(python "${exepath}"/openeuler_at_operation.py restart "${jobid}")
if [ "x${restart_ids}" == "xerror" ]; then
echo "restart job $jobid failed"
else
echo "restart job $jobid success,new job $restart_ids"
old_jobids=$jobids
export jobids=$(echo ${jobids/$jobid/$restart_ids})
echo "new jobids:$jobids"
mv /tmp/"${old_jobids}" /tmp/"${jobids}"
fi
set +xe
fi
fi
elif [ "$job_state" == "done" ]; then
if [ "$job_test" == "install_testsuite" -a "$job_result" == "passed" -a $save_flag -eq 0 ]; then
set -xe
save_qcow "${VERSION}"
if [ $? -eq 0 ]; then
save_flag=1
else
echo "save qcow ${VERSION} error"
fi
set +xe
fi
((done_num++))
fi
done
echo "${result_str}"
echo "${result_str}" >/tmp/"${jobids}""result"
}
function wait_job_finish() {
date_start=$(date +%s)
array=(${jobids//+/ })
case_num=${#array[*]}
while true; do
if [ ${error_num} -gt 15 ]; then
echo "get the job status error for 15 times, break"
break
fi
if ! get_status; then
echo "get the job status error, sleep 60s and continue to check"
((error_num++))
sleep 60
continue
fi
set -ex
if [ $case_num -eq $done_num ]; then
echo "The testjob has been done"
break
fi
date_new=$(date +%s)
if [ $((date_new - date_start)) -gt 10800 ]; then
echo "timeout"
break
fi
sleep 30
error_num=0
set +ex
done
}
function get_result() {
set +x
jobids_result=$(cat /tmp/"${jobids}""result")
echo "*****************************************************************************
all_result:
$jobids_result
*****************************************************************************"
array=(${jobids_result// ; / })
for jobid_result in ${array[@]}; do
if [ "$(echo ${jobid_result} | awk -F ',' '{print $3}')" == "result=passed" ]; then
passed_num=$(($passed_num + 1))
fi
done
if [ "x${case_num}" == "x${passed_num}" ]; then
echo "*****************************************************************************
All testcase success!
*****************************************************************************"
rm -rf /tmp/*result /tmp/"${jobids}" /tmp/livelog*
else
echo "*****************************************************************************
Some testcase failed!
*****************************************************************************"
rm -rf /tmp/*result /tmp/"${jobids}" /tmp/livelog*
exit 1
fi
}
run_testjob
echo "start to connect openQA ,run test job: ${jobids}"
#sleep 100
wait_job_finish
get_result
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/concave-convex-manda/wenjian.git
git@gitee.com:concave-convex-manda/wenjian.git
concave-convex-manda
wenjian
wenjian
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385