当前位置: 首页 > 工具软件 > Avocado > 使用案例 >

Avocado使用

赫连越
2023-12-01

Avocado用户手册:https://avocado-framework.readthedocs.io/en/latest/guides/user/index.html

1.安装Avocado

pip3 install avocado-framework

2.安装Avocado-VT

pip3 install git+https://gitee.com/openeuler/avocado-vt

3.引导Avocado-VT(在线下载方式)

1.安装python3-devel

yum install python3-devel

如果python3-devel包没有安装,后续执行avocado vt-bootstrap命令时会报错缺失Python.h,如下:

Required include Python.h is missing. You may have to install it

Missing (cmds/includes): Python.h

2.修改test-providers的ini配置

在/usr/local/lib/python3.6/site-packages/virttest/test-providers.d目录下有三个ini配置文件:

io-github-autotest-libvirt.ini

io-github-autotest-qemu.ini

io-github-spiceqa-spice.ini

这三个ini配置文件中配置了test-provider的uri地址,后续执行avocado vt-bootstrap命令时会去对应的uri地址下载代码,但是这三个uri指定的是github地址,通常无法成功下载,因此需要修改这三个配置文件。

  • io-github-autotest-libvirt.ini修改如下:uri: https://github.com/autotest/tp-libvirt.git改为uri: https://gitee.com/openeuler/tp-libvirt.git。
  • io-github-autotest-qemu.ini修改如下:uri: https://github.com/autotest/tp-qemu.git改为uri: https://gitee.com/openeuler/tp-qemu.git。
  • 删除io-github-spiceqa-spice.ini。

注意,如果不修改这三个ini配置,后续执行avocado vt-bootstrap命令时会卡在如下步骤:

4 - Downloading the test providers from remote repos

Creating directory /var/lib/avocado/data/avocado-vt/virttest/test-providers.d/downloads/io-github-autotest-libvirt for git repo https://github.com/autotest/tp-libvirt.git

Initializing new git repo at /var/lib/avocado/data/avocado-vt/virttest/test-providers.d/downloads/io-github-autotest-libvirt for receiving git repo https://github.com/autotest/tp-libvirt.git

Running '/usr/bin/git init'

[stdout] Initialized empty Git repository in /var/lib/avocado/data/avocado-vt/virttest/test-providers.d/downloads/io-github-autotest-libvirt/.git/

Command '/usr/bin/git init' finished with 0 after 0.00392603874206543s

Fetching git [REP 'https://github.com/autotest/tp-libvirt.git' BRANCH 'master'] -> /var/lib/avocado/data/avocado-vt/virttest/test-providers.d/downloads/io-github-autotest-libvirt

Running '/usr/bin/git fetch -q -f -u -t https://github.com/autotest/tp-libvirt.git master:master'

3.执行avocado vt-bootstrap

执行过程中会去avocado官网下载qcow2文件,注意选择y。

avocado vt-bootstrap --vt-type qemu

...

8 - Verifying (and possibly downloading) guest image

Verifying expected SHA1 sum from https://avocado-project.org/data/assets/jeos/27/SHA1SUM_JEOS_27_64

Expected SHA1 sum: ce560ecdd5adaeaf00895f70cf4bdeecda9defd2

Found /var/lib/avocado/data/avocado-vt/images/jeos-27-x86_64.qcow2.xz

Actual SHA1 sum: da39a3ee5e6b4b0d3255bfef95601890afd80709

The file seems corrupted or outdated. Would you like to download it? (y/n) y

vt-bootstrap执行成功后可以使用avocado list --vt-type qemu命令查看qemu的测试用例:

[root@bj03-no_use-172e28e205e56 avocado]# avocado list --vt-type qemu

WARNING:root:No python imaging library installed. Screendump and Windows guest BSOD detection are disabled. In order to enable it, please install python-imaging or the equivalent for your distro.

WARNING:root:No python imaging library installed. PPM image conversion to JPEG disabled. In order to enable it, please install python-imaging or the equivalent for your distro.

VT io-github-autotest-qemu.unattended_install.url.extra_cdrom_ks.default_install.aio_native

VT io-github-autotest-qemu.unattended_install.url.extra_cdrom_ks.default_install.aio_threads

VT io-github-autotest-qemu.unattended_install.url.extra_cdrom_ks.perf.aio_native

