#1 Add CI tests using the standard test interface
Opened 5 years ago by sturivny. Modified 6 days ago
git://fedorapeople.org/~sturivny/glib-networking/ add_tests  into  rawhide

Add CI tests using the standard test interface
sturivny • 5 years ago  
tests/tests.yml
file added
+78
@@ -0,0 +1,78 @@

+ ---

+ # Tests for classic and container

+ - hosts: localhost

+   roles:

+   - role: standard-test-basic

+     tags:

+     - classic

+     - container

+     tests:

+     - glib-networking-certificate.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/certificate.test

+     - glib-networking-connection.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/connection.test

+     - glib-networking-file-database.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/file-database.test

+     - glib-networking-gnome.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/gnome.test

+     - glib-networking-libproxy.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/libproxy.test

+     - glib-networking-pkcs11-array.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/pkcs11-array.test

+     - glib-networking-pkcs11-pin.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/pkcs11-pin.test

+     - glib-networking-pkcs11-slot.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/pkcs11-slot.test

+     - glib-networking-pkcs11-util.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/pkcs11-util.test

+     required_packages:

+     - glib-networking-tests     # required by upstream-testset

+     - gnome-desktop-testing     # required by upstream-testset

+     - sudo                      # required by upstream-testset

+ 

+ # Tests for atomic

+ - hosts: localhost

+   roles:

+   - role: standard-test-basic

+     tags:

+     - atomic

+     tests:

+     - glib-networking-certificate.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/certificate.test

+     - glib-networking-connection.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/connection.test

+     - glib-networking-file-database.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/file-database.test

+     - glib-networking-gnome.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/gnome.test

+     - glib-networking-libproxy.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/libproxy.test

+     - glib-networking-pkcs11-array.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/pkcs11-array.test

+     - glib-networking-pkcs11-pin.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/pkcs11-pin.test

+     - glib-networking-pkcs11-slot.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/pkcs11-slot.test

+     - glib-networking-pkcs11-util.test:

+         dir: upstream-testset

+         run: ./runtest.sh glib-networking/pkcs11-util.test

+     required_packages:

+     - glib-networking-tests     # required by upstream-testset

+     - gnome-desktop-testing     # required by upstream-testset

tests/upstream-testset/runtest.sh
file added
+60
@@ -0,0 +1,60 @@

+ #!/bin/bash -x

+ 

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Description: upstream-testset

+ #   Author: Tomas Pelka <tpelka@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2006 Red Hat, Inc.

+ #

+ #   This program is free software: you can redistribute it and/or

+ #   modify it under the terms of the GNU General Public License as

+ #   published by the Free Software Foundation, either version 2 of

+ #   the License, or (at your option) any later version.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE.  See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public License

+ #   along with this program. If not, see http://www.gnu.org/licenses/.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ set -x

+ 

+ ARCH=$(uname -m)

+ LOG=/tmp/$TEST

+ T=$1

+ 

+ user=test

+ 

+ #Check if test user exists

+ grep -e "^$user:" /etc/passwd > /dev/null

+ if [ $? -ne 0 ]; then

+     adduser $user

+ fi

+ 

+ sudo -u $user ginsttest-runner $T 2>&1 >$LOG

+ rc=$?

+ RESULT=FAIL

+ if [ $rc -eq 0 ]; then

+   RESULT="PASS"

+ fi

+ 

+ #If test is not installed it won't run, but ginsttest-runner does not exit with error

+ grep "SUMMARY: total=0;" $LOG

+ if [ $? -eq 0 ]; then

+   RESULT="FAIL"

+   rc=1

+ fi

+ 

+ echo "Result is: $RESULT"

+ 

+ if which rhts-report-result &> /dev/null; then

+     rhts-report-result $TEST $RESULT $LOG

+ fi

+ 

+ exit $rc

no initial comment

Justification

Adds tests according to the CI wiki specifically the standard test interface in the spec.

