Skip to content

Run OpenQA smoketest locally

Saray Cabrera Padrón edited this page Nov 30, 2020 · 11 revisions

Introduction

Here are described the steps to run the smoketest of the webui locally. These tests are used in the openQA Setup for OBS.

We will replicate the steps done by the following scripts:

Installation of virt-manager

We will use virt-manager to run the downloaded image. Make sure you have libvirt and virt-manager installed. Make sure the libvirtd.service is up und running. On a machine with openSUSE Tumbleweed you should:

  1. sudo zypper install libvirt virt-manager
  2. sudo systemctl enable libvirtd --now

Make sure your user is part of the libvirt group, otherwise virt-manager needs to be started with root rights, which is usually not a good idea. You can do the following to achieve this:

  1. Check for the existence of the libvirt group -> sudo getent group | grep libvirt
  2. Incase it does not exist -> sudo groupadd --system libvirt
  3. Now add your user to the group -> sudo usermod -a -G libvirt $(whoami)
  4. Restart the libvirtd.service -> sudo systemctl restart libvirtd.service

Download the image you want to test

  1. Navigate to the download subdirectory. It should be one of these:
  2. Download the .qcow2 image:
    • e.g.: curl -s http://download.opensuse.org/repositories/OBS:/Server:/2.10:/Staging/images/obs-server.x86_64-2.10.0-qcow2-Build1.17.qcow2

Import the image with virt-manager

  1. Open virt-manager in you console:
    • virt-manager
  2. Import the image:
    1. Click File | New Virtual Machine | Import existing disk image | Browse Local | Browse.
    2. Select the .qcow2 file you have downloaded.
    3. Choose the operating system: openSUSE Unknown, and click Forward.
    4. In "Memory and CPU settings" stay with the defaults and click Forward.
    5. Click Finish.

You should see a new window with a text console booting a system. It takes a while until you finally see the last output welcoming you to Open Build Services (OBS) Appliance.

Enabling ssh access

In order to make it easier to access the virtual machine, we will enable its ssh daemon.

  1. In the QEMU/KVM window of the virtual machine login as root with de default password provided in the appliances:
    • Login: root
    • Password: opensuse
  2. Enable the sshd service:
    • systemctl enable sshd --now
  3. Retrieve the ip of your virtual machine:
    • ip a | grep inet | grep eth0
  4. Try to enter the virtual machine from you local machine:
    • ssh root@IP_VIRTUAL_MACHINE

Prepare the enviroment to run the tests

Depending on the image you have downloaded, you will need do clone a different git branch:

  • For Unstable: export GIT_BRANCH=master
  • For 2.10: export GIT_BRANCH=2.10
  • For 2.9: export GIT_BRANCH=2.9

Then you can do the following steps:

git clone --single-branch --branch $GIT_BRANCH --depth 1 https://github.com/openSUSE/open-build-service.git /tmp/open-build-service
cd /tmp/open-build-service/dist/t/                                                                                                                    
zypper -vv -n --gpg-auto-import-keys install --force-resolution --no-recommends chromedriver xorg-x11-fonts libxml2-devel libxslt-devel ruby2.5-devel 
bundle.ruby2.5 install                                                                                                                                

Run the tests

cd /tmp/open-build-service/dist/t/
bundle.ruby2.5 exec rspec

Re-run the tests

In case you found an error running the tests, most probably you will need to restore the database to the initial setup:

cd /srv/www/obs/api/
rake db:drop db:create db:setup RAILS_ENV=production DISABLE_DATABASE_ENVIRONMENT_CHECK=1 SAFETY_ASSURED=1

Then you can run the tests again, as described in the previous section.

Capybara Screenshots

When a feature test fails, we generate a html and png file into the directory

/tmp/rspec_screens

To check these files, you can copy the file to your local machine with:

scp root@IP_VIRTUAL_MACHINE:/tmp/rspec_screens/screenshot-0040_package_spec.rb-24.png .
Clone this wiki locally