From 8b898757973b347ec00ba87b2d01db23c350fdc8 Mon Sep 17 00:00:00 2001 From: Ke Zhiming Date: Tue, 5 Jan 2021 16:48:56 +0800 Subject: [PATCH 1/4] virttest: Images is stored using /dev/sda Images is stored using /dev/sda, because some envionments only have one disk and no /dev/sdb. Signed-off-by: Ke Zhiming --- tests/virttest | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/virttest b/tests/virttest index 7911876..9f26314 100755 --- a/tests/virttest +++ b/tests/virttest @@ -24,6 +24,7 @@ images_aarch64=("openEuler-20.03-aarch64.qcow2" "openEuler-20.09-aarch64.qcow2") images_x86_64=("openEuler-20.03-x86_64.qcow2" "openEuler-20.09-x86_64.qcow2") file_server="${image_server}/initrd/qemu-image" images_path="/var/lib/avocado/data/avocado-vt/images/" +images_partition="/dev/sda" set_up() { iptables -F @@ -304,7 +305,7 @@ config_tmpdir() { # image file system config if [ $os_mount == "cifs" -o $os_mount == "nfs" -o $os_mount == "initramfs" ]; then - mount /dev/sdb ${images_path} || echo y | mkfs.ext4 /dev/sdb && mount /dev/sdb ${images_path} + mount $images_partition $images_path || echo y | mkfs.ext4 $images_partition && mount $images_partition $images_path fi config_tmpdir -- Gitee From 6db6b896e0f760aa8c2b78160b9a703b29c57b01 Mon Sep 17 00:00:00 2001 From: Ke Zhiming Date: Tue, 5 Jan 2021 17:02:12 +0800 Subject: [PATCH 2/4] virttest: delete the wrong operation Delete the wrong operation Signed-off-by: Ke Zhiming --- tests/virttest | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/virttest b/tests/virttest index 9f26314..5f5f2d4 100755 --- a/tests/virttest +++ b/tests/virttest @@ -242,7 +242,6 @@ fi # config virttest for 2hosts pwd=${node_pwd:-Helloman@12#$} -[ -z "$env_type" ] || env_type = "" if [ x$env_type == x"2hosts" -a ! -e $libvirt_base_cfg.bak_by_CI ];then config_virttest $server $client $pwd fi -- Gitee From a72f0243b0b6ec8c7387b23aa8d30f708e75300c Mon Sep 17 00:00:00 2001 From: Ke Zhiming Date: Tue, 5 Jan 2021 17:11:28 +0800 Subject: [PATCH 3/4] virttest: dns configuration modified DNS is configured if resolv.conf does not exist and the default address is used if dns_address is not configured Signed-off-by: Ke Zhiming --- tests/virttest | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/virttest b/tests/virttest index 5f5f2d4..7f2fbee 100755 --- a/tests/virttest +++ b/tests/virttest @@ -26,6 +26,9 @@ file_server="${image_server}/initrd/qemu-image" images_path="/var/lib/avocado/data/avocado-vt/images/" images_partition="/dev/sda" +default_dns_address="223.5.5.5" # The default DNS address for compass-ci +dns_address=${dns_address:-$default_dns_address} + set_up() { iptables -F @@ -221,8 +224,9 @@ if [ ! -e /etc/bashrc.bak_by_CI ]; then log_cmd systemctl restart libvirtd ||systemctl unmask libvirtd && systemctl restart libvirtd # config dns - [ -z "$dns_address" ] || echo "nameserver $dns_address" >> /etc/resolv.conf - + if [ ! -f /etc/resolv.conf ]; then + echo "nameserver $dns_address" >> /etc/resolv.conf + fi fi # config qemu -- Gitee From 784798903bc9cd04cbda97bcaa1aef336e1e20f9 Mon Sep 17 00:00:00 2001 From: Ke Zhiming Date: Wed, 6 Jan 2021 13:45:10 +0800 Subject: [PATCH 4/4] virttest: centrally define variables 1. Defining variables centrally is easy to read 2. Some variables rename Signed-off-by: Ke Zhiming --- tests/virttest | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/virttest b/tests/virttest index 7f2fbee..f1cd5bb 100755 --- a/tests/virttest +++ b/tests/virttest @@ -28,6 +28,11 @@ images_partition="/dev/sda" default_dns_address="223.5.5.5" # The default DNS address for compass-ci dns_address=${dns_address:-$default_dns_address} +default_pwd="Helloman@12#$" +node_pwd=${node_pwd:-$default_pwd} + +libvirt_base_cfg="/var/lib/avocado/data/avocado-vt/backends/libvirt/cfg/base.cfg" +bash_prompt="/root/.shell/bash_prompt" set_up() { iptables -F @@ -160,7 +165,6 @@ run_test() { ) } -libvirt_base_cfg=/var/lib/avocado/data/avocado-vt/backends/libvirt/cfg/base.cfg config_virttest() { local_ip=$1 remote_ip=$2 @@ -207,7 +211,6 @@ config_virttest() { } # config bash prompt. The shell prompt that indicates a successfull login -bash_prompt="/root/.shell/bash_prompt" if [ -f $bash_prompt -a ! -e $bash_prompt.bak_by_CI ]; then cp -a $bash_prompt $bash_prompt.bak_by_CI sed -i '/^PS1=/c PS1=\"[\\u@\\h \\W]# \"' $bash_prompt @@ -245,9 +248,8 @@ if [ $vt_reference == "remote_deploy" ]; then fi # config virttest for 2hosts -pwd=${node_pwd:-Helloman@12#$} if [ x$env_type == x"2hosts" -a ! -e $libvirt_base_cfg.bak_by_CI ];then - config_virttest $server $client $pwd + config_virttest $server $client $node_pwd fi conf_file=$(find /usr/local/lib/ -name "avocado.conf") @@ -293,9 +295,6 @@ for _only_filter in $only_filter; do done [ -z "$vt_tests" ] && die "Not found tests: avocado list ${vt_reference:?} ${base_params[@]} ${extra_params[@]}" -ok=0 -all=0 - # config tmp dir config_tmpdir() { umount /var/tmp > /dev/null 2>&1 @@ -315,15 +314,17 @@ config_tmpdir # download images images_download +test_ok=0 +test_all=0 for vt_test in $vt_tests; do run_test avocado run "${vt_test:?}" "${base_params[@]}" --job-timeout "$job_timeout" 2>&1 - [ $? -eq 0 ] && ((ok++)) - ((all++)) + [ $? -eq 0 ] && ((test_ok++)) + ((test_all++)) done -echo "$vt_name.result.ok: $ok" -echo "$vt_name.result.all: $all" -echo "$vt_name.result.rate: $(($ok*100/$all))" +echo "$vt_name.result.ok: $test_ok" +echo "$vt_name.result.all: $test_all" +echo "$vt_name.result.rate: $(($test_ok*100/$test_all))" mkdir /home/$vt_reference mv ${logs_dir}/* /home/$vt_reference -- Gitee