Exploring openSUSE's automated testing tool for ISO images

Command and Control

Successfully booting a SUSE installation disk or ISO file requires input, even at the first screen (Figure 2). Luckily, KVM/Qemu starts a VNC server and allows users to send input remotely (via the VNC protocol) to the virtual machine. This API is called the Qemu/KVM Monitor. You can send mouse moves and events like clicks, any keyboard input, and more into the virtual machine [2]. On the other hand, it's also possible to grab screenshots and extract audio.

Figure 2: You can't tell it is openQA booting this SUSE image in a virtual machine.

The developers of openQA let their scripts take several screenshots per second. Videos like those provided on the website are simply series of those pictures rendered using standard tools such as Image Magick or Mplayer/Mencoder – tools that are probably already on your Linux box. The openQA developers are still working on sound/audio and general multimedia support.

Comparing Images

In the next step, openQA compares the screenshots acquired to screenshots prepared and taken from a working system. The openQA web interface shows the resulting errors or the success.

In a nutshell, just imagine the boot screen. If you hit the Down arrow, GRUB must select the next entry in the list. To test this action, a developer will have prepared an image with the second entry highlighted. openQA then compares this image to the screenshot just taken. If the images match, then openQA will send a Return key command to the virtual machine to proceed with the installation.

Needles, Pins and Tests

Some processes just don't matter – like when SUSE randomly tells the user about its newest features while the installation wizard is busily copying files. To make sure only areas of interest are compared and evaluated for possible errors, the openQA developers invented the concept of needles [3] (Figures 3 and 4, Listing 1).

Listing 1

A Thunderbird Needle

 

Figure 3: The SUSE developers have written tests for many tools, including the Thunderbird setup wizard.
Figure 4: Defining an area of interest in the needle editor at the openQA website.

A needle describes an area within a screenshot. The openQA website has an online editor that allows you to drag and drop the square you want to have inspected onto the picture. Or, you can go to the JSON files and edit the needle yourself. An openQA test can consist of countless needles. Additionally, hundreds of tests are already available, including specialized tests for KDE, Gnome, and other desktops.

You can test for network connectivity, check if an SSH server was successfully started, and much more – the web interface will report success and failure in long lists. If you want to extract the results and work with them, you can download them in a JSON file called results.json. Initial variables are stored in vars.json and might describe certain behaviors (Listings 2 and 3).

Listing 2

Excerpt from results.json

 

Listing 3

vars.json

 

The web interface lets you download these files and offers detailed insight into the tests (Figures 5 and 6). If you want to dive in deeper and start writing your own tests, see the HowTos available online [3] [4].

Figure 5: openQA takes screenshots every few seconds, comparing them to prefabricated images with the desired result.
Figure 6: Because openQA makes use of the built-in VNC server, even shell commands are tested via graphical analysis and image comparison.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News