autotest workshop

Jetzt loslegen. Gratis!
oder registrieren mit Ihrer E-Mail-Adresse
Rocket clouds
autotest workshop von Mind Map: autotest workshop

1. Presenters

1.1. Lukáš Doktor

1.2. Jiří Župka

1.3. Autotest maintainers and developers

1.4. Red Hat Czech emloyees

2. Content

2.1. Introduction(20)

2.1.1. autotest

2.1.1.1. purpose

2.1.1.1.1. testing systems, kernel, virtualization, .....

2.1.1.1.2. google use it for testing chrome OS

2.1.1.2. before start

2.1.1.2.1. Autotest

2.1.1.2.2. Autotest in IDE eclipse

2.1.1.2.3. Download sources

2.1.1.3. structure

2.1.1.3.1. overall-structure

2.1.1.4. tests

2.1.1.4.1. clasic autetest test

2.1.1.4.2. structure

2.1.1.4.3. how to start

2.1.1.4.4. results

2.1.1.4.5. virttest

2.2. virttest (30-60)

2.2.1. Basics (10)

2.2.1.1. https://github.com/autotest/virt-test/wiki/GetStarted

2.2.1.2. git clone --recursive git://github.com/autotest/autotest.git

2.2.1.3. cd autotest/client/tests/virt

2.2.1.4. AUTOTEST_PATH=../../../ ./run -t qemu --list-tests

2.2.1.5. AUTOTEST_PATH=../../../ ./run -t qemu --tests='boot' -v

2.2.1.6. vncviewer :0

2.2.2. Hello_world (15-45)

2.2.2.1. basic test

2.2.2.1.1. drop-in echo test

2.2.2.1.2. hello world 2.0

2.2.2.1.3. cruel world 2.0

2.2.2.1.4. virtualized hello world

2.2.2.2. params

2.2.2.2.1. ls_disk

2.2.2.3. vm.monitor.cmd()

2.2.2.3.1. ls_disk

2.2.3. automatic machine install (5)

2.2.3.1. --tests="io-github-autotest-qemu.unattended_install.cdrom.extra_cdrom_ks.default_install.aio_native" --guest=Fedora.19.x86_64 -k --keep-image-between-tests

2.2.3.2. --tests="io-github-autotest-qemu.install io-github-autotest-qemu.setup" --guest=Win7.x86_64.sp1

2.2.3.2.1. set licence number to set licence number to shared/cfg/cdkeys.cfg

2.3. Eclipse (15-30)

2.3.1. prepare for python

2.3.1.1. install pydev

2.3.1.1.1. http://pydev.org/updates/

2.3.1.2. install egit

2.3.1.2.1. http://download.eclipse.org/egit/updates

2.3.2. New project

2.3.2.1. https://github.com/autotest/autotest/wiki/Using-Eclipse-with-autotest

2.3.2.2. enable code_analysis

2.3.3. Git

2.3.3.1. Working with Submodule

2.3.3.2. annotation

2.3.4. Debugging

2.3.4.1. test

2.3.4.2. env_preprocess

2.3.4.3. Remote debuging pydev

2.3.4.3.1. on guest

2.3.5. Playing with

2.3.5.1. ctrl+click

2.3.5.1.1. jump to the definition

2.3.5.2. ctrl+1

2.3.5.2.1. quick changes

2.3.5.3. ctrl+h

2.3.5.3.1. search

2.3.5.4. ctrl+shift+f. ctrl+shift+o

2.3.5.4.1. format code and imports

2.3.5.5. ctrl+space

2.3.5.5.1. finish word

2.3.5.6. pep8, pylint

2.4. params (15)

2.4.1. test cart configs

2.4.1.1. repair config from freemind

2.4.1.1.1. sed -i -e 's/\xc2\xa0/ /g' config_name

2.4.1.2. list dicts

2.4.1.2.1. [dir virt]virttest/cartesian_config.py config_name

2.4.1.3. list dicts with content

2.4.1.3.1. [dir virt]virttest/cartesian_config.py -c config_name

2.4.2. example

2.4.2.1. general_param = abc variants:     - long:         time = long     - short:         time = short variants guest_os:     - linux:         var2 = str1     - windows:         var2 = str2 variants host_os:     - linux:         hostvar = strlinux     - windows:         hostvar = strwin only (host_os=linux)

2.4.2.1.1. dict    1:  linux.linux.long     _name_map_file = {'aaa.cfg': '(host_os=linux).(guest_os=linux).long'}     _short_name_map_file = {'aaa.cfg': 'linux.linux.long'}     dep = []     general_param = abc     guest_os = linux     host_os = linux     hostvar = strlinux     name = (host_os=linux).(guest_os=linux).long     shortname = linux.linux.long     time = long     var2 = str1 dict    2:  linux.linux.short     _name_map_file = {'aaa.cfg': '(host_os=linux).(guest_os=linux).short'}     _short_name_map_file = {'aaa.cfg': 'linux.linux.short'}     dep = []     general_param = abc     guest_os = linux     host_os = linux     hostvar = strlinux     name = (host_os=linux).(guest_os=linux).short     shortname = linux.linux.short     time = short     var2 = str1 dict    3:  linux.windows.long     _name_map_file = {'aaa.cfg': '(host_os=linux).(guest_os=windows).long'}     _short_name_map_file = {'aaa.cfg': 'linux.windows.long'}     dep = []     general_param = abc     guest_os = windows     host_os = linux     hostvar = strlinux     name = (host_os=linux).(guest_os=windows).long     shortname = linux.windows.long     time = long     var2 = str2 dict    4:  linux.windows.short     _name_map_file = {'aaa.cfg': '(host_os=linux).(guest_os=windows).short'}     _short_name_map_file = {'aaa.cfg': 'linux.windows.short'}     dep = []     general_param = abc     guest_os = windows     host_os = linux     hostvar = strlinux     name = (host_os=linux).(guest_os=windows).short     shortname = linux.windows.short     time = short     var2 = str2

2.4.3. advanced example

2.4.3.1. variants guest_os:     - linux:         var2 = str1         var2 += append     - windows:         var2 = str2 variants host_os:     - linux:         hostvar = strlinux         hostvar <= prepend         no after     - windows:         hostvar = strwin variants:     - long:         time = long         (guest_os=linux):               start_time = short     - short:         time = short ${str(var2) + "=" + str(2+3)} only (host_os=linux)

2.4.3.1.1. dict    1:  long.linux.linux     (guest_os = linux):     _name_map_file = {'aaa.cfg': 'long.(host_os=linux).(guest_os=linux)'}     _short_name_map_file = {'aaa.cfg': 'long.linux.linux'}     dep = []     guest_os = linux     host_os = linux     hostvar = prependstrlinux     name = long.(host_os=linux).(guest_os=linux)     shortname = long.linux.linux     start_time = short     time = long     var2 = str1append dict    2:  long.linux.windows     (guest_os = linux):     _name_map_file = {'aaa.cfg': 'long.(host_os=linux).(guest_os=windows)'}     _short_name_map_file = {'aaa.cfg': 'long.linux.windows'}     dep = []     guest_os = windows     host_os = linux     hostvar = prependstrlinux     name = long.(host_os=linux).(guest_os=windows)     shortname = long.linux.windows     start_time = short     time = long     var2 = str2 dict    3:  short.linux.linux     _name_map_file = {'aaa.cfg': 'short.(host_os=linux).(guest_os=linux)'}     _short_name_map_file = {'aaa.cfg': 'short.linux.linux'}     dep = []     guest_os = linux     host_os = linux     hostvar = prependstrlinux     name = short.(host_os=linux).(guest_os=linux)     shortname = short.linux.linux     time = short str1append=5     var2 = str1append dict    4:  short.linux.windows     _name_map_file = {'aaa.cfg': 'short.(host_os=linux).(guest_os=windows)'}     _short_name_map_file = {'aaa.cfg': 'short.linux.windows'}     dep = []     guest_os = windows     host_os = linux     hostvar = prependstrlinux     name = short.(host_os=linux).(guest_os=windows)     shortname = short.linux.windows     time = short str2=5     var2 = str2

2.4.4. syntax

2.4.4.1. +=

2.4.4.1.1. append

2.4.4.2. <=

2.4.4.2.1. prepend

2.4.4.3. =

2.4.4.3.1. asignation

2.4.4.4. ${}

2.4.4.4.1. eval stement in python

2.4.4.5. ""

2.4.4.5.1. take like a string

2.4.4.6. only filter

2.4.4.6.1. take only variants which contain variant subvariant filter

2.4.4.7. no filter

2.4.4.7.1. do not take variant which contain subvariant filter

2.4.4.8. filter:

2.4.4.8.1. do something when variants variant contain varitnat filter

2.4.4.9. filter

2.4.4.9.1. and

2.4.4.9.2. or

2.4.4.9.3. named filter

2.4.4.10. variants

2.4.4.10.1. variants:     - long:         time = long     - short:         time = short

2.4.4.10.2. named variants

2.5. multi-host support (10)

2.5.1. Prepare Virt env

2.5.1.1. ssh-copy-id [email protected]

2.5.1.2. set shared disk to hosts(NFS)

2.5.2. start tcp migration tests

2.5.2.1. change configuration in multi-host-tests.cfg

2.5.2.2. sudo ../../../../server/autoserv -m ip_host1,ip_host2 multi_host.srv

2.5.3. explain bariers

2.6. Git (15)

2.6.1. Submodule

2.6.1.1. clone

2.6.1.1.1. git clone –recursive

2.6.1.2. add submodule

2.6.1.2.1. git submodule add git://github.com/my/submodule.git ./subm

2.6.1.3. Fetch submodules

2.6.1.3.1. git submodule update --init

2.6.1.4. Pull changes

2.6.1.4.1. git pull origin/master

2.6.1.4.2. git submodule update

2.6.2. remote

2.6.2.1. git remote add reponame repopath

2.6.2.1.1. git remote add ldoktor https://github.com/ldoktor/virt-test.git

2.6.2.2. git fetch reponame

2.6.2.2.1. git fetch ldoktor

2.6.2.3. git checkout -t reponame/branch

2.6.2.3.1. git checkout -t ldoktor/cpu

2.6.3. Github

2.6.3.1. workflow

2.6.3.1.1. review

2.6.3.1.2. new patch

2.6.3.2. pullrequest

2.6.3.3. issue

3. Bonus

3.1. formating patches

3.1.1. run_pep8 and run_pylint

3.1.2. split patch by "git citool"

3.1.3. send to github

3.2. testing patches

3.2.1. tools/check_patch.py

3.3. multi_disk test

3.3.1. walkthrough

3.3.2. qemu_devices

3.3.3. qtree_verification

3.4. modifying params in test

3.4.1. process_image()

3.4.1.1. multi_disk.py

3.4.2. process_vm()

3.4.2.1. virtio_console.py

3.5. command v shelu VM aexpect

3.5.1. interactive command

3.6. qemu_devices

3.6.1. structure

3.6.2. goal

3.6.3. stored information

3.6.4. hotplug

3.6.4.1. pci_devices.py

3.7. Funcatexit

3.7.1. Alternative to try/catch

3.7.2. Easier and much nicer

3.7.3. virtio_console.py

3.8. Services

3.8.1. shared/service.py

3.8.1.1. ServiceManager

3.8.1.2. SpecificServiceManager

3.8.1.3. start, stop, status, ...

3.8.2. init/systemd

3.8.3. example

3.8.3.1. service.py

3.8.3.1.1. """ simple service handling test :copyright: 2014 Red Hat Inc. """ import logging import time from autotest.client import utils from autotest.client.shared import error from autotest.client.shared.service import SpecificServiceManager from virttest import remote @error.context_aware def run(test, params, env): """ Logs guest's hostname. 1) Decide whether use host/guest 2) Check current service status 3) Start (Stop) $service 4) Check status of $service 5) Stop (Start) $service 6) Check service status :param test: QEMU test object :param params: Dictionary with the test parameters :param env: Dictionary with test environment. """ if params.get('test_on_guest') == "yes": error.context("Using guest.", logging.info) vm = env.get_vm(params["main_vm"]) session = vm.wait_for_login() runner = remote.RemoteRunner(session=session).run else: error.context("Using host", logging.info) runner = utils.run error.context("Initialize service manager", logging.info) service = SpecificServiceManager(params["test_service"], runner) error.context("Testing service %s" % params["test_service"], logging.info) original_status = service.status() logging.info("Original status=%s", original_status) if original_status is True: service.stop() time.sleep(5) if service.status() is not False: logging.error("Fail to stop service") service.start() raise error.TestFail("Fail to stop service") service.start() else: service.start() time.sleep(5) if service.status() is not True: logging.error("Fail to start service") service.stop() raise error.TestFail("Fail to start service") service.start() time.sleep(5) if not service.status() is original_status: raise error.TestFail("Fail to restore original status of the %s " "service" % params["test_service"])

3.8.3.2. cfg/service.cfg

3.8.3.2.1. - service: install setup image_copy unattended_install.cdrom virt_test_type = libvirt qemu type = service requires_root = yes variants: - ntpdate_service: test_service = ntpdate - smb_service: test_service = smb variants: - test_guest: test_on_guest = yes - test_host: vms = "" test_on_guest = no

3.9. Software manager

3.9.1. shared/software_manager.py

3.9.1.1. SoftwareManager

3.9.1.2. install, remove, provides, list_all, list_files, ...

3.9.2. Atp, Yum, Zypper

3.9.3. v2v/tests/install.py

3.10. Advanced Eclipse

3.10.1. Github

3.10.1.1. task

3.11. Explosion

3.11.1. autotest freezes while initialization

3.11.1.1. --no-downloads

3.11.2. cleanup environment

3.11.2.1. #!/bin/bash sudo killall run sudo killall autotest sudo killall autotest-local sudo killall qemu-system-x86_64 sudo killall qemu-kvm sudo killall qemu rm -f env sudo rm -f /tmp/address_pool* sudo rm -f /tmp/__db.address_pool

3.11.3. --list-tests

3.11.3.1. name_change

3.11.3.2. directory changed

3.11.4. --list-guests

3.11.4.1. x86_64 vs. 64