Main subroutine to execute test.
Run before test run starts. Check host healthy state and do logs cleanup.
Actual test is executed in this subroutine which needs to be overloaded in test module which uses this module as base.
Run after test run finishes. Judge overall test run result and die if test fails.
Get role (parent or children) of job based on whether PARALLEL_WITH is given.
Create barriers to be used for synchronization between peers.
Any subroutine calls this set_test_run_progress will set TEST_RUN_PROGRESS to the name of FILE::SUBROUTINE. If argument token is not empty, it will be added to the end of the name of FILE::SUBROUTINE.
Return TEST_RUN_PROGRESS of peer or self job depends on whether argument peer is set (1) or not (0);
Return TEST_RUN_RESULT of peer or self job depends on whether argument peer is set (1) or not (0);
Initialization information about local host and save it into variables.
Initialization information about peer, save it into variables and setup passwordless ssh connection to it.
Get peer job info and variables.
Configure SSH Public Key Authentication to host or guest. Main arguments are address to which ssh connects, whether overwrite (1) or not (0) existing keys, either host (1) or guest (0) on which operation will be done and whether die (1) or not (0) if any failures happen.
Check source and destination hosts have the same architecture, otherwise test run can not proceed.
Check source and destination hosts operating system version. Guest migration can not be done from the newer to the older. Main argument is host role (src or dst).
Check virtualization modules and services are ready, otherwise test run can not proceed.
Install necessary packages to facilitate test run down the road. Main argument is packages to be installed.
Check source and destination hosts have the same user id for user qemu. If any discrepancy, set the same group id on both side by using the value provided in _user.
Check source and destination hosts have the same group id for groups qemu, kvm and libvirt. If any discrepancy, set the same group id on both side by using the value provided in _group.
Configure shared nfs storage on server and mount it on client. Main arguments are type of shared storage, path of exported shared storage, server or client , original source path on server and mount path on server and client.
Get rid of limitations come from security services and rules which may have impact on connectivity between host and guest.
Obtain all guests to be tested, either from test suite level setting GUEST_LIST or those already on host. Destination host retrieves such information from source. At last, initialize guest_matrix to empty.
Initialize hash structure test_result, which contains all tests specified by test suite level setting GUEST_MIGRATION_TEST, to 'FAILED' and TEST_RUN_RESULT to empty. The detailed test commands are stored in guest_migration_matrix.
Save guest xml config for use down the road. Main arguments are guest to be manipulated , directory in which xml config is stored and whether die (1) or not (0) if any failures happen. This subroutine also calls construct_uri to determine the desired URI to be used if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.
Find guest disk and xml config with domain name, restore them to their original names and places. Main arguments are guest to be manipulated, whether die (1) or not (0) if any failures happen, directories in which guest asset and config are stored. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.
Configure guest clock to kvm-clock or tsc. Please refer to guest migration requirements: https://susedoc.github.io/doc-sle/main/single-html/SLES-virtualization/#libvirt-admin-live-migration-requirements Main arguments are guest to be configured, directory in which guest xml config is stored and whether die (1) or not (0) if any failures happen.
Configure guest storage cache mode to none. Please refer to guest migration requirements: https://susedoc.github.io/doc-sle/main/single-html/SLES-virtualization/#libvirt-admin-live-migration-requirements Main arguments are guest to be configured, directory in which guest xml config is stored and whether die (1) or not (0) if any failures happen.
Configure serial console for guest by using libguestfs tools. Main arguments are guest to be configured, directory in which guest xml config is stored and whether die (1) or not (0) if any failures happen. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.
Start guest by using virsh start and wait for it up and running if necessary. Main arguments are guest to start, virtualization management tool to be used, whether restart (1) or not (0), whether die (1) or not (0) if any failures happen and whether wait (1) or not (0) for guest up and running. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.
Wait for guest up and running by obtaining ip address, adding mapping in /etc/hosts, and calling wait_guest_ssh. Main arguments are guest to wait, whether check ip address (1) or not (0) and whether die (1) or not (0) if any failures happen.
Detect whether guest ssh port is open by using nc. Main arguments are guest to be detected, times of retry and whether die (1) or not (0) if any failures happen.
Check and obtain guest network configuration. Guest xml config contains enough information about network to which guest connects on boot, for example: <interface type="network"> <mac address="00:16:3e:4f:5a:35"/> <source network="vnet_nat"/> </interface> or <interface type='bridge'> <mac address='52:54:00:70:9d:b2'/> <source bridge='br123'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> </interface> Interface type, source network/bridge name and model type are those useful ones determine the network, they will be stored in guest_matrix{guest}{nettype}, guest_matrix{guest}{netname} and guest_matrix{guest}{netmode}. In order to obtain netmode conveniently and consistently, netname should take the form of "vnet_" + "nat/route/host" + "_other_strings" if virtual network to be used. Addtionally, guest_matrix{guest}{macaddr} is also upated by querying domiflist and ip address guest_matrix{guest}{ipaddr} can also be obtained from lib/virt_autotest/common.pm if static ip address is being used. The main arguments are guest to be checked and directory in which guest xml config is stored. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.
Check and obtain guest ip address. If static ip address is being used, there is no need to check it anymore. If guest uses bridge device directly, its ip address can be obtained by querying journal log or scanning subnet by using nmap (if host bridge device br0 is being used directly) with mac address. If guest uses virtual network created by virsh, its ip address can be obtained by querying dhcp leases of the virtual network or scanning subnet by using nmap (if host bridge device is being used in the virtual network directly) with mac address. The main arguments is guest to be checked. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.
Create network, type of which is either network or bridge, to be used with guest. In order to make this work consistent, data in hash structure guest_network_matrix will be used for network creating, and the network name should begin with "vnet_" followed by "nat", "route" or "host" if network type is "network", or be "br0" or "br123" if network type is "bridge". For guest using static ip address, network address info is derived from guest ip address. Main arguments are guest to be served, the directory in which network xml config will be stored and whether die (1) or not (0) if any error.This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.
Initialize guest matrix and associated variables. If variables are not empty, then update them. These variables will be shared between source and destination host to facilitate collaborative operations. On source host, putting values of variables into corresponding arrays which will be filled up or updated by calling fill_up_array. At last, storing updated values in arrays in variables. On destination host, initialize or update variables by retrieving corresponding information from source.
Fill up or update existing array which contains information about running guest, mac address, ip address, network type, network name, network mode and use static ip (yes) or not (no). Updated array will be used to set corresponding variables, for example, GUEST_UNDER_TEST_IPADDR. Main arguments are reference to the array, guest to be involved and variable related. Guest attribute name is derived from corresponding variable, for example, guest_matrix{guest}{netmode} is derived from GUEST_UNDER_TEST_NETMODE. At last, array will be filled up or updated by the latest guest_matrix{guest}{attribute}.
Test networking accessibility of guest. All guests should can be reached on host and can reach outside from inside. The only guest that can be reached from outside host is the one uses host bridge network. Main arguments are guest to be tested and whether die (1) or not (0) if any error.
Test whether writing into guest disk is successful and return the result. Main arguments are guest to be tested and whether die (1) or not (0) if any error.
Perform basic administration on guest and return overall result. Main arguments are guest to be manipulated, virttool (virsh or xl) to be used, directory in which original guest config file resides and whether die (1) or not (0) if any error. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.
Perform manual postcopy guest migration which needs an extra command to be executed alongside main migration command. The return value of this extra command indicates whether it is a successful manual postcopy guest migration. Main arguments are guest to be migrated, main migraiton command and whether die (1) or not (0) if any error.
Create xml file to be parsed by parse_junit_log by using XML::LibXML. The data source is a hash structure like test_result which stores test results and some other side information like product and time.
Create xml elements that may have attributes, text or child and return array of created elements. Accepted arguments are references to xml doc object, parent of element to be created, array of elements to be created, array of attributes of elements and array of texts of elements. The order in which elements appear in array of elements to be created should be the same as those respective attributes and texts in their arrays.
Check progress of test run of peer job. This subroutine is called to verify whether peer job is destined to fail or not and return its test run result. This is usually called by paired job that is already in post_fail_hook to wait for peer job if it already failed or is about to fail, so the peer job can finish operations instead of being cancelled due to paired job fails and terminates. This can be achieved simply by barrier_wait on certain lock by both jobs if the peer fails as well. There are situations in which peer job needs to move pass current running subroutines like, do_guest_migration or post_run_test, before entering into post_fail_hook, so it is necessary to wait a period before having the final resolution. But if peer job still remains any earlier steps, it is not meaningful to wait anymore because locks ahead.
Filters migration tests based on specified criteria.
Set TEST_RUN_RESULT to FAILED, create junit log and collect logs.