Guide 3. Internet access in virtual machines

What you're going to learn

In this guide you're going to learn:

  1. Test hierarchy basics.
  2. Learn about virtual networks and Network Interface Cards (NICs).
  3. Learn how to provide the Internet access to virtual machines inside your test scripts.

Preconditions

  1. Testo Framework is installed.
  2. Hyper-V is installed.
  3. Ubuntu server 16.04 image is downloaded and located here: C:\iso\ubuntu_server.iso. The location may be different, but in this case the test scripts have to be adjusted accordingly.
  4. The Host has the Internet access.
  5. (Recommended) Testo-lang syntax highlight for Sublime Text 3 is set up.
  6. (Recommended) Guide 2 is complete.

Introduction

Aside from virtual machines, there are two other virtual entities available in Testo-lang: virtual flash drives and virtual networks. Virtual flash drives are currently unavailable for Hyper-V, but virtual networks are OK to use, which we'll see in a moment.

Generally, virtual networks in Testo-lang could be used for 2 purposes: to link up virtual machines with each other and to provide the Internet access to a virtual machine. Linking up machines is explained in of of the next guides, so in this guide we're going to learn about the Internet access.

What to begin with?

Let's begin with renaming the test my_first_test into something more appropriate. For example, ubuntu_installation.

test ubuntu_installation {
    my_ubuntu {
        start
        wait "Install Ubuntu Server"
        ...
        wait "login:" timeout 2m; type "my-ubuntu-login"; press Enter
        wait "Password:"; type "1111"; press Enter
        wait "Welcome to Ubuntu"
    }
}

Don't run the new script just yet, we'll do that in a jiffy.

Right now the my_ubuntu machine doesn't have any NICs, so, obviously, it can't access the Internet. Let's create a test to check that it's true.

To do that first we need to learn what the tests hiearchy is. All the tests are organized in a tree based on the "testing from the simple to the complex" concept. Tests can have a "parent-children" connection, where the "simpler" test plays the role of the parent and the "more complex" test plays the role of the child. A test may have multiple parents and multiple children. A child is not going run until all his parents are completed successfully. The most simple tests that don't depend on anything (and have no parents) are called base tests, otherwise a test is called derived. In our guides the ubuntu_installation test is an example of a base test.

The "child-parent" connection is created like this:

test check_internet: ubuntu_installation {
    my_ubuntu {
        abort "stop here"
    }
}

Let's make sure that a child test really depends on the parent test.

To do that, let's run our script file, but this time we're going to use a new command-line argument --test_spec. This argument specifies the tests we want to run (instead of running all of the tests). After the run we'll see something like this:

C:\Users\Testo> sudo testo run nat.testo --stop_on_fail --test_spec check_internet
TESTS TO RUN:
ubuntu_installation
check_internet
[ 0%] Preparing the environment for test ubuntu_installation
[ 0%] Restoring snapshot initial for virtual machine my_ubuntu
[ 0%] Running test ubuntu_installation
[ 0%] Starting virtual machine my_ubuntu
[ 0%] Waiting "Install Ubuntu Server" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Choose the language" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Select your location" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Detect keyboard layout?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Country of origin for the keyboard" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Keyboard layout" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "No network interfaces detected" for 5m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Hostname:" for 30s with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key BACKSPACE 36 times in virtual machine my_ubuntu
[ 0%] Typing "my-ubuntu" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Full name for the new user" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Typing "my-ubuntu-login" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Username for your account" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Choose a password for the new user" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Typing "1111" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Re-enter password to verify" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Typing "1111" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Use weak password?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key LEFT in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Encrypt your home directory?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Select your timezone" for 2m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Partitioning method" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Select disk to partition" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Write the changes to disks and configure LVM?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key LEFT in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Amount of volume group to use for guided partitioning" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Force UEFI installation?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key LEFT in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Write the changes to disks?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key LEFT in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "HTTP proxy information" for 3m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "How do you want to manage upgrades" for 6m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Choose software to install" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Installation complete" for 30m with interval 1s in virtual machine my_ubuntu
[ 0%] Unplugging dvd from virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "login:" for 2m with interval 1s in virtual machine my_ubuntu
[ 0%] Typing "my-ubuntu-login" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Password:" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Typing "1111" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Welcome to Ubuntu" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Taking snapshot ubuntu_installation for virtual machine my_ubuntu
[ 50%] Test ubuntu_installation PASSED in 0h:6m:23s
[ 50%] Preparing the environment for test check_internet
[ 50%] Running test check_internet
C:/Users/Testo/testo/nat.testo:52:3: Caught abort action on virtual machine my_ubuntu with message: stop here

