Общие сведения

ВступлениеПодготовка к запускуАрхитектура платформы TestoПорядок запускаПолитика запуска тестов

Обучающие материалы по Testo для Hyper-V

Часть 1. Самый первый тестЧасть 2. Устанавливаем Ubuntu ServerЧасть 3. Доступ в Интернет из виртуальной машиныЧасть 4. Гостевые дополненияЧасть 5. ПараметрыЧасть 6. КешированиеЧасть 7. Связываем две машины по сетиЧасть 8. ФлешкиЧасть 9. МакросыЧасть 10. Конструкция ifЧасть 11. No snapshotsЧасть 12. Управление мышкойЧасть 13. Импортирование жёстких дисковЧасть 14. JS-селекторыЧасть 15. Циклы

Обучающие материалы по Testo для QEMU

Часть 1. Самый первый тестЧасть 2. Устанавливаем Ubuntu ServerЧасть 3. Гостевые дополненияЧасть 4. ПараметрыЧасть 5. КешированиеЧасть 6. Доступ в Интернет из виртуальной машиныЧасть 7. Связываем две машины по сетиЧасть 8. ФлешкиЧасть 9. МакросыЧасть 10. Конструкция ifЧасть 11. No snapshotsЧасть 12. Управление мышкойЧасть 13. Импортирование жёстких дисковЧасть 14. JS-селекторыЧасть 15. ЦиклыЧасть 16. Макросы с объявлениями

Спецификация языка

Общая структура скриптовых файловБазовые конструкции языкаOбъявление виртуальной машиныОбъявление виртуального флеш-накопителяОбъявление виртуальной сетиПараметрыОбъявление тестовМакросыДействия с виртуальными машинамиДействия с мышкойПоиск изображений на экранеДействия с виртуальными флеш-накопителямиУсловияЦиклыСписок идентификаторов клавиш

Запросы на языке Javascript

Общая концепция построения JS-селекторовВстроенные глобальные функции JavascriptИсключенияКласс TextTensorКласс ImgTensorКласс Point

Часть 16. Макросы с объявлениями

С чем Вы познакомитесь

В этой части вы познакомитесь с новым типом макросов в платформе Testo: макросы с объявлениями.

Начальные условия

  1. Платформа Testo установлена.
  2. Установлен менеджер виртуальных машин virt-manager.
  3. На хостовой машине имеется доступ в Интернет
  4. Имеется установочный образ Ubuntu server 16.04 с расположением /opt/iso/ubuntu_server_16.iso. Местоположение и название установочного файла может быть другим, в этом случае нужно будет соответствующим образом поправить параметр ISO_DIR, передаваемый через командную строку во время запуска тестов.
  5. Имеется установочный образ Ubuntu server 20.04 с расположением /opt/iso/ubuntu_server_20.iso. Местоположение и название установочного файла может быть другим, в этом случае нужно будет соответствующим образом поправить параметр ISO_DIR, передаваемый через командную строку во время запуска тестов.
  6. Имеется образ с гостевыми дополнениями Testo в одной папке с установочным образом Ubuntu.
  7. (Рекомендовано) Настроена подсветка синтаксиса Testo-lang в Sublime Text 3.
  8. (Рекомендовано) Проделаны шаги из девятой части.

Вступление

Механизм макросов играет важную роль в платформе Testo. Макросы позволяют объединять схожие участки кода в именованные блоки, которые затем можно удобно использовать, не вникая в особенности реализации этих блоков. В девятой части туториалов мы уже познакомились с механизмом макросов в платформе Testo: мы посмотрели как можно объединять в макросы различные действия (макросы с действиями) и даже команды (макросы с командами). Всё это позволяет значительно снизить количество копи-пасты в ваших тестовых сценариях.

Однако есть ещё один тип макросов, с которым вам необходимо познакомиться, чтобы пользоваться возможностями Testo-lang в полном объеме: макросы с объявлениями. Этот тип макросов позволит вам объединять в блоки целые группы тестов и даже стенды.

С чего начать?

Чтобы лучше понять смысл использования макросов с объявлениями, давайте вернемся к девятой части наших гайдов. К той части, в которой мы познакомились с макросами. Давайте не поленимся и вспомним как выглядит наш тестовый сценарий на момент окончания туториала:

Файл declarations.testo:

network internet {
    mode: "nat"
}

network LAN {
    mode: "internal"
}

param guest_additions_pkg "testo-guest-additions*"
param default_password "1111"

param client_hostname "client"
param client_login "client-login"

machine client {
    cpus: 1
    ram: 512Mb
    disk main: {
        size: 5Gb
    }
    iso: "${ISO_DIR}/ubuntu_server.iso"

    nic nat: {
        attached_to: "internet"
    }

    nic server_side: {
        attached_to: "LAN"
        mac: "52:54:00:00:00:AA"
    }
}

param server_hostname "server"
param server_login "server-login"

machine server {
    cpus: 1
    ram: 512Mb
    disk main: {
        size: 5Gb
    }
    iso: "${ISO_DIR}/ubuntu_server.iso"

    nic nat: {
        attached_to: "internet"
    }

    nic client_side: {
        attached_to: "LAN"
        mac: "52:54:00:00:00:BB"
    }
}

flash exchange_flash {
    fs: "ntfs"
    size: 8Mb
    folder: "./folder_to_copy"
}

Файл macros.testo:

include "declarations.testo"

macro install_ubuntu(hostname, login, password = "${default_password}") {
    ...
}


macro install_guest_additions(hostname, login, password="${default_password}") {
    ...
}

macro unplug_nic(hostname, login, nic_name, password="${default_password}") {
    ...
}

# A macro encapsulating several actions:
# 1) Plugging a flash drive
# 2) Mounting the flash drive into the filesystem
# 3) Executing a bash script
# 4) Unmounting the flash drive from the filesystem
# 5) Unplugging the flash drive
macro process_flash(flash_name, command) {
    plug flash "${flash_name}"
    sleep 5s
    exec bash "mount /dev/sdb1 /media"
    exec bash "${command}"
    exec bash "umount /media"
    unplug flash "${flash_name}"
}

# A command macro suitable for copying a file between arbitrary vms
# Copies a file from vm to /media/filename on the flash
# Copies a file from the flash to another vm
macro copy_file_with_flash(vm_from, vm_to, copy_flash, file_from, file_to) {
    "${vm_from}" process_flash("${copy_flash}", "cp ${file_from} /media/$(basename ${file_from})")
    "${vm_to}" process_flash("${copy_flash}", "cp /media/$(basename ${file_from}) ${file_to}")
}

Файл tests.testo:

include "macros.testo"

test server_install_ubuntu {
    server install_ubuntu("${server_hostname}", "${server_login}")
}

test server_install_guest_additions: server_install_ubuntu {
    server install_guest_additions("${server_hostname}", "${server_login}")
}

test server_unplug_nat: server_install_guest_additions {
    server unplug_nic("${server_hostname}", "${server_login}", "nat")
}

test server_prepare: server_unplug_nat {
    server {
        copyto "./rename_net.sh" "/opt/rename_net.sh"
        exec bash """
            chmod +x /opt/rename_net.sh
            /opt/rename_net.sh 52:54:00:00:00:bb client_side
            ip a a 192.168.1.1/24 dev client_side
            ip l s client_side up
            ip ad
        """
    }
}

test client_install_ubuntu {
    client install_ubuntu("${client_hostname}", "${client_login}")
}

test client_install_guest_additions: client_install_ubuntu {
    client install_guest_additions("${client_hostname}", "${client_login}")
}

test client_unplug_nat: client_install_guest_additions {
    client unplug_nic("${client_hostname}", "${client_login}", "nat")
}

test client_prepare: client_unplug_nat {
    client {
        process_flash("exchange_flash", "cp /media/rename_net.sh /opt/rename_net.sh")

        exec bash """
            chmod +x /opt/rename_net.sh
            /opt/rename_net.sh 52:54:00:00:00:aa server_side
            ip a a 192.168.1.2/24 dev server_side
            ip l s server_side up
            ip ad
        """
    }
}

test test_ping: client_prepare, server_prepare {
    client exec bash "ping 192.168.1.2 -c5"
    server exec bash "ping 192.168.1.1 -c5"
}

# Take a note, that the test is inherited not from
# the test_ping, but from the client_prepare and
# server_prepare tests.
# Which means that test_ping and exchange_files_with_flash
# both lay on the samy tests tree level
test exchange_files_with_flash: client_prepare, server_prepare {
    #Create a file to be transferred
    client exec bash "echo \"Hello from client!\" > /tmp/copy_me_to_server.txt"
    copy_file_with_flash("client", "server", "exchange_flash", "/tmp/copy_me_to_server.txt", "/tmp/copy_me_to_server.txt")
    server exec bash "cat /tmp/copy_me_to_server.txt"
}

Выглядит довольно лаконично и понятно, не так ли? Действительно, мы проделали хорошую работу в том туториале и смогли разложить весь код по полочкам, минимизировав копи-пасту и убрав всю путаницу.

Однако давайте представим такую ситуацию: что если нам нужно проверить что эти тесты выполняются как на Ubuntu server 16.04, так и на Ubuntu server 20.04? На текущих машинах установлена Ubuntu 16.04, так что для осуществления задуманого нам понадобится ещё две машины (не забудем переименовать существующие машины, чтобы не запутаться в них). Для полноты картины давайте также представим, что мы хотим соединять эти машины разными сетями и использовать для копирования файлов разные флешки:

declarations.testo:

param guest_additions_pkg "testo-guest-additions*"
param default_password "1111"

param client_hostname "client"
param client_login "client-login"

param server_hostname "server"
param server_login "server-login"

network internet_16 {
    mode: "nat"
}

network LAN_16 {
    mode: "internal"
}

machine client_16 {
    cpus: 1
    ram: 512Mb
    disk main: {
        size: 5Gb
    }
    iso: "${ISO_DIR}/ubuntu_server_16.iso"

    nic nat: {
        attached_to: "internet_16"
    }

    nic server_side: {
        attached_to: "LAN_16"
        mac: "52:54:00:00:00:AA"
    }
}

machine server_16 {
    cpus: 1
    ram: 512Mb
    disk main: {
        size: 5Gb
    }
    iso: "${ISO_DIR}/ubuntu_server_16.iso"

    nic nat: {
        attached_to: "internet_16"
    }

    nic client_side: {
        attached_to: "LAN_16"
        mac: "52:54:00:00:00:BB"
    }
}

flash exchange_flash_16 {
    fs: "ntfs"
    size: 8Mb
    folder: "./folder_to_copy"
}

network internet_20 {
    mode: "nat"
}

network LAN_20 {
    mode: "internal"
}

machine client_20 {
    cpus: 1
    ram: 1Gb
    disk main: {
        size: 8Gb
    }
    iso: "${ISO_DIR}/ubuntu_server_20.iso"

    nic nat: {
        attached_to: "internet_20"
    }

    nic server_side: {
        attached_to: "LAN_20"
        mac: "52:54:00:00:00:AA"
    }
}

machine server_20 {
    cpus: 1
    ram: 1Gb
    disk main: {
        size: 8Gb
    }
    iso: "${ISO_DIR}/ubuntu_server_20.iso"

    nic nat: {
        attached_to: "internet_20"
    }

    nic client_side: {
        attached_to: "LAN_20"
        mac: "52:54:00:00:00:BB"
    }
}

flash exchange_flash_20 {
    fs: "ntfs"
    size: 8Mb
    folder: "./folder_to_copy"
}

Обратите внимание, что для Ubuntu 20 нам пришлось указать большее количество оперативной памяти и размера диска. Со старыми значениями Ubuntu 20 не работает.

А что же с тестами? Какие изменения нужно будет внести в тестах? Хотелось бы просто скопировать все тесты для Ubuntu 16 и подправить только названия виртуальных машин в них... Но не всё так просто.

Во-первых, процессы установки Ubuntu Server 20.04 и 16.04, очевидно, заметно отличаются. А значит, нам потребуется новый макрос:

macro install_ubuntu_server_20(nat_interface, hostname, login, password = "${default_password}") {
    unplug nic "${nat_interface}"
    start
    if (check "Language" timeout 5s) {
        press Enter
        wait "Install Ubuntu Server"; press Enter
    }
    wait "Welcome!" timeout 5m; press Enter

    wait "Please select your keyboard layout"; press Enter
    wait "Configure at least one interface"; press Enter
    wait "Proxy address"; press Enter
    wait "Mirror address"; press Enter
    wait "Continue without updating"; press Enter
    wait "Use an entire disk"; press Down*5; wait js "find_text().match('Done').match_background('green').size() > 0"; press Enter
    wait "FILE SYSTEM SUMMARY"; press Enter
    wait "Confirm destructive action"; press Down, Enter
    wait "Enter the username"; type "${login}"; press Tab
    type "${hostname}"; press Tab
    type "${login}"; press Tab
    type "${password}"; press Tab
    type "${password}"; press Enter*2
    wait "SSH Setup"; press Tab, Enter
    wait "Installing system"
    wait "Installation complete!" timeout 15m
    press Enter
    wait "Please remove the installation medium"
    unplug dvd; press Enter
    wait "${hostname} login" timeout 3m

    stop; plug nic "${nat_interface}"; start

    wait "GNU GRUB"; press Enter

    wait "${hostname} login" timeout 3m
    type "${login}"; press Enter
    wait "Password"; type "${password}"; press Enter

    wait "${login}@${hostname}"
}

Старый макрос мы переименуем в install_ubuntu_server_16 чтобы не путаться.

А теперь попробуем объединить оба макроса в один:

macro install_ubuntu_server(version, nat_interface, hostname, login, password = "${default_password}") {
    if ("${version}" STREQUAL "16") {
        install_ubuntu_server_16("${hostname}", "${login}", "${password}")
    } else if ("${version}" STREQUAL "20") {
        install_ubuntu_server_20("${nat_interface}","${hostname}", "${login}", "${password}")
    } else {
        abort "Unknown version:  ${version}"
    }
}

Теперь за установку ОС разных версий отвечает один макрос, который принимает на вход номер версии ОС. После чего на основе номера версии происходит выбор нужного "частного" макроса.

С этим вопросом разобрались, двигаемся дальше.

Во-вторых, rename_net.sh не будет работать в Ubuntu 20.04, потому что в 20 версии нет утилиты ipconfig. Эту проблему можно уладить, если добавить новый скрипт rename_net_20.sh, где механизм поиска имени интерфейса будет реализован через утилиту ip:

#!/bin/bash

set -e

mac=$1

oldname=`ip -o link | grep ${mac,,} | awk '{print substr($2, 1, length($2) - 1)}'`
newname=$2

echo SUBSYSTEM==\"net\", ACTION==\"add\", ATTR{address}==\"$mac\", NAME=\"$newname\", DRIVERS==\"?*\" >> /lib/udev/rules.d/70-test-tools.rules

rm -f /etc/network/interfaces
echo source /etc/network/interfaces.d/* >> /etc/network/interfaces
echo auto lo >> /etc/network/interfaces
echo iface lo inet loopback >> /etc/network/interfaces

ip link set $oldname down
ip link set $oldname name $newname
ip link set $newname up

echo "Renaming success"

Старый файл rename_net.sh мы переименуем в rename_net_16.sh, чтобы не запутаться.

В остальном - все тесты для Ubuntu 16 и 20 полностью идентичны. Поэтому осталось собрать всё воедино и получить такой файл tests.testo:

include "macros.testo"

test server_16_install_ubuntu {
    server_16 install_ubuntu_server("16", "nat", "${server_hostname}", "${server_login}")
}

test server_16_install_guest_additions: server_16_install_ubuntu {
    server_16 install_guest_additions("${server_hostname}", "${server_login}")
}

test server_16_unplug_nat: server_16_install_guest_additions {
    server_16 unplug_nic("${server_hostname}", "${server_login}", "nat")
}

test server_16_prepare: server_16_unplug_nat {
    server_16 {
        copyto "./rename_net_16.sh" "/opt/rename_net.sh"
        exec bash """
            chmod +x /opt/rename_net.sh
            /opt/rename_net.sh 52:54:00:00:00:bb client_side
            ip a a 192.168.1.1/24 dev client_side
            ip l s client_side up
            ip ad
        """
    }
}

test client_16_install_ubuntu {
    client_16 install_ubuntu_server("16", "nat", "${client_hostname}", "${client_login}")
}

test client_16_install_guest_additions: client_16_install_ubuntu {
    client_16 install_guest_additions("${client_hostname}", "${client_login}")
}

test client_16_unplug_nat: client_16_install_guest_additions {
    client_16 unplug_nic("${client_hostname}", "${client_login}", "nat")
}

test client_16_prepare: client_16_unplug_nat {
    client_16 {
        process_flash("exchange_flash_16", "cp /media/rename_net_16.sh /opt/rename_net.sh")

        exec bash """
            chmod +x /opt/rename_net.sh
            /opt/rename_net.sh 52:54:00:00:00:aa server_side
            ip a a 192.168.1.2/24 dev server_side
            ip l s server_side up
            ip ad
        """
    }
}

test test_ping_16: client_16_prepare, server_16_prepare {
    client_16 exec bash "ping 192.168.1.2 -c5"
    server_16 exec bash "ping 192.168.1.1 -c5"
}

# Take a note, that the test is inherited not from
# the test_ping, but from the client_prepare and
# server_prepare tests.
# Which means that test_ping and exchange_files_with_flash
# both lay on the samy tests tree level
test exchange_files_with_flash_16: client_16_prepare, server_16_prepare {
    #Create a file to be transferred
    client_16 exec bash "echo \"Hello from client!\" > /tmp/copy_me_to_server.txt"
    copy_file_with_flash("client_16", "server_16", "exchange_flash_16", "/tmp/copy_me_to_server.txt", "/tmp/copy_me_to_server.txt")
    server_16 exec bash "cat /tmp/copy_me_to_server.txt"
}


test server_20_install_ubuntu {
    server_20 install_ubuntu_server("20", "nat", "${server_hostname}", "${server_login}")
}

test server_20_install_guest_additions: server_20_install_ubuntu {
    server_20 install_guest_additions("${server_hostname}", "${server_login}")
    server_20 {
        exec bash """
            ip l s ens7 up
            dhclient ens7
            apt install -y net-tools
        """
    }
}

test server_20_unplug_nat: server_20_install_guest_additions {
    server_20 unplug_nic("${server_hostname}", "${server_login}", "nat")
}

test server_20_prepare: server_20_unplug_nat {
    server_20 {
        copyto "./rename_net_20.sh" "/opt/rename_net.sh"
        exec bash """
            chmod +x /opt/rename_net.sh
            /opt/rename_net.sh 52:54:00:00:00:bb client_side
            ip a a 192.168.1.1/24 dev client_side
            ip l s client_side up
            ip ad
        """
    }
}

test client_20_install_ubuntu {
    client_20 install_ubuntu_server("20", "nat", "${client_hostname}", "${client_login}")
}

test client_20_install_guest_additions: client_20_install_ubuntu {
    client_20 install_guest_additions("${client_hostname}", "${client_login}")
    client_20 {
        exec bash """
            ip l s ens7 up
            dhclient ens7
            apt install -y net-tools
        """
    }
}

test client_20_unplug_nat: client_20_install_guest_additions {
    client_20 unplug_nic("${client_hostname}", "${client_login}", "nat")
}

test client_20_prepare: client_20_unplug_nat {
    client_20 {
        process_flash("exchange_flash_20", "cp /media/rename_net_20.sh /opt/rename_net.sh")

        exec bash """
            chmod +x /opt/rename_net.sh
            /opt/rename_net.sh 52:54:00:00:00:aa server_side
            ip a a 192.168.1.2/24 dev server_side
            ip l s server_side up
            ip ad
        """
    }
}

test test_ping_20: client_20_prepare, server_20_prepare {
    client_20 exec bash "ping 192.168.1.2 -c5"
    server_20 exec bash "ping 192.168.1.1 -c5"
}

# Take a note, that the test is inherited not from
# the test_ping, but from the client_prepare and
# server_prepare tests.
# Which means that test_ping and exchange_files_with_flash
# both lay on the samy tests tree level
test exchange_files_with_flash_20: client_20_prepare, server_20_prepare {
    #Create a file to be transferred
    client_20 exec bash "echo \"Hello from client!\" > /tmp/copy_me_to_server.txt"
    copy_file_with_flash("client_20", "server_20", "exchange_flash_20", "/tmp/copy_me_to_server.txt", "/tmp/copy_me_to_server.txt")
    server_20 exec bash "cat /tmp/copy_me_to_server.txt"
}

Давайте убедимся, что тесты запускаются и проходят:

user$ sudo testo run ./ --stop_on_fail --param ISO_DIR /opt/iso
TESTS TO RUN:
server_16_install_ubuntu
server_16_install_guest_additions
server_16_unplug_nat
server_16_prepare
client_16_install_ubuntu
client_16_install_guest_additions
client_16_unplug_nat
client_16_prepare
test_ping_16
exchange_files_with_flash_16
server_20_install_ubuntu
server_20_install_guest_additions
server_20_unplug_nat
server_20_prepare
client_20_install_ubuntu
client_20_install_guest_additions
client_20_unplug_nat
client_20_prepare
test_ping_20
exchange_files_with_flash_20
[ 0%] Preparing the environment for test server_16_install_ubuntu
[ 0%] Creating virtual machine server_16
[ 0%] Taking snapshot initial for virtual machine server_16
[ 0%] Running test server_16_install_ubuntu
[ 0%] Calling macro install_ubuntu_server(version="16", nat_interface="nat", hostname="server", login="server-login", password="1111") in virtual machine server_16
[ 0%] Calling macro install_ubuntu_server_16(hostname="server", login="server-login", password="1111") in virtual machine server_16
[ 0%] Starting virtual machine server_16
[ 0%] Waiting "English" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Install Ubuntu Server" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Choose the language" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Select your location" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Detect keyboard layout?" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Country of origin for the keyboard" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Keyboard layout" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Primary network interface" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Hostname:" for 5m with interval 1s in virtual machine server_16
[ 0%] Pressing key BACKSPACE 36 times in virtual machine server_16
[ 0%] Typing "server" with interval 30ms in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Full name for the new user" for 1m with interval 1s in virtual machine server_16
[ 0%] Typing "server-login" with interval 30ms in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Username for your account" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Choose a password for the new user" for 1m with interval 1s in virtual machine server_16
[ 0%] Typing "1111" with interval 30ms in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Re-enter password to verify" for 1m with interval 1s in virtual machine server_16
[ 0%] Typing "1111" with interval 30ms in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Use weak password?" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key LEFT in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Encrypt your home directory?" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Is this time zone correct?" for 2m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Partitioning method" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Select disk to partition" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Write the changes to disks and configure LVM?" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key LEFT in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Amount of volume group to use for guided partitioning" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Write the changes to disks?" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key LEFT in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "HTTP proxy information" for 3m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "How do you want to manage upgrades" for 6m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Choose software to install" for 1m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Install the GRUB boot loader to the master boot record?" for 10m with interval 1s in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Installation complete" for 1m with interval 1s in virtual machine server_16
[ 0%] Unplugging dvd from virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "server login:" for 2m with interval 1s in virtual machine server_16
[ 0%] Typing "server-login" with interval 30ms in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Password:" for 1m with interval 1s in virtual machine server_16
[ 0%] Typing "1111" with interval 30ms in virtual machine server_16
[ 0%] Pressing key ENTER in virtual machine server_16
[ 0%] Waiting "Welcome to Ubuntu" for 1m with interval 1s in virtual machine server_16
[ 0%] Taking snapshot server_16_install_ubuntu for virtual machine server_16
[ 5%] Test server_16_install_ubuntu PASSED in 0h:4m:22s
[ 5%] Preparing the environment for test server_16_install_guest_additions
[ 5%] Running test server_16_install_guest_additions
[ 5%] Calling macro install_guest_additions(hostname="server", login="server-login", password="1111") in virtual machine server_16
[ 5%] Plugging dvd /home/alex/work/iso/testo-guest-additions.iso into virtual machine server_16
[ 5%] Typing "sudo su" with interval 30ms in virtual machine server_16
[ 5%] Pressing key ENTER in virtual machine server_16
[ 5%] Waiting "password for server-login" for 1m with interval 1s in virtual machine server_16
[ 5%] Typing "1111" with interval 30ms in virtual machine server_16
[ 5%] Pressing key ENTER in virtual machine server_16
[ 5%] Waiting "root@server" for 1m with interval 1s in virtual machine server_16
[ 5%] Typing "mount /dev/cdrom /media" with interval 30ms in virtual machine server_16
[ 5%] Pressing key ENTER in virtual machine server_16
[ 5%] Waiting "read-only" for 1m with interval 1s in virtual machine server_16
[ 5%] Typing "dpkg -i /media/testo-guest-additions*" with interval 30ms in virtual machine server_16
[ 5%] Pressing key ENTER in virtual machine server_16
[ 5%] Waiting "Setting up testo-guest-additions" for 1m with interval 1s in virtual machine server_16
[ 5%] Typing "umount /media" with interval 30ms in virtual machine server_16
[ 5%] Pressing key ENTER in virtual machine server_16
[ 5%] Sleeping in virtual machine server_16 for 2s
[ 5%] Unplugging dvd from virtual machine server_16
[ 5%] Taking snapshot server_16_install_guest_additions for virtual machine server_16
[ 10%] Test server_16_install_guest_additions PASSED in 0h:0m:9s
[ 10%] Preparing the environment for test server_16_unplug_nat
[ 10%] Running test server_16_unplug_nat
[ 10%] Calling macro unplug_nic(hostname="server", login="server-login", nic_name="nat", password="1111") in virtual machine server_16
[ 10%] Shutting down virtual machine server_16 with timeout 1m
[ 10%] Unplugging nic nat from virtual machine server_16
[ 10%] Starting virtual machine server_16
[ 10%] Waiting "server login:" for 2m with interval 1s in virtual machine server_16
[ 10%] Typing "server-login" with interval 30ms in virtual machine server_16
[ 10%] Pressing key ENTER in virtual machine server_16
[ 10%] Waiting "Password:" for 1m with interval 1s in virtual machine server_16
[ 10%] Typing "1111" with interval 30ms in virtual machine server_16
[ 10%] Pressing key ENTER in virtual machine server_16
[ 10%] Waiting "Welcome to Ubuntu" for 1m with interval 1s in virtual machine server_16
[ 10%] Taking snapshot server_16_unplug_nat for virtual machine server_16
[ 15%] Test server_16_unplug_nat PASSED in 0h:0m:20s
[ 15%] Preparing the environment for test server_16_prepare
[ 15%] Running test server_16_prepare
[ 15%] Copying /home/alex/work/testo-related/testo-tutorials/16 - macros_with_declarations/./rename_net_16.sh to virtual machine server_16 to destination /opt/rename_net.sh with timeout 10m
[ 15%] Executing bash command in virtual machine server_16 with timeout 10m
+ chmod +x /opt/rename_net.sh
+ /opt/rename_net.sh 52:54:00:00:00:bb client_side
Renaming success
+ ip a a 192.168.1.1/24 dev client_side
+ ip l s client_side up
+ ip ad
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen
1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: client_side: <BROADCAST,MULTICAST
,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:00:00:bb brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 scope global client_side
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe00:bb/
64 scope link tentative
valid_lft forever preferred_lft forever
[ 15%] Taking snapshot server_16_prepare for virtual machine server_16
[ 20%] Test server_16_prepare PASSED in 0h:0m:1s
[ 20%] Preparing the environment for test client_16_install_ubuntu
[ 20%] Creating virtual machine client_16
[ 20%] Taking snapshot initial for virtual machine client_16
[ 20%] Running test client_16_install_ubuntu
[ 20%] Calling macro install_ubuntu_server(version="16", nat_interface="nat", hostname="client", login="client-login", password="1111") in virtual machine client_16
[ 20%] Calling macro install_ubuntu_server_16(hostname="client", login="client-login", password="1111") in virtual machine client_16
[ 20%] Starting virtual machine client_16
[ 20%] Waiting "English" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Install Ubuntu Server" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Choose the language" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Select your location" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Detect keyboard layout?" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Country of origin for the keyboard" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Keyboard layout" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Primary network interface" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Hostname:" for 5m with interval 1s in virtual machine client_16
[ 20%] Pressing key BACKSPACE 36 times in virtual machine client_16
[ 20%] Typing "client" with interval 30ms in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Full name for the new user" for 1m with interval 1s in virtual machine client_16
[ 20%] Typing "client-login" with interval 30ms in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Username for your account" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Choose a password for the new user" for 1m with interval 1s in virtual machine client_16
[ 20%] Typing "1111" with interval 30ms in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Re-enter password to verify" for 1m with interval 1s in virtual machine client_16
[ 20%] Typing "1111" with interval 30ms in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Use weak password?" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key LEFT in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Encrypt your home directory?" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Is this time zone correct?" for 2m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Partitioning method" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Select disk to partition" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Write the changes to disks and configure LVM?" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key LEFT in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Amount of volume group to use for guided partitioning" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Write the changes to disks?" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key LEFT in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "HTTP proxy information" for 3m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "How do you want to manage upgrades" for 6m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Choose software to install" for 1m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Install the GRUB boot loader to the master boot record?" for 10m with interval 1s in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Installation complete" for 1m with interval 1s in virtual machine client_16
[ 20%] Unplugging dvd from virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "client login:" for 2m with interval 1s in virtual machine client_16
[ 20%] Typing "client-login" with interval 30ms in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Password:" for 1m with interval 1s in virtual machine client_16
[ 20%] Typing "1111" with interval 30ms in virtual machine client_16
[ 20%] Pressing key ENTER in virtual machine client_16
[ 20%] Waiting "Welcome to Ubuntu" for 1m with interval 1s in virtual machine client_16
[ 20%] Taking snapshot client_16_install_ubuntu for virtual machine client_16
[ 25%] Test client_16_install_ubuntu PASSED in 0h:4m:24s
[ 25%] Preparing the environment for test client_16_install_guest_additions
[ 25%] Running test client_16_install_guest_additions
[ 25%] Calling macro install_guest_additions(hostname="client", login="client-login", password="1111") in virtual machine client_16
[ 25%] Plugging dvd /home/alex/work/iso/testo-guest-additions.iso into virtual machine client_16
[ 25%] Typing "sudo su" with interval 30ms in virtual machine client_16
[ 25%] Pressing key ENTER in virtual machine client_16
[ 25%] Waiting "password for client-login" for 1m with interval 1s in virtual machine client_16
[ 25%] Typing "1111" with interval 30ms in virtual machine client_16
[ 25%] Pressing key ENTER in virtual machine client_16
[ 25%] Waiting "root@client" for 1m with interval 1s in virtual machine client_16
[ 25%] Typing "mount /dev/cdrom /media" with interval 30ms in virtual machine client_16
[ 25%] Pressing key ENTER in virtual machine client_16
[ 25%] Waiting "read-only" for 1m with interval 1s in virtual machine client_16
[ 25%] Typing "dpkg -i /media/testo-guest-additions*" with interval 30ms in virtual machine client_16
[ 25%] Pressing key ENTER in virtual machine client_16
[ 25%] Waiting "Setting up testo-guest-additions" for 1m with interval 1s in virtual machine client_16
[ 25%] Typing "umount /media" with interval 30ms in virtual machine client_16
[ 25%] Pressing key ENTER in virtual machine client_16
[ 25%] Sleeping in virtual machine client_16 for 2s
[ 25%] Unplugging dvd from virtual machine client_16
[ 25%] Taking snapshot client_16_install_guest_additions for virtual machine client_16
[ 30%] Test client_16_install_guest_additions PASSED in 0h:0m:10s
[ 30%] Preparing the environment for test client_16_unplug_nat
[ 30%] Running test client_16_unplug_nat
[ 30%] Calling macro unplug_nic(hostname="client", login="client-login", nic_name="nat", password="1111") in virtual machine client_16
[ 30%] Shutting down virtual machine client_16 with timeout 1m
[ 30%] Unplugging nic nat from virtual machine client_16
[ 30%] Starting virtual machine client_16
[ 30%] Waiting "client login:" for 2m with interval 1s in virtual machine client_16
[ 30%] Typing "client-login" with interval 30ms in virtual machine client_16
[ 30%] Pressing key ENTER in virtual machine client_16
[ 30%] Waiting "Password:" for 1m with interval 1s in virtual machine client_16
[ 30%] Typing "1111" with interval 30ms in virtual machine client_16
[ 30%] Pressing key ENTER in virtual machine client_16
[ 30%] Waiting "Welcome to Ubuntu" for 1m with interval 1s in virtual machine client_16
[ 30%] Taking snapshot client_16_unplug_nat for virtual machine client_16
[ 35%] Test client_16_unplug_nat PASSED in 0h:0m:20s
[ 35%] Preparing the environment for test client_16_prepare
[ 35%] Creating flash drive exchange_flash_16
[ 35%] Taking snapshot initial for flash drive exchange_flash_16
[ 35%] Running test client_16_prepare
[ 35%] Calling macro process_flash(flash_name="exchange_flash_16", command="cp /media/rename_net_16.sh /opt/rename_net.sh") in virtual machine client_16
[ 35%] Plugging flash drive exchange_flash_16 into virtual machine client_16
[ 35%] Sleeping in virtual machine client_16 for 5s
[ 35%] Executing bash command in virtual machine client_16 with timeout 10m
+ mount /dev/sdb1 /media
[ 35%] Executing bash command in virtual machine client_16 with timeout 10m
+ cp /media/rename_net_16.sh /opt/rename_net.sh
[ 35%] Executing bash command in virtual machine client_16 with timeout 10m
+ umount /media
[ 35%] Unplugging flash drive exchange_flash_16 from virtual machine client_16
[ 35%] Executing bash command in virtual machine client_16 with timeout 10m
+ chmod +x /opt/rename_net.sh
+ /opt/rename_net.sh 52:54:00:00:00:aa server_side
Renaming success
+ ip a a 192.168.1.2/24 dev server_side
+ ip l s server_side up
+ ip ad
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen
1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: server_side: <BROADCAST,MULTICAST
,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:00:00:aa brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 scope global server_side
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe00:aa/
64 scope link tentative
valid_lft forever preferred_lft forever
[ 35%] Taking snapshot client_16_prepare for virtual machine client_16
[ 35%] Taking snapshot client_16_prepare for flash drive exchange_flash_16
[ 40%] Test client_16_prepare PASSED in 0h:0m:10s
[ 40%] Preparing the environment for test test_ping_16
[ 40%] Running test test_ping_16
[ 40%] Executing bash command in virtual machine client_16 with timeout 10m
+ ping 192.168.1.2 -c5
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.022 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=0.024 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=0.024 ms
64
bytes from 192.168.1.2: icmp_seq=4 ttl=64 time=0.028 ms
64 bytes from 192.168.1.2: icmp_seq=5 ttl=64 time=0.029 ms

--- 192.168.1.2 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3997ms
rtt min/avg/max/mdev = 0.022/0.025/0.029/
0.005 ms
[ 40%] Executing bash command in virtual machine server_16 with timeout 10m
+ ping 192.168.1.1 -c5
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.018 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.024 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.024 ms
64
bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.024 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=0.028 ms

--- 192.168.1.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3996ms
rtt min/avg/max/mdev = 0.018/0.023/0.028/
0.006 ms
[ 40%] Taking snapshot test_ping_16 for virtual machine client_16
[ 40%] Taking snapshot test_ping_16 for virtual machine server_16
[ 40%] Taking snapshot test_ping_16 for flash drive exchange_flash_16
[ 45%] Test test_ping_16 PASSED in 0h:0m:11s
[ 45%] Preparing the environment for test exchange_files_with_flash_16
[ 45%] Restoring snapshot server_16_prepare for virtual machine server_16
[ 45%] Restoring snapshot client_16_prepare for virtual machine client_16
[ 45%] Restoring snapshot client_16_prepare for flash drive exchange_flash_16
[ 45%] Running test exchange_files_with_flash_16
[ 45%] Executing bash command in virtual machine client_16 with timeout 10m
+ echo 'Hello from client!'
[ 45%] Calling command macro copy_file_with_flash(vm_from="client_16", vm_to="server_16", copy_flash="exchange_flash_16", file_from="/tmp/copy_me_to_server.txt", file_to="/tmp/copy_me_to_server.txt")
[ 45%] Calling macro process_flash(flash_name="exchange_flash_16", command="cp /tmp/copy_me_to_server.txt /media/$(basename /tmp/copy_me_to_server.txt)") in virtual machine client_16
[ 45%] Plugging flash drive exchange_flash_16 into virtual machine client_16
[ 45%] Sleeping in virtual machine client_16 for 5s
[ 45%] Executing bash command in virtual machine client_16 with timeout 10m
+ mount /dev/sdb1 /media
[ 45%] Executing bash command in virtual machine client_16 with timeout 10m
++ basename /tmp/copy_me_to_server.txt
+ cp /tmp/copy_me_to_server.txt /media/copy_me_to_server.txt
[ 45%] Executing bash command in virtual machine client_16 with timeout 10m
+ umount /media
[ 45%] Unplugging flash drive exchange_flash_16 from virtual machine client_16
[ 45%] Calling macro process_flash(flash_name="exchange_flash_16", command="cp /media/$(basename /tmp/copy_me_to_server.txt) /tmp/copy_me_to_server.txt") in virtual machine server_16
[ 45%] Plugging flash drive exchange_flash_16 into virtual machine server_16
[ 45%] Sleeping in virtual machine server_16 for 5s
[ 45%] Executing bash command in virtual machine server_16 with timeout 10m
+ mount /dev/sdb1 /media
[ 45%] Executing bash command in virtual machine server_16 with timeout 10m
++ basename /tmp/copy_me_to_server.txt
+ cp /media/copy_me_to_server.txt /tmp/copy_me_to_server.txt
[ 45%] Executing bash command in virtual machine server_16 with timeout 10m
+ umount /media
[ 45%] Unplugging flash drive exchange_flash_16 from virtual machine server_16
[ 45%] Executing bash command in virtual machine server_16 with timeout 10m
+ cat /tmp/copy_me_to_server.txt
Hello from client!
[ 45%] Taking snapshot exchange_files_with_flash_16 for virtual machine client_16
[ 45%] Taking snapshot exchange_files_with_flash_16 for virtual machine server_16
[ 45%] Taking snapshot exchange_files_with_flash_16 for flash drive exchange_flash_16
[ 50%] Test exchange_files_with_flash_16 PASSED in 0h:0m:19s
[ 50%] Preparing the environment for test server_20_install_ubuntu
[ 50%] Creating virtual machine server_20
[ 50%] Taking snapshot initial for virtual machine server_20
[ 50%] Running test server_20_install_ubuntu
[ 50%] Calling macro install_ubuntu_server(version="20", nat_interface="nat", hostname="server", login="server-login", password="1111") in virtual machine server_20
[ 50%] Calling macro install_ubuntu_server_20(nat_interface="nat", hostname="server", login="server-login", password="1111") in virtual machine server_20
[ 50%] Unplugging nic nat from virtual machine server_20
[ 50%] Starting virtual machine server_20
[ 50%] Checking "Language" for 5s in virtual machine server_20
[ 50%] Waiting "Welcome!" for 5m with interval 1s in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "Please select your keyboard layout" for 1m with interval 1s in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "Configure at least one interface" for 1m with interval 1s in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "Proxy address" for 1m with interval 1s in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "Mirror address" for 1m with interval 1s in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "Continue without updating" for 1m with interval 1s in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "Use an entire disk" for 1m with interval 1s in virtual machine server_20
[ 50%] Pressing key DOWN 5 times in virtual machine server_20
[ 50%] Waiting "find_text().match('Done').match_background('green').size() > 0" for 1m with interval 1s in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "FILE SYSTEM SUMMARY" for 1m with interval 1s in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "Confirm destructive action" for 1m with interval 1s in virtual machine server_20
[ 50%] Pressing key DOWN in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "Enter the username" for 1m with interval 1s in virtual machine server_20
[ 50%] Typing "server-login" with interval 30ms in virtual machine server_20
[ 50%] Pressing key TAB in virtual machine server_20
[ 50%] Typing "server" with interval 30ms in virtual machine server_20
[ 50%] Pressing key TAB in virtual machine server_20
[ 50%] Typing "server-login" with interval 30ms in virtual machine server_20
[ 50%] Pressing key TAB in virtual machine server_20
[ 50%] Typing "1111" with interval 30ms in virtual machine server_20
[ 50%] Pressing key TAB in virtual machine server_20
[ 50%] Typing "1111" with interval 30ms in virtual machine server_20
[ 50%] Pressing key ENTER 2 times in virtual machine server_20
[ 50%] Waiting "SSH Setup" for 1m with interval 1s in virtual machine server_20
[ 50%] Pressing key TAB in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "Installing system" for 1m with interval 1s in virtual machine server_20
[ 50%] Waiting "Installation complete!" for 15m with interval 1s in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "Please remove the installation medium" for 1m with interval 1s in virtual machine server_20
[ 50%] Unplugging dvd from virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "server login" for 3m with interval 1s in virtual machine server_20
[ 50%] Stopping virtual machine server_20
[ 50%] Plugging nic nat into virtual machine server_20
[ 50%] Starting virtual machine server_20
[ 50%] Waiting "GNU GRUB" for 1m with interval 1s in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "server login" for 3m with interval 1s in virtual machine server_20
[ 50%] Typing "server-login" with interval 30ms in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "Password" for 1m with interval 1s in virtual machine server_20
[ 50%] Typing "1111" with interval 30ms in virtual machine server_20
[ 50%] Pressing key ENTER in virtual machine server_20
[ 50%] Waiting "server-login@server" for 1m with interval 1s in virtual machine server_20
[ 50%] Taking snapshot server_20_install_ubuntu for virtual machine server_20
[ 55%] Test server_20_install_ubuntu PASSED in 0h:3m:50s
[ 55%] Preparing the environment for test server_20_install_guest_additions
[ 55%] Running test server_20_install_guest_additions
[ 55%] Calling macro install_guest_additions(hostname="server", login="server-login", password="1111") in virtual machine server_20
[ 55%] Plugging dvd /home/alex/work/iso/testo-guest-additions.iso into virtual machine server_20
[ 55%] Typing "sudo su" with interval 30ms in virtual machine server_20
[ 55%] Pressing key ENTER in virtual machine server_20
[ 55%] Waiting "password for server-login" for 1m with interval 1s in virtual machine server_20
[ 55%] Typing "1111" with interval 30ms in virtual machine server_20
[ 55%] Pressing key ENTER in virtual machine server_20
[ 55%] Waiting "root@server" for 1m with interval 1s in virtual machine server_20
[ 55%] Typing "mount /dev/cdrom /media" with interval 30ms in virtual machine server_20
[ 55%] Pressing key ENTER in virtual machine server_20
[ 55%] Waiting "read-only" for 1m with interval 1s in virtual machine server_20
[ 55%] Typing "dpkg -i /media/testo-guest-additions*" with interval 30ms in virtual machine server_20
[ 55%] Pressing key ENTER in virtual machine server_20
[ 55%] Waiting "Setting up testo-guest-additions" for 1m with interval 1s in virtual machine server_20
[ 55%] Typing "umount /media" with interval 30ms in virtual machine server_20
[ 55%] Pressing key ENTER in virtual machine server_20
[ 55%] Sleeping in virtual machine server_20 for 2s
[ 55%] Unplugging dvd from virtual machine server_20
[ 55%] Executing bash command in virtual machine server_20 with timeout 10m
+ ip l s ens7 up
+ dhclient ens7
cmp: EOF on /tmp/tmp.rwmiaB2Mhz which is empty
+ apt install -y net-tools

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state
information...
The following NEW packages will be installed:
net-tools
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 196 kB of archives.
After this operation, 864 kB of additional disk space will be used.
Get:1 http://archive
.ubuntu.com/ubuntu focal/main amd64 net-tools amd64 1.60+git20180626.aebd88e-1ubuntu1 [196 kB]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debc
onf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin:
Fetched 196 kB in 0s (552 kB/s)
Selecting previously unselected packa
ge net-tools.
(Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading da
tabase ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 67943 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20180626.aebd88e-1ubuntu1_amd64.deb ...
Unpacking net-tools (1.60+git20180626.aebd88e-1ubuntu1
) ...
Setting up net-tools (1.60+git20180626.aebd88e-1ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
[ 55%] Taking snapshot server_20_install_guest_additions for virtual machine server_20
[ 60%] Test server_20_install_guest_additions PASSED in 0h:0m:15s
[ 60%] Preparing the environment for test server_20_unplug_nat
[ 60%] Running test server_20_unplug_nat
[ 60%] Calling macro unplug_nic(hostname="server", login="server-login", nic_name="nat", password="1111") in virtual machine server_20
[ 60%] Shutting down virtual machine server_20 with timeout 1m
[ 60%] Unplugging nic nat from virtual machine server_20
[ 60%] Starting virtual machine server_20
[ 60%] Waiting "server login:" for 2m with interval 1s in virtual machine server_20
[ 60%] Typing "server-login" with interval 30ms in virtual machine server_20
[ 60%] Pressing key ENTER in virtual machine server_20
[ 60%] Waiting "Password:" for 1m with interval 1s in virtual machine server_20
[ 60%] Typing "1111" with interval 30ms in virtual machine server_20
[ 60%] Pressing key ENTER in virtual machine server_20
[ 60%] Waiting "Welcome to Ubuntu" for 1m with interval 1s in virtual machine server_20
[ 60%] Taking snapshot server_20_unplug_nat for virtual machine server_20
[ 65%] Test server_20_unplug_nat PASSED in 0h:0m:40s
[ 65%] Preparing the environment for test server_20_prepare
[ 65%] Running test server_20_prepare
[ 65%] Copying /home/alex/work/testo-related/testo-tutorials/16 - macros_with_declarations/./rename_net_20.sh to virtual machine server_20 to destination /opt/rename_net.sh with timeout 10m
[ 65%] Executing bash command in virtual machine server_20 with timeout 10m
+ chmod +x /opt/rename_net.sh
+ /opt/rename_net.sh 52:54:00:00:00:bb client_side
Renaming success
+ ip a a 192.168.1.1/24 dev client_side
+ ip l s client_side up
+ ip ad
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen
1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: client_side: <BROADCAST,MULTIC
AST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:00:00:bb brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 scope global client_side
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe00:bb
/64 scope link tentative
valid_lft forever preferred_lft forever
[ 65%] Taking snapshot server_20_prepare for virtual machine server_20
[ 70%] Test server_20_prepare PASSED in 0h:0m:3s
[ 70%] Preparing the environment for test client_20_install_ubuntu
[ 70%] Creating virtual machine client_20
[ 70%] Taking snapshot initial for virtual machine client_20
[ 70%] Running test client_20_install_ubuntu
[ 70%] Calling macro install_ubuntu_server(version="20", nat_interface="nat", hostname="client", login="client-login", password="1111") in virtual machine client_20
[ 70%] Calling macro install_ubuntu_server_20(nat_interface="nat", hostname="client", login="client-login", password="1111") in virtual machine client_20
[ 70%] Unplugging nic nat from virtual machine client_20
[ 70%] Starting virtual machine client_20
[ 70%] Checking "Language" for 5s in virtual machine client_20
[ 70%] Waiting "Welcome!" for 5m with interval 1s in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "Please select your keyboard layout" for 1m with interval 1s in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "Configure at least one interface" for 1m with interval 1s in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "Proxy address" for 1m with interval 1s in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "Mirror address" for 1m with interval 1s in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "Continue without updating" for 1m with interval 1s in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "Use an entire disk" for 1m with interval 1s in virtual machine client_20
[ 70%] Pressing key DOWN 5 times in virtual machine client_20
[ 70%] Waiting "find_text().match('Done').match_background('green').size() > 0" for 1m with interval 1s in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "FILE SYSTEM SUMMARY" for 1m with interval 1s in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "Confirm destructive action" for 1m with interval 1s in virtual machine client_20
[ 70%] Pressing key DOWN in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "Enter the username" for 1m with interval 1s in virtual machine client_20
[ 70%] Typing "client-login" with interval 30ms in virtual machine client_20
[ 70%] Pressing key TAB in virtual machine client_20
[ 70%] Typing "client" with interval 30ms in virtual machine client_20
[ 70%] Pressing key TAB in virtual machine client_20
[ 70%] Typing "client-login" with interval 30ms in virtual machine client_20
[ 70%] Pressing key TAB in virtual machine client_20
[ 70%] Typing "1111" with interval 30ms in virtual machine client_20
[ 70%] Pressing key TAB in virtual machine client_20
[ 70%] Typing "1111" with interval 30ms in virtual machine client_20
[ 70%] Pressing key ENTER 2 times in virtual machine client_20
[ 70%] Waiting "SSH Setup" for 1m with interval 1s in virtual machine client_20
[ 70%] Pressing key TAB in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "Installing system" for 1m with interval 1s in virtual machine client_20
[ 70%] Waiting "Installation complete!" for 15m with interval 1s in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "Please remove the installation medium" for 1m with interval 1s in virtual machine client_20
[ 70%] Unplugging dvd from virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "client login" for 3m with interval 1s in virtual machine client_20
[ 70%] Stopping virtual machine client_20
[ 70%] Plugging nic nat into virtual machine client_20
[ 70%] Starting virtual machine client_20
[ 70%] Waiting "GNU GRUB" for 1m with interval 1s in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "client login" for 3m with interval 1s in virtual machine client_20
[ 70%] Typing "client-login" with interval 30ms in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "Password" for 1m with interval 1s in virtual machine client_20
[ 70%] Typing "1111" with interval 30ms in virtual machine client_20
[ 70%] Pressing key ENTER in virtual machine client_20
[ 70%] Waiting "client-login@client" for 1m with interval 1s in virtual machine client_20
[ 70%] Taking snapshot client_20_install_ubuntu for virtual machine client_20
[ 75%] Test client_20_install_ubuntu PASSED in 0h:3m:54s
[ 75%] Preparing the environment for test client_20_install_guest_additions
[ 75%] Running test client_20_install_guest_additions
[ 75%] Calling macro install_guest_additions(hostname="client", login="client-login", password="1111") in virtual machine client_20
[ 75%] Plugging dvd /home/alex/work/iso/testo-guest-additions.iso into virtual machine client_20
[ 75%] Typing "sudo su" with interval 30ms in virtual machine client_20
[ 75%] Pressing key ENTER in virtual machine client_20
[ 75%] Waiting "password for client-login" for 1m with interval 1s in virtual machine client_20
[ 75%] Typing "1111" with interval 30ms in virtual machine client_20
[ 75%] Pressing key ENTER in virtual machine client_20
[ 75%] Waiting "root@client" for 1m with interval 1s in virtual machine client_20
[ 75%] Typing "mount /dev/cdrom /media" with interval 30ms in virtual machine client_20
[ 75%] Pressing key ENTER in virtual machine client_20
[ 75%] Waiting "read-only" for 1m with interval 1s in virtual machine client_20
[ 75%] Typing "dpkg -i /media/testo-guest-additions*" with interval 30ms in virtual machine client_20
[ 75%] Pressing key ENTER in virtual machine client_20
[ 75%] Waiting "Setting up testo-guest-additions" for 1m with interval 1s in virtual machine client_20
[ 75%] Typing "umount /media" with interval 30ms in virtual machine client_20
[ 75%] Pressing key ENTER in virtual machine client_20
[ 75%] Sleeping in virtual machine client_20 for 2s
[ 75%] Unplugging dvd from virtual machine client_20
[ 75%] Executing bash command in virtual machine client_20 with timeout 10m
+ ip l s ens7 up
+ dhclient ens7
cmp: EOF on /tmp/tmp.hQxtodoogv which is empty
+ apt install -y net-tools

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state
information...
The following NEW packages will be installed:
net-tools
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 196 kB of archives.
After this operation, 864 kB of additional disk space will be used.
Get:1 http://archive
.ubuntu.com/ubuntu focal/main amd64 net-tools amd64 1.60+git20180626.aebd88e-1ubuntu1 [196 kB]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debc
onf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin:
Fetched 196 kB in 0s (562 kB/s)
Selecting previously unselected packa
ge net-tools.
(Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading da
tabase ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 67943 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20180626.aebd88e-1ubuntu1_amd64.deb ...
Unpacking net-tools (1.60+git20180626.aebd88e-1ubuntu1
) ...
Setting up net-tools (1.60+git20180626.aebd88e-1ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
[ 75%] Taking snapshot client_20_install_guest_additions for virtual machine client_20
[ 80%] Test client_20_install_guest_additions PASSED in 0h:0m:15s
[ 80%] Preparing the environment for test client_20_unplug_nat
[ 80%] Running test client_20_unplug_nat
[ 80%] Calling macro unplug_nic(hostname="client", login="client-login", nic_name="nat", password="1111") in virtual machine client_20
[ 80%] Shutting down virtual machine client_20 with timeout 1m
[ 80%] Unplugging nic nat from virtual machine client_20
[ 80%] Starting virtual machine client_20
[ 80%] Waiting "client login:" for 2m with interval 1s in virtual machine client_20
[ 80%] Typing "client-login" with interval 30ms in virtual machine client_20
[ 80%] Pressing key ENTER in virtual machine client_20
[ 80%] Waiting "Password:" for 1m with interval 1s in virtual machine client_20
[ 80%] Typing "1111" with interval 30ms in virtual machine client_20
[ 80%] Pressing key ENTER in virtual machine client_20
[ 80%] Waiting "Welcome to Ubuntu" for 1m with interval 1s in virtual machine client_20
[ 80%] Taking snapshot client_20_unplug_nat for virtual machine client_20
[ 85%] Test client_20_unplug_nat PASSED in 0h:0m:38s
[ 85%] Preparing the environment for test client_20_prepare
[ 85%] Creating flash drive exchange_flash_20
[ 85%] Taking snapshot initial for flash drive exchange_flash_20
[ 85%] Running test client_20_prepare
[ 85%] Calling macro process_flash(flash_name="exchange_flash_20", command="cp /media/rename_net_20.sh /opt/rename_net.sh") in virtual machine client_20
[ 85%] Plugging flash drive exchange_flash_20 into virtual machine client_20
[ 85%] Sleeping in virtual machine client_20 for 5s
[ 85%] Executing bash command in virtual machine client_20 with timeout 10m
+ mount /dev/sdb1 /media
[ 85%] Executing bash command in virtual machine client_20 with timeout 10m
+ cp /media/rename_net_20.sh /opt/rename_net.sh
[ 85%] Executing bash command in virtual machine client_20 with timeout 10m
+ umount /media
[ 85%] Unplugging flash drive exchange_flash_20 from virtual machine client_20
[ 85%] Executing bash command in virtual machine client_20 with timeout 10m
+ chmod +x /opt/rename_net.sh
+ /opt/rename_net.sh 52:54:00:00:00:aa server_side
Renaming success
+ ip a a 192.168.1.2/24 dev server_side
+ ip l s server_side up
+ ip ad
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen
1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: server_side: <BROADCAST,MULTIC
AST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:00:00:aa brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 scope global server_side
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe00:aa
/64 scope link tentative
valid_lft forever preferred_lft forever
[ 85%] Taking snapshot client_20_prepare for virtual machine client_20
[ 85%] Taking snapshot client_20_prepare for flash drive exchange_flash_20
[ 90%] Test client_20_prepare PASSED in 0h:0m:12s
[ 90%] Preparing the environment for test test_ping_20
[ 90%] Running test test_ping_20
[ 90%] Executing bash command in virtual machine client_20 with timeout 10m
+ ping 192.168.1.2 -c5
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.019 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=0.028 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=0.030 ms
64
bytes from 192.168.1.2: icmp_seq=4 ttl=64 time=0.032 ms
64 bytes from 192.168.1.2: icmp_seq=5 ttl=64 time=0.032 ms

--- 192.168.1.2 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4084ms
rtt min/avg/max/mdev = 0.019/0.028/0.032/
0.004 ms
[ 90%] Executing bash command in virtual machine server_20 with timeout 10m
+ ping 192.168.1.1 -c5
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.020 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.036 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.031 ms
64
bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.030 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=0.031 ms

--- 192.168.1.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4086ms
rtt min/avg/max/mdev = 0.020/0.029/0.036/
0.005 ms
[ 90%] Taking snapshot test_ping_20 for virtual machine server_20
[ 90%] Taking snapshot test_ping_20 for virtual machine client_20
[ 90%] Taking snapshot test_ping_20 for flash drive exchange_flash_20
[ 95%] Test test_ping_20 PASSED in 0h:0m:14s
[ 95%] Preparing the environment for test exchange_files_with_flash_20
[ 95%] Restoring snapshot server_20_prepare for virtual machine server_20
[ 95%] Restoring snapshot client_20_prepare for flash drive exchange_flash_20
[ 95%] Restoring snapshot client_20_prepare for virtual machine client_20
[ 95%] Running test exchange_files_with_flash_20
[ 95%] Executing bash command in virtual machine client_20 with timeout 10m
+ echo 'Hello from client!'
[ 95%] Calling command macro copy_file_with_flash(vm_from="client_20", vm_to="server_20", copy_flash="exchange_flash_20", file_from="/tmp/copy_me_to_server.txt", file_to="/tmp/copy_me_to_server.txt")
[ 95%] Calling macro process_flash(flash_name="exchange_flash_20", command="cp /tmp/copy_me_to_server.txt /media/$(basename /tmp/copy_me_to_server.txt)") in virtual machine client_20
[ 95%] Plugging flash drive exchange_flash_20 into virtual machine client_20
[ 95%] Sleeping in virtual machine client_20 for 5s
[ 95%] Executing bash command in virtual machine client_20 with timeout 10m
+ mount /dev/sdb1 /media
[ 95%] Executing bash command in virtual machine client_20 with timeout 10m
++ basename /tmp/copy_me_to_server.txt
+ cp /tmp/copy_me_to_server.txt /media/copy_me_to_server.txt
[ 95%] Executing bash command in virtual machine client_20 with timeout 10m
+ umount /media
[ 95%] Unplugging flash drive exchange_flash_20 from virtual machine client_20
[ 95%] Calling macro process_flash(flash_name="exchange_flash_20", command="cp /media/$(basename /tmp/copy_me_to_server.txt) /tmp/copy_me_to_server.txt") in virtual machine server_20
[ 95%] Plugging flash drive exchange_flash_20 into virtual machine server_20
[ 95%] Sleeping in virtual machine server_20 for 5s
[ 95%] Executing bash command in virtual machine server_20 with timeout 10m
+ mount /dev/sdb1 /media
[ 95%] Executing bash command in virtual machine server_20 with timeout 10m
++ basename /tmp/copy_me_to_server.txt
+ cp /media/copy_me_to_server.txt /tmp/copy_me_to_server.txt
[ 95%] Executing bash command in virtual machine server_20 with timeout 10m
+ umount /media
[ 95%] Unplugging flash drive exchange_flash_20 from virtual machine server_20
[ 95%] Executing bash command in virtual machine server_20 with timeout 10m
+ cat /tmp/copy_me_to_server.txt
Hello from client!
[ 95%] Taking snapshot exchange_files_with_flash_20 for virtual machine server_20
[ 95%] Taking snapshot exchange_files_with_flash_20 for virtual machine client_20
[ 95%] Taking snapshot exchange_files_with_flash_20 for flash drive exchange_flash_20
[100%] Test exchange_files_with_flash_20 PASSED in 0h:0m:27s
PROCESSED TOTAL 20 TESTS IN 0h:21m:4s
UP-TO-DATE: 0
RUN SUCCESSFULLY: 20
FAILED: 0

Что ж, с задачей мы справились, но нам снова пришлось заняться копипастой: нам пришлось фактически скуопировать виртуальные машины, сети, флешки и сами тесты.

Но всё это можно исправить, если задействовать ещё один тип макросов, доступный в Testo: макросы с объявлениями.

Макрос с объявлениями стенда

Макросы с объявлениями позволяют объединять в блоки некоторые конструкции самого верхнего уровня в языке Testo-lang: объявления виртуальных сущностей (машин, флешек и сетей), а также тестов. Внутри макросов с объявлениями нельзя объявлять параметры, другие макроса и использовать директиву include. Зато можно вызывать другие макросы с объявлениями.

Начнём мы с того, что попробуем объединить объявление сетей, флешек и машин в макрос generate_bench:

macro generate_bench(version, ram_size, disk_size) {
    network "internet_${version}" {
        mode: "nat"
    }

    network "LAN_${version}" {
        mode: "internal"
    }

    machine "client_${version}" {
        cpus: 1
        ram: "${ram_size}"
        disk main: {
            size: "${disk_size}"
        }
        iso: "${ISO_DIR}/ubuntu_server_${version}.iso"

        nic nat: {
            attached_to: "internet_${version}"
        }

        nic server_side: {
            attached_to: "LAN_${version}"
            mac: "52:54:00:00:00:AA"
        }
    }

    machine "server_${version}" {
        cpus: 1
        ram: "${ram_size}"
        disk main: {
            size: "${disk_size}"
        }
        iso: "${ISO_DIR}/ubuntu_server_${version}.iso"

        nic nat: {
            attached_to: "internet_${version}"
        }

        nic client_side: {
            attached_to: "LAN_${version}"
            mac: "52:54:00:00:00:BB"
        }
    }

    flash "exchange_flash_${version}" {
        fs: "ntfs"
        size: 8Mb
        folder: "./folder_to_copy"
    }
}

generate_bench("16", "512Mb", "5Gb")
generate_bench("20", "1Gb", "8Gb")

Давайте рассмотрим познимательней, что здесь происходит.

Внутри макроса инкапсулировано объявление виртуального стенда: две виртуальные машины, две сети и одна флешка. Каждый вызов макроса будет генерировать целый стенд. Чтобы виртуальные сущности не "наслаивались" друг на друга при нескольких вызовах макроса, мы сделали имена всех сущностей параметризируемыми. Для этого мы воспользовались возможностью языка Testo-lang, которая позволяет задавать имена сущностей не только в виде идентификаторов (как мы всегда делали до этого), но и в виде строк. А внутри строк мы можем использовать обращение к аргументам макроса.

В итоге вызов макроса generate_bench с аргументом version = "16" (Ubuntu версии 16) сгенерирует сущности network internet_16, network LAN_16, machine client_16, machine server_16 и flash exchange_flash_16. Для того, чтобы сгенерировать сущности для Ubuntu 20 достаточно вызвать макрос generate_bench с аргументом version = 20. Это приведёт к тому, что виртуальные машины "подгрузят" ISO-образ ubuntu_server_20.iso (где должен находяиться установочный образ Ubuntu 20) вместо ubuntu_server_16.iso.

Следующий интересный момент - это изменяемое количество оперативной памяти (ram) и дискового пространства (size). Как уже упоминалось выше, Ubuntu Server 20 требует большего количества как оперативной, так и дисковой памяти. Поэтому при генерации стенда хотелось бы иметь возможность указывать количество памяти. Для этого существуют аргументы ram_size и disk_size.

После того, как эти аргументы попадают в макрос, к ним происходит обращение в атрибутах ram и size. Мы с вами привыкли указывать в этих атрибутах спецификаторы количества памяти (512Mb, 5Gb), но язык Testo-lang позволяет также задавать эти атрибуты с помощью строк ("512Mb", "5Gb"). Использование строк предполагает определенный бонус: внутри строк можно обращаться к аргументам макроса, чем мы и пользуемся.

При это значение аргументов ram_size и disk_size должно быть приводимым к спецификатору количества памяти. Если попытаться передать неправильное значение (например, "5"), то сгенерируется ошибка.

Итак, мы сделали макрос generate_bench, но объявление макроса не означает объявления виртуальных машин, флешек и сетей. Для того, чтобы сущности внутри макроса действительно сгенерировались, нужно этот макрос вызвать. Вызовы макроса происходят в конце файла declarations.testo и благодаря этим вызовам генерится два независимых набора виртуалок, сетей и флешек. Обратите внимание, что вызовы происходят на самом верхнем уровне - на том же уровне, где обычно определяются виртуальные сущности и тесты.

Макрос с объявлениями тестов

Теперь пора переходить к тестам. Объявления тестов, как и объявления машин, можно инкапсулировать в макросы (причем никто не запрещает в одном и том же макросе объявлять и тесты и виртальные сущности вперемешку). Давайте попробуем это сделать:

Файл tests.testo:

include "macros.testo"

macro generate_tests(version) {

    test "server_${version}_install_ubuntu" {
        "server_${version}" install_ubuntu_server("${version}", "nat", "${server_hostname}", "${server_login}")
    }

    test "server_${version}_install_guest_additions": "server_${version}_install_ubuntu" {
        "server_${version}" install_guest_additions("${server_hostname}", "${server_login}")
    }

    test "server_${version}_unplug_nat": "server_${version}_install_guest_additions" {
        "server_${version}" unplug_nic("${server_hostname}", "${server_login}", "nat")
    }

    test "server_${version}_prepare": "server_${version}_unplug_nat" {
        "server_${version}" {
            copyto "./rename_net_${version}.sh" "/opt/rename_net.sh"
            exec bash """
                chmod +x /opt/rename_net.sh
                /opt/rename_net.sh 52:54:00:00:00:bb client_side
                ip a a 192.168.1.1/24 dev client_side
                ip l s client_side up
                ip ad
            """
        }
    }

    test "client_${version}_install_ubuntu" {
        "client_${version}" install_ubuntu_server("${version}", "nat", "${client_hostname}", "${client_login}")
    }

    test "client_${version}_install_guest_additions": "client_${version}_install_ubuntu" {
        "client_${version}" install_guest_additions("${client_hostname}", "${client_login}")
    }

    test "client_${version}_unplug_nat": "client_${version}_install_guest_additions" {
        "client_${version}" unplug_nic("${client_hostname}", "${client_login}", "nat")
    }

    test "client_${version}_prepare": "client_${version}_unplug_nat" {
        "client_${version}" {
            process_flash("exchange_flash_${version}", "cp /media/rename_net_${version}.sh /opt/rename_net.sh")

            exec bash """
                chmod +x /opt/rename_net.sh
                /opt/rename_net.sh 52:54:00:00:00:aa server_side
                ip a a 192.168.1.2/24 dev server_side
                ip l s server_side up
                ip ad
            """
        }
    }

    test "test_ping_${version}": "client_${version}_prepare", "server_${version}_prepare" {
        "client_${version}" exec bash "ping 192.168.1.2 -c5"
        "server_${version}" exec bash "ping 192.168.1.1 -c5"
    }

    # Take a note, that the test is inherited not from
    # the test_ping, but from the client_prepare and
    # server_prepare tests.
    # Which means that test_ping and exchange_files_with_flash
    # both lay on the samy tests tree level
    test "exchange_files_with_flash_${version}": "client_${version}_prepare", "server_${version}_prepare" {
        #Create a file to be transferred
        "client_${version}" exec bash "echo \"Hello from client!\" > /tmp/copy_me_to_server.txt"
        copy_file_with_flash("client_${version}", "server_${version}", "exchange_flash_${version}", "/tmp/copy_me_to_server.txt", "/tmp/copy_me_to_server.txt")
        "server_${version}" exec bash "cat /tmp/copy_me_to_server.txt"
    }
}

generate_tests("16")
generate_tests("20")

Макрос generate_tests предназначен для генерации сразу целой серии тестов: от установки ОС до пинга и обмена файлами между двумя машинами. Благодаря этому макросу мы можем объединить код для тестов Ubuntu 16.04 и Ubuntu 20.04 - ведь сами тесты очень похожи. Давайте рассмотрим несколько интересных моментов получившегося макроса.

Во-первых, давайте посмотрим на названия тестов. Точно так же, как и для виртуальных сущностей, имена тестов тоже можно задавать с помощью строк (пользуясь при этом обращением к аргументам макросов). Причем для тестов и имена родителей тоже могут задаваться с помощью строк, чем мы и пользуемся в данном макросе.

Во-вторых, внутри макроса мы свободно используем вызов других видов макросов: макросов с действиями (например, install_ubuntu_server) и командами (copy_file_with_flash).

Заметьте, что для Ubuntu 16.04 и Ubuntu 20.04 процесс установки сильно отличается. Но за счет того, что мы объединили оба процесса установки в одном макросе install_ubuntu_server, мы можем не обращать на это внимания: для теста server_${version}_install_ubuntu все равно, как именно выполняется установка ОС - об этом позаботится макрос install_ubuntu_server.

Чтобы сгенерировать сами тесты, нужно вызывать макрос generate_tests. Мы его вызовем два раза: один раз для генерации коллекции тестов для Ubuntu Server 16.04 (generate_tests("16")) и ещё один раз для генерации тестов для Ubuntu Server 20.04 (generate_tests("20")).

После этого можно смело запускать тесты и проверять, что всё работает.

Выводы

С помощью макросов можно не только объединять в блоки действия и команды, но даже целые объявления - виртуальные стенды и тесты. Если Вам необходимо сгенерировать большое количество однотипных тестов (которые либо ничем не отличаются друг от друга, либо слабо отличаются), то макросы с объявлениями могут вам в этом сильно помочь.

Готовые скрипты можно найти здесь

Поздравляем! Вы изучили все основы языка Test-lang! Теперь Вы можете смело переходить к созданию своих собственных тестовых сценариев.