VT io-github-autotest-qemu.unattended_install.url.extra_cdrom_ks.perf.aio_threads

...

3.引导Avocado-VT(离线方式)

avocado vt-bootstrap --vt-type qemu --vt-no-downloads

之后需要准备好从其他机器上下载好的/var/lib/avocado/data/avocado-vt整个目录。

注意:运行的时候会在/var/lib/avocado/data/avocado-vt/images/路径下生成很多磁盘镜像文件,占用空间较大,因此建议将/var/lib/avocado/data/avocado-vt/images单独挂载。

4.执行测试

[root@bj03-no_use-172e28e205e56 avocado]# avocado run io-github-autotest-qemu

WARNING:root:No python imaging library installed. Screendump and Windows guest BSOD detection are disabled. In order to enable it, please install python-imaging or the equivalent for your distro.

WARNING:root:No python imaging library installed. PPM image conversion to JPEG disabled. In order to enable it, please install python-imaging or the equivalent for your distro.

JOB ID : 98222919bca3e08fd3ffa68565db9c57e473a09b

JOB LOG : /root/avocado/job-results/job-2021-03-26T16.51-9822291/job.log

...

可以看到其日志文件在/root/avocado/job-results/job-2021-03-26T16.51-9822291/job.log。

 

附:执行avocado vt-bootstrap的过程:

[root@bj03-no_use-172e28e205e56 images]# avocado vt-bootstrap --vt-type qemu

WARNING:root:No python imaging library installed. Screendump and Windows guest BSOD detection are disabled. In order to enable it, please install python-imaging or the equivalent for your distro.

WARNING:root:No python imaging library installed. PPM image conversion to JPEG disabled. In order to enable it, please install python-imaging or the equivalent for your distro.

Running bootstrap for qemu

 

1 - Checking the mandatory programs and headers

/bin/xz OK

/sbin/tcpdump OK

/bin/nc OK

/sbin/ip OK

/sbin/arping OK

/bin/diff OK

/bin/gcc OK

/usr/include/python3.6m/Python.h OK

/usr/include/asm/socket.h OK

/usr/include/asm/types.h OK

/usr/include/asm/unistd.h OK

 

2 - Checking the recommended programs

/usr/libexec/qemu-kvm OK

/bin/qemu-img OK

/bin/qemu-io OK

/bin/virsh OK

 

3 - Updating test providers repo configuration from local copy

 

4 - Updating the test providers from remote repos

Running 'git log -1'

[stdout] commit 7a29c88df7c058abdeaaa5af2218b61d826d2934

[stdout] Merge: 43683978 56308f58

[stdout] Author: dzhengfy <dzheng@redhat.com>

Command 'git log -1' finished with 0 after 0.004309177398681641s

[stdout] Date: Fri Mar 19 18:43:15 2021 +0800

[stdout]

[stdout] Merge pull request #3370 from iccaszhulili/remote_access_vm_name

[stdout]

[stdout] remote_with_unix: Complete fix the regex issue of unix connection test

Running 'git log -1'

[stdout] Merge: 6fa1179b a4be5107

[stdout] Author: Zhenchao Liu <35018947+zhencliu@users.noreply.github.com>

[stdout] Date: Fri Mar 19 10:42:33 2021 +0800

[stdout]

Command 'git log -1' finished with 0 after 0.0032923221588134766s

[stdout] Merge pull request #2701 from XueqiangWei/create_large_img

[stdout]

[stdout] create_large_img: add qcow2 and luks format support

 

5 - Verifying directories

Dir /var/lib/avocado/data/avocado-vt/images exists, not creating

Dir /var/lib/avocado/data/avocado-vt/isos exists, not creating

Dir /var/lib/avocado/data/avocado-vt/steps_data exists, not creating

Dir /var/lib/avocado/data/avocado-vt/gpg exists, not creating

Dir /var/lib/avocado/data/avocado-vt/downloads exists, not creating

 

6 - Syncing backend dirs /usr/local/lib/python3.6/site-packages/virttest/backends -> /var/lib/avocado/data/avocado-vt/backends

Copying downloadable assets file definitions from /usr/local/lib/python3.6/site-packages/virttest/shared/downloads into /var/lib/avocado/data/avocado-vt/downloads