The playbook includes Tier1 level test cases that have been tested in the following contexts and is passing reliably: Classic and Container. Test logs are stored in the artifacts directory.

The following steps are used to execute the tests using the standard test interface:


Test environment

Make sure you have installed packages from the spec

$ rpm -q ansible python2-dnf libselinux-python standard-test-roles
ansible-2.3.2.0-1.fc26.noarch
python2-dnf-2.6.3-11.fc26.noarch
libselinux-python-2.6-7.fc26.x86_64
standard-test-roles-2.4-1.fc26.noarch




Install all necessary packages from Standard_Test_Roles

$ sudo dnf install fedpkg libselinux-python standard-test-roles



Clone tests to your PC

$ git clone git://fedorapeople.org/~sturivny/glib-networking
$ cd glib-networking/



Run tests for Classic

All test should be run under the root

# tests/
# sudo ansible-playbook --tags=classic tests.yml

Snip of the example test run:

TASK [str-common-final : Pull out the logs from test environment to test runner] **************************************************************************************************************
ok: [localhost]

TASK [str-common-final : Report role result] **************************************************************************************************************************************************
ok: [localhost] => {
    "failed_when_result": false, 
    "msg": [
        "Tests failed: False", 
        "Tests msg: ", 
        ""
    ]
}

PLAY RECAP ************************************************************************************************************************************************************************************
localhost                  : ok=38   changed=12   unreachable=0    failed=0   



Run tests for Container

# export TEST_ARTIFACTS=/tmp/artifacts
# export ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)
# export TEST_SUBJECTS=docker:docker.io/library/fedora:27
# ansible-playbook --tags=container tests.yml

Snip of the example test run:

TASK [str-common-final : Pull out the logs from test environment to test runner] **************************************************************************************************************
ok: [localhost]

TASK [str-common-final : Report role result] **************************************************************************************************************************************************
ok: [localhost] => {
    "failed_when_result": false, 
    "msg": [
        "Tests failed: False", 
        "Tests msg: ", 
        ""
    ]
}

PLAY [localhost] ******************************************************************************************************************************************************************************

TASK [Gathering Facts] ************************************************************************************************************************************************************************
ok: [localhost]

PLAY RECAP ************************************************************************************************************************************************************************************
localhost                  : ok=20   changed=5    unreachable=0    failed=0



Run tests for Atomic

All test should be run under the root

# export ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)
# curl -Lo /tmp/atomic.qcow2 https://getfedora.org/atomic_qcow2_latest
# export TEST_SUBJECTS=/tmp/atomic.qcow2
# ansible-playbook --tags=atomic tests.yml

Snip of the example test run:

TASK [str-common-final : Pull out the logs from test environment to test runner] **************************************************************************************************************
changed: [/tmp/atomic.qcow2]

TASK [str-common-final : Report role result] **************************************************************************************************************************************************
ok: [/tmp/atomic.qcow2] => {
    "failed_when_result": false, 
    "msg": [
        "Tests failed: False", 
        "Tests msg: ", 
        ""
    ]
}

PLAY RECAP ************************************************************************************************************************************************************************************
/tmp/atomic.qcow2          : ok=20   changed=7    unreachable=0    failed=0   



Notes

Tests will be enabled in CI, yet gating is currently disabled, so nothing will change. Tests will run on each dist-git commit, they are not triggered by koji builds and if you are using FMN, it should notify you of failures normally.

The RH QE maintainer contact in case you have questions: Tomas Pelka tpelka@redhat.com
The idea is that these tests become yours just as you're maintaining the package, there will, of course, be people around if you have questions or troubles.

Hi @tpelka is this obsolete?

I'm thinking we probably only want upstream tests as part of Fedora package builds, right?

@catanzaro you mean remove them completely or have them disabled for RHEL case?

I suppose what I mean is: our other desktop packages do not contain downstream test configuration. Is it really still desired to add this? And if so, could you explain why?

I don't understand what this is tbh. :)