C:/Users/Testo/testo/nat.testo:2:1: note: the virtual machine my_ubuntu was declared here

[100%] Test check_internet FAILED in 0h:0m:0s
C:\Users\Testo>

At the begin of the output we can see, that the Testo Framework is shceduled the ubuntu_installation test to run, despite the fact that we only asked to run the check_internet test. It happened because we want to run a child test, but the parent test hasn't run successfully just yet. And therefore, Testo Framework automatically queues the parent test first, and only after that - the child test.

But haven't we already installed Ubuntu successfully? We ended the previous guide at the moment when the Ubuntu Server was installed, the test ended, and the virtual machine state must had been staged.

In fact, in the previous guide our test had the name my_first_test, and now, with the new name, Testo Framework sees it as a brand new test, which has never run before.

At the end of the output we can see, that the parent test has been run successfully, and Testo proceeded to the child test run, but it failed (because of the abort action).

If we run Testo one more time with the same arguments, we will see a new picture:

C:\Users\Testo> sudo testo run nat.testo --stop_on_fail --test_spec check_internet
UP-TO-DATE TESTS:
ubuntu_installation
TESTS TO RUN:
check_internet
[ 50%] Preparing the environment for test check_internet
[ 50%] Restoring snapshot ubuntu_installation for virtual machine my_ubuntu
[ 50%] Running test check_internet
C:/Users/Testo/testo/nat.testo:52:3: Caught abort action on virtual machine my_ubuntu with message: stop here

C:/Users/Testo/testo/nat.testo:2:1: note: the virtual machine my_ubuntu was declared here

[100%] Test check_internet FAILED in 0h:0m:2s
C:\Users\Testo>

This means that Testo Framework detected, that the ubuntu_installation test had already run successfully, and its virtual machine state had been staged. And so, instead of running the parent test again, Testo was able to just rollback the test bench into the state it was at the end of ubuntu_installation test.

Makeing sure that there is no Internet

As I've mentioned earlier, the my_ubuntu machine doens't have the Internet acces just yet. AHow how can we make sure of that? We could try the ping 8.8.8.8 -c5 bash command. But how can it be done? Well, we can do that just like any person would: type it on the keyboard:

test check_internet: ubuntu_installation {
    my_ubuntu {
        type "ping 8.8.8.8 -c5"; press Enter
        abort "stop here"
    }
}

Opening the machine in Hyper-V, we'll see the next result:

Network_unreachable

We, as humans, can clearly see there is no Internet. But what if we hadn't known that and we would've wanted to check that the was Internet access.

Of cource, the ping utility prints the information about the ICMP response packets (if there are any). We could've used the output itself, somewhat like this:

test check_internet: ubuntu_installation {
    my_ubuntu {
        type "ping 8.8.8.8 -c5"; press Enter
        wait "64 Bytes from 8.8.8.8"
        abort "stop here"
    }
}

But instead, I suggest more universal way to assert almost any command in Linux. It looks like this:

test check_internet: ubuntu_installation {
    my_ubuntu {
        type "ping 8.8.8.8 -c5 && echo Result is &?"; press Enter
        wait "Result is 0" timeout 10s
    }
}

What is going on here? We've exploited the Bash possibility to link up commands into a chain. In this particular case we're doing this "With the ping command returned successfully, pleasem execute also the echo Result is &?" command. Such an echo prints out the return code of the previously executed command (ping). If the ping was OK, then the Result if 0 text would appear on the screen. Otherwise nothing would show up, or a return code would be non-zero.