Download file /var/lib/avocado/data/avocado-vt/downloads/centos66-32.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/centos66-64.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/centos70-64.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/centos72-ppc64le.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/centos73-ppc64le.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/centos74-ppc64le.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/debian-9.4.0-aarch64.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/fedora-31-x86_64.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/jeos-23-64.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/jeos-25-64.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/jeos-27-aarch64.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/jeos-27-ppc64.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/jeos-27-ppc64le.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/jeos-27-s390x.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/jeos-27-x86_64.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/ubuntu-12.04-server-32.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/ubuntu-12.04-server-64.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/ubuntu-14.04-server-32.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/ubuntu-14.04-server-64.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/virtio-win.ini exists, not touching

Download file /var/lib/avocado/data/avocado-vt/downloads/winutils.ini exists, not touching

 

7 - Generating config set

Config file /var/lib/avocado/data/avocado-vt/backends/qemu/cfg/base.cfg exists, not touching

Config file /var/lib/avocado/data/avocado-vt/backends/qemu/cfg/cdkeys.cfg exists, not touching

Config file /var/lib/avocado/data/avocado-vt/backends/qemu/cfg/guest-hw.cfg exists, not touching

Config file /var/lib/avocado/data/avocado-vt/backends/qemu/cfg/machines.cfg exists, not touching

Config file /var/lib/avocado/data/avocado-vt/backends/qemu/cfg/subtests.cfg auto generated from subtest samples

Config file /var/lib/avocado/data/avocado-vt/backends/qemu/cfg/guest-os.cfg auto generated from guest OS samples

Could not find micro-architecture/family, Error: [Errno 2] No such file or directory: '/sys/devices/cpu/caps/pmu_name'

Config file /var/lib/avocado/data/avocado-vt/backends/qemu/cfg/host.cfg generated from distro detection

 

8 - Verifying (and possibly downloading) guest image

Verifying expected SHA1 sum from https://avocado-project.org/data/assets/jeos/27/SHA1SUM_JEOS_27_64

Expected SHA1 sum: ce560ecdd5adaeaf00895f70cf4bdeecda9defd2

Found /var/lib/avocado/data/avocado-vt/images/jeos-27-x86_64.qcow2.xz

Actual SHA1 sum: da39a3ee5e6b4b0d3255bfef95601890afd80709

The file seems corrupted or outdated. Would you like to download it? (y/n) y

Updating image to the latest available...

Downloading jeos-27-64.qcow2.xz, 253.54 MB to /var/lib/avocado/data/avocado-vt/images

JeOS 27 x86_64: [===========================================================] 100%Actual SHA1 sum: da39a3ee5e6b4b0d3255bfef95601890afd80709

The file downloaded /var/lib/avocado/data/avocado-vt/images/jeos-27-x86_64.qcow2.xz is corrupted. Would you like to try again? (y/n) y

Check your internet connection: <urlopen error [Errno -2] Name or service not known>

Actual SHA1 sum: da39a3ee5e6b4b0d3255bfef95601890afd80709

The file downloaded /var/lib/avocado/data/avocado-vt/images/jeos-27-x86_64.qcow2.xz is corrupted. Would you like to try again? (y/n) y

Downloading jeos-27-64.qcow2.xz, 253.54 MB to /var/lib/avocado/data/avocado-vt/images

JeOS 27 x86_64: [===========================================================] 100%/var/lib/avocado/data/avocado-vt/images/jeos-27-x86_64.qcow2.xz present, with proper checksum

Uncompressing /var/lib/avocado/data/avocado-vt/images/jeos-27-x86_64.qcow2.xz -> /var/lib/avocado/data/avocado-vt/images/jeos-27-x86_64.qcow2

Running 'xz -cd /var/lib/avocado/data/avocado-vt/images/jeos-27-x86_64.qcow2.xz > /var/lib/avocado/data/avocado-vt/images/jeos-27-x86_64.qcow2'

Command 'xz -cd /var/lib/avocado/data/avocado-vt/images/jeos-27-x86_64.qcow2.xz > /var/lib/avocado/data/avocado-vt/images/jeos-27-x86_64.qcow2' finished with 0 after 18.633646965026855s

 

9 - Checking for modules kvm, kvm-intel

Module kvm loaded

Module kvm-intel loaded

 

VT-BOOTSTRAP FINISHED

 类似资料: