#1 Add CI tests using the standard test interface
Merged 2 years ago by walters. Opened 2 years ago by sturivny.
git://fedorapeople.org/~sturivny/dbus-glib add-tests  into  master

Add CI tests using the standard test interface
Sergey Turivniy • 2 years ago  
tests/README
file added
+1

@@ -0,0 +1,1 @@

+ Tests are passing and ready to be migrated to dist-git

tests/tests.yml
file added
+16

@@ -0,0 +1,16 @@

+ ---

+ # This first play always runs on the local staging system

+ - hosts: localhost

+   roles:

+   - role: standard-test-basic

+     tags:

+     - classic

+     tests:

+     - upstream-testset

+     required_packages:

+     - dbus-glib

+     - rpm-build    

+     - gcc 

+     - gcc-c++

+     - wget

+     - make

tests/upstream-testset/runtest.sh
file added
+58

@@ -0,0 +1,58 @@

+ #!/bin/bash -x

+ 

+ # Copyright (c) 2015 Red Hat, Inc. This copyrighted material

+ # is made available to anyone wishing to use, modify, copy, or

+ # redistribute it subject to the terms and conditions of the GNU General

+ # Public License v.2.

+ #

+ # 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, write to the Free Software

+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

+ #

+ # Author: Vladimir Benes <vbenes@redhat.com>

+ 

+ PKG=dbus-glib

+ PKG_DIR=$2

+ if [ -z "$PKG_DIR" ]; then

+   PKG_DIR=$1

+ fi

+ 

+ RPMBUILD=$(rpm --eval '%{_topdir}')

+ LOG="/tmp/$TEST.log"

+ PKG_SRPM=$(rpm -q --qf '%{SOURCERPM}\n' $PKG | head -n1)

+ PKG_PATH=$(rpm -q --qf '%{NAME}/%{VERSION}/%{RELEASE}\n' $PKG | head -n1)

+ PKG_BUILD_PATH=$(rpm -q --qf "$PKG_DIR-%{VERSION}\n" $PKG | head -n1)

+ 

+ echo "Downloading SRPM"

+ wget https://kojipkgs.fedoraproject.org/packages/$PKG_PATH/src/$PKG_SRPM

+ rm -rf $RPMBUILD

+ rpm -ivf $PKG_SRPM

+ echo "Building dependencies"

+ dnf builddep -y $PKG_SRPM

+ echo "Rebuilding the package"

+ rpmbuild -bc $RPMBUILD/SPECS/$PKG.spec

+ 

+ echo "Running make check"

+ #make check -C $RPMBUILD/BUILD/$PKG_BUILD_PATH/ &>$LOG

+ cd $RPMBUILD/BUILD/$PKG*

+ make check | tee -a $LOG

+ #make check -C $RPMBUILD/BUILD/$PKG_BUILD_PATH/ 

+ rc=$?

+ RESULT=FAIL

+ 

+ if [ $rc -eq 0 ]; then

+   RESULT="PASS"

+ fi

+ 

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

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

+ fi

+ 

+ exit $rc

+ echo "Result is: $RESULT"

+ rm $LOG

+ 

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



Clone tests to your PC

$ git clone git://fedorapeople.org/~sturivny/glib2
$ cd glib2/



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 [standard-test-basic : Copy tests to target] **************************************************************************************************
changed: [localhost]

TASK [standard-test-basic : Make artifacts directory] **********************************************************************************************
changed: [localhost]

TASK [standard-test-basic : Execute tests] *********************************************************************************************************
changed: [localhost] => (item=upstream-testset)

TASK [standard-test-basic : Pull out the logs] *****************************************************************************************************
changed: [localhost]

TASK [standard-test-basic : Check the results] *****************************************************************************************************
changed: [localhost]

PLAY RECAP *****************************************************************************************************************************************
localhost                  : ok=12   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: Vladimir Benes vbenes@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.

I'm confused about the point of this test; it's just rebuilding and rerunning the tests, but that's the same thing Koji is doing today, right? Now I would like to move the tests out of koji personally, but that gets into a bigger topic.

@walters well, it's still useful to have, I think, as it means we can run those tests in contexts other than "a build of this package". E.g. it's a step towards allowing us to do something like "check if this new systemd breaks dbus-glib", etc.

@walters The point of this tests is to have tests in each package that can be run in the same way. Easy to contribute, easy to run, easy to get test results.
https://fedoraproject.org/wiki/CI

Yes, I understand this. What I am saying in https://lists.fedoraproject.org/archives/list/ci@lists.fedoraproject.org/thread/OBH5HYIALLF6Q2UT2ADOYRFZFXNDXYBI/ is that the logical next step is to stop running %check in the spec files.

(But then of course you get into the problem that these tests are testing new binaries, not the binaries actually shipped from Koji, which then gets to https://wiki.gnome.org/Initiatives/GnomeGoals/InstalledTests )

Commit c5b29ad fixes this pull-request

Pull-Request has been merged by walters

2 years ago

Pull-Request has been merged by walters

2 years ago