Let's thy this script out:

C:\Users\Testo> sudo testo run nat.testo --stop_on_fail --test_spec check_internet
UP-TO-DATE TESTS:
ubuntu_installation
TESTS TO RUN:
check_internet
[ 50%] Preparing the environment for test check_internet
[ 50%] Restoring snapshot ubuntu_installation for virtual machine my_ubuntu
[ 50%] Running test check_internet
[ 50%] Typing "ping 8.8.8.8 -c5 && echo Result is $?" with interval 30ms in virtual machine my_ubuntu
[ 50%] Pressing key ENTER in virtual machine my_ubuntu
[ 50%] Waiting "Result is 0" for 10s with interval 1s in virtual machine my_ubuntu
C:/Users/Testo/testo/nat.testo:53:3: Error while performing action wait "Result is 0" timeout 10s on virtual machine my_ubuntu
- Timeout

C:/Users/Testo/testo/nat.testo:2:1: note: the virtual machine my_ubuntu was declared here

[100%] Test check_internet FAILED in 0h:0m:14s
C:\Users\Testo>

And just to make sure that that the check would actually pass when the ping passed, let's change 8.8.8.8 for 127.0.0.1 (this ping should most definetely work fine):

test check_internet: ubuntu_installation {
    my_ubuntu {
        type "ping 127.0.0.1 -c5 && echo Result is &?"; press Enter
        wait "Result is 0" timeout 10s
    }
}
C:\Users\Testo> sudo testo run nat.testo --stop_on_fail --test_spec check_internet
UP-TO-DATE TESTS:
ubuntu_installation
TESTS TO RUN:
check_internet
[ 50%] Preparing the environment for test check_internet
[ 50%] Restoring snapshot ubuntu_installation for virtual machine my_ubuntu
[ 50%] Running test check_internet
[ 50%] Typing "ping 127.0.0.1 -c5 && echo Result is $?" with interval 30ms in virtual machine my_ubuntu
[ 50%] Pressing key ENTER in virtual machine my_ubuntu
[ 50%] Waiting "Result is 0" for 10s with interval 1s in virtual machine my_ubuntu
[ 50%] Taking snapshot check_internet for virtual machine my_ubuntu
[100%] Test check_internet PASSED in 0h:0m:12s
PROCESSED TOTAL 2 TESTS IN 0h:0m:12s
UP-TO-DATE: 1
RUN SUCCESSFULLY: 1
FAILED: 0
C:\Users\Testo>

So the check does work. And with this type of check you can assert almost any bash command there is. In one of the future guides we'll move this code into a macro to make it more user-friendly.

You can also execute commands inside an OS with the testo guest additions. We'll see how it's done in the next guide.

Gaining the Internet access.

To connect your virtual machine to the Internet, first you need to declare a virtual network which will serve for this purpose. To declare a virtual network, the network keyword is used:

network internet {
    mode: "nat"
}

Virtual network declaration is very similar to the virtual machine declarations: after the keyword network, a name for the network is followed (the name must be unique between all the virtual resources), followed by a set of attributes, from which only one is mandatory: mode. There are only two possible netowrk modes in Testo-lang at the moment: nat (the network is NATed to the default route of the Host, which usually means to the Internet) and internal (the network is isolated, this mode is used to link up virtual machines with each other).

After we've declared a network, it is time to link up our machine to this network. To do this, we need to add the nic attribute to my_ubuntu and attach this NIC to the internet network with the attache_to subattribute:

machine my_ubuntu {
    cpus: 1
    ram: 512Mb
    disk main: {
        size: 5Gb
    }
    iso: "C:\\iso\\ubuntu_server.iso"

    nic nat: {
        attached_to: "internet"
    }
}

The nic attribute must have a name (just like the disk attribute). The reason for that is that you can add several NICs to a virtual machine and unique names is the way to distinguish them (which will see in action in the next guide).

Aside from the name, you may to specify a bunch of subattributes, and only one of them is mandatory: attached_to, which specifies the virtual network name you want to attach the NIC to.

Keep in mind that the internet network must be declared before referencing it in the attached_to subattribute.

Adjusting the ubuntu_installation test

Let's run our test script:

C:\Users\Testo> sudo testo run nat.testo --stop_on_fail --test_spec check_internet
Because of the cache loss, Testo is scheduled to run the following tests:
- ubuntu_installation
- check_internet
Do you confirm running them? [y/N]: y
TESTS TO RUN:
ubuntu_installation
check_internet
[ 0%] Preparing the environment for test ubuntu_installation
[ 0%] Creating virtual machine my_ubuntu
[ 0%] Taking snapshot initial for virtual machine my_ubuntu
[ 0%] Running test ubuntu_installation
[ 0%] Starting virtual machine my_ubuntu
[ 0%] Waiting "Install Ubuntu Server" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Choose the language" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Select your location" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Detect keyboard layout?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Country of origin for the keyboard" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Keyboard layout" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "No network interfaces detected" for 5m with interval 1s in virtual machine my_ubuntu
C:/Users/Testo/testo/nat.testo:30:3: Error while performing action wait "No network interfaces detected" timeout 5m on virtual machine my_ubuntu
- Timeout

C:/Users/Testo/testo/nat.testo:6:1: note: the virtual machine my_ubuntu was declared here

[ 50%] Test ubuntu_installation FAILED in 0h:5m:11s
C:\Users\Testo>

If your tests are cached at the moment, you'll see that the ubuntu_installation test has lost its cache and needs to be re-run. It could seem strange, since we haven't modified the test itself, and its cache should've stayed intact. Hovewer, the cache validity depends on the involved virtual machines configurations integrity. Since we've changed the my_ubuntu configuration, all the tests referencing this virtual machine must be run again.

Caching technology is considered thoroughly in one of the future guides

In any case, after a few minutes you're going to find out that the ubuntu_installation test now fails. The output gives us a hint, that Testo couldn't detect the "No network interfaces detected" text in 5 minutes.

Indeed, if you open the Hyper-V manager and check out the virtual machine screen, you'll see this:

Hostname

The reason for this screen to appear is that we added the NIC to my_ubuntu, so now, naturally, the warning about not detecting any interfaces doesn't show up.

Let's comment up the line with waiting for this warning. But now 30 seconds may be not enough for the next text "Hostname" to appear, so let's enlarge this timeout to 5 minutes:

...
wait "Country of origin for the keyboard"; press Enter
wait "Keyboard layout"; press Enter
#wait "No network interfaces detected" timeout 5m; press Enter
wait "Hostname:" timeout 5m; press Backspace*36; type "my-ubuntu"; press Enter
wait "Full name for the new user"; type "my-ubuntu-login"; press Enter
wait "Username for your account"; press Enter
...

And run the script again.

If you don't have any issues with the proxy server (or if you don't use it at all), then the test script might fail one more time.

C:\Users\Testo> sudo testo run nat.testo --stop_on_fail --test_spec check_internet
TESTS TO RUN:
ubuntu_installation
check_internet
[ 0%] Preparing the environment for test ubuntu_installation
[ 0%] Restoring snapshot initial for virtual machine my_ubuntu
[ 0%] Running test ubuntu_installation
[ 0%] Starting virtual machine my_ubuntu
[ 0%] Waiting "Install Ubuntu Server" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Choose the language" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Select your location" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Detect keyboard layout?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Country of origin for the keyboard" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Keyboard layout" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Hostname:" for 5m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key BACKSPACE 36 times in virtual machine my_ubuntu
[ 0%] Typing "my-ubuntu" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Full name for the new user" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Typing "my-ubuntu-login" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Username for your account" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Choose a password for the new user" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Typing "1111" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Re-enter password to verify" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Typing "1111" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Use weak password?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key LEFT in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Encrypt your home directory?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Select your timezone" for 2m with interval 1s in virtual machine my_ubuntu
C:/Users/Testo/testo/nat.testo:39:3: Error while performing action wait "Select your timezone" timeout 2m on virtual machine my_ubuntu
- Timeout

C:/Users/Testo/testo/nat.testo:6:1: note: the virtual machine my_ubuntu was declared here

[ 50%] Test ubuntu_installation FAILED in 0h:2m:56s
C:\Users\Testo>

Instead of the screen with the time zone selection you'll see another screen:

Timezone

The reason is that, thanks to the Internet access, Ubunstu Server installator now can detect your current timezone automatically. So let's change our script a little bit more:

...
wait "Re-enter password to verify"; type "1111"; press Enter
wait "Use weak password?"; press Left, Enter
wait "Encrypt your home directory?"; press Enter

#wait "Select your timezone" timeout 2m; press Enter
wait "Is this time zone correct?" timeout 2m; press Enter
wait "Partitioning method"; press Enter
...

Now all the tests should pass successfully. And the check_internet test along with it:

C:\Users\Testo> sudo testo run nat.testo --stop_on_fail --test_spec check_internet
TESTS TO RUN:
ubuntu_installation
check_internet
[ 0%] Preparing the environment for test ubuntu_installation
[ 0%] Restoring snapshot initial for virtual machine my_ubuntu
[ 0%] Running test ubuntu_installation
[ 0%] Starting virtual machine my_ubuntu
[ 0%] Waiting "Install Ubuntu Server" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Choose the language" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Select your location" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Detect keyboard layout?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Country of origin for the keyboard" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Keyboard layout" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Hostname:" for 5m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key BACKSPACE 36 times in virtual machine my_ubuntu
[ 0%] Typing "my-ubuntu" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Full name for the new user" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Typing "my-ubuntu-login" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Username for your account" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Choose a password for the new user" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Typing "1111" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Re-enter password to verify" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Typing "1111" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Use weak password?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key LEFT in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Encrypt your home directory?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Is this time zone correct?" for 2m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Partitioning method" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Select disk to partition" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Write the changes to disks and configure LVM?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key LEFT in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Amount of volume group to use for guided partitioning" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Force UEFI installation?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key LEFT in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Write the changes to disks?" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key LEFT in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "HTTP proxy information" for 3m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "How do you want to manage upgrades" for 6m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Choose software to install" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Installation complete" for 30m with interval 1s in virtual machine my_ubuntu
[ 0%] Unplugging dvd from virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "login:" for 2m with interval 1s in virtual machine my_ubuntu
[ 0%] Typing "my-ubuntu-login" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Password:" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Typing "1111" with interval 30ms in virtual machine my_ubuntu
[ 0%] Pressing key ENTER in virtual machine my_ubuntu
[ 0%] Waiting "Welcome to Ubuntu" for 1m with interval 1s in virtual machine my_ubuntu
[ 0%] Taking snapshot ubuntu_installation for virtual machine my_ubuntu
[ 50%] Test ubuntu_installation PASSED in 0h:7m:5s
[ 50%] Preparing the environment for test check_internet
[ 50%] Running test check_internet
[ 50%] Typing "ping 8.8.8.8 -c5 && echo Result is $?" with interval 30ms in virtual machine my_ubuntu
[ 50%] Pressing key ENTER in virtual machine my_ubuntu
[ 50%] Waiting "Result is 0" for 10s with interval 1s in virtual machine my_ubuntu
[ 50%] Taking snapshot check_internet for virtual machine my_ubuntu
[100%] Test check_internet PASSED in 0h:0m:10s
PROCESSED TOTAL 2 TESTS IN 0h:7m:15s
UP-TO-DATE: 0
RUN SUCCESSFULLY: 2
FAILED: 0
C:\Users\Testo>

The ping 8.8.8.8 command run successfully, and it means that the virtual machine now has the Internet access!

Conclusion

Testo Framework allows you to connect your virtual machines to the Internet. This is done with the help of virtual networks, which could be also used to link up virtual machines with each other. Linking up machines with each other is the main highlight of one of the next guides.

You can find the complete test scripts for this guide here.