#1 Add CI tests using the standard test interface
Merged 6 years ago by kengert. Opened 6 years ago by bgoncalv.
rpms/ bgoncalv/ca-certificates ca-certificates-tests  into  master

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

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

+ #

+ #   Makefile of /CoreOS/ca-certificates/Sanity/smoke-test

+ #   Description: Check presence of Verisign root.

+ #   Author: Ondrej Moris <omoris@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2010 Red Hat, Inc. All rights reserved.

+ #

+ #   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 version 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.

+ #

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

+ 

+ export TEST=/CoreOS/ca-certificates/Sanity/smoke-test

+ export TESTVERSION=1.0

+ 

+ BUILT_FILES=

+ 

+ FILES=$(METADATA) runtest.sh Makefile PURPOSE

+ 

+ .PHONY: all install download clean

+ 

+ run: $(FILES) build

+ 	./runtest.sh

+ 

+ build: $(BUILT_FILES)

+ 	chmod a+x runtest.sh

+ 

+ clean:

+ 	rm -f *~ $(BUILT_FILES)

+ 

+ 

+ include /usr/share/rhts/lib/rhts-make.include

+ 

+ $(METADATA): Makefile

+ 	@echo "Owner:           Ondrej Moris <omoris@redhat.com>" > $(METADATA)

+ 	@echo "Name:            $(TEST)" >> $(METADATA)

+ 	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)

+ 	@echo "Path:            $(TEST_DIR)" >> $(METADATA)

+ 	@echo "Description:     Check presence of Verisign root." >> $(METADATA)

+ 	@echo "Type:            Sanity" >> $(METADATA)

+ 	@echo "TestTime:        5m" >> $(METADATA)

+ 	@echo "RunFor:          ca-certificates" >> $(METADATA)

+ 	@echo "Requires:        ca-certificates" >> $(METADATA)

+ 	@echo "Requires:        wget" >> $(METADATA)

+ 	@echo "Priority:        Normal" >> $(METADATA)

+ 	@echo "License:         GPLv2" >> $(METADATA)

+ 	@echo "Confidential:    no" >> $(METADATA)

+ 	@echo "Destructive:     no" >> $(METADATA)

+ 

+ 	rhts-lint $(METADATA)

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

+ PURPOSE of /CoreOS/ca-certificates/Sanity/smoke-test

+ Description: Check presence of Verisign root.

+ Author: Ondrej Moris <omoris@redhat.com>

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

+ #!/bin/bash

+ # vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

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

+ #

+ #   runtest.sh of /CoreOS/ca-certificates/Sanity/smoke-test

+ #   Description: Check presence of Verisign root.

+ #   Author: Ondrej Moris <omoris@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2010 Red Hat, Inc. All rights reserved.

+ #

+ #   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 version 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.

+ #

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

+ 

+ # Include rhts environment

+ . /usr/lib/beakerlib/beakerlib.sh

+ 

+ PACKAGE="ca-certificates"

+ 

+ rlJournalStart

+ 

+     rlPhaseStartTest

+ 

+     rlAssertRpm "$PACKAGE"

+ 	rlRun "curl -sS -o /dev/null https://www.verisign.com/" 0

+ 	rlRun "curl -sS -o /dev/null https://www.google.com/intl/en" 0

+ 

+     rlPhaseEnd

+ 

+ rlJournalPrintText

+ 

+ rlJournalEnd

file added
+13
@@ -0,0 +1,13 @@ 

+ ---

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

+ - hosts: localhost

+   roles:

+   - role: standard-test-beakerlib

+     tags:

+     - atomic

+     - classic

+     - container

+     tests:

+     - smoke-test

+     required_packages:

+     - findutils         # beakerlib needs find command

Adds tests according to the CI wiki [0] specifically the standard test interface in the spec [1].

The playbook includes Tier1 level test cases that have been tested in the following contexts and is passing reliably: Atomic Host, Docker, and Classic.
Test logs are stored in the Artifacts directory.

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

  • Atomic
    sudo ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) TEST_SUBJECTS=../atomic.qcow2 TEST_ARTIFACTS=$PWD/artifacts ansible-playbook --tags atomic tests.yml

  • Docker
    sudo ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) TEST_SUBJECTS=docker:docker.io/library/fedora:26 TEST_ARTIFACTS=$PWD/artifacts ansible-playbook --tags container tests.yml

  • Classic
    sudo ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) TEST_SUBJECTS="" TEST_ARTIFACTS=$PWD/artifacts ansible-playbook --tags classic tests.yml

[0] https://fedoraproject.org/wiki/CI
[1] https://fedoraproject.org/wiki/Changes/InvokingTests

Does this mean beaker is the standard for running CI tests in Fedora? (Beaker apparently isn't mentioned on the documents you're referring to.)

What triggers these tests to be executed automatically?

You are referring to a "standard test interface", where can I find the documentation that explains that for Fedora?

You mentioned commands (shown in red color), but who needs to know these commands? Are they standard commands already known in the "standard test interface", or must they get recorded somewhere?

I cannot review your script for correctness, is this something you expect me to do?

Does this mean beaker is the standard for running CI tests in Fedora? (Beaker apparently isn't mentioned on the documents you're referring to.)
No, the tests will not use beaker, but they might use beakerlib [1]

What triggers these tests to be executed automatically?
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 on koji builds and if you are using FMN, it should notify you of failures normally.

You are referring to a "standard test interface", where can I find the documentation that explains that for Fedora?
https://fedoraproject.org/wiki/CI
https://fedoraproject.org/wiki/Changes/InvokingTests

You mentioned commands (shown in red color), but who needs to know these commands? Are they standard commands already known in the "standard test interface", or must they get recorded somewhere?
The commands are used to invoke the tests and will be invoked by the CI system: https://fedoraproject.org/wiki/CI/Tests

I cannot review your script for correctness, is this something you expect me to do?
This is part of a Fedora effort of bringing downstream tests into Fedora, as open-source.

Test Logs: (If you you would like a pointer to the complete log, I can include that as well)

  • Atomic

    <snip>
    TASK [standard-test-beakerlib : Execute beakerlib tests] *****
    changed: [../atomic.qcow2] => (item=smoke-test)

    TASK [standard-test-beakerlib : Make the master test summary log artifact] *
    changed: [../atomic.qcow2] => (item=smoke-test)

    TASK [standard-test-beakerlib : Pull out the logs] *****
    changed: [../atomic.qcow2]

    TASK [standard-test-beakerlib : Check the results] *****
    changed: [../atomic.qcow2]

    PLAY RECAP ***********
    ../atomic.qcow2 : ok=13 changed=9 unreachable=0 failed=0

    Test results:

    PASS smoke-test

  • Docker

    <snip>
    TASK [standard-test-beakerlib : Execute beakerlib tests] *****
    changed: [fbf5a45ade937278f2d652bbec2c7236bf0eb59c6ef33f2e27708747f0f98232] => (item=smoke-test)

    TASK [standard-test-beakerlib : Make the master test summary log artifact] *
    changed: [fbf5a45ade937278f2d652bbec2c7236bf0eb59c6ef33f2e27708747f0f98232] => (item=smoke-test)

    TASK [standard-test-beakerlib : Pull out the logs] *****
    changed: [fbf5a45ade937278f2d652bbec2c7236bf0eb59c6ef33f2e27708747f0f98232]

    TASK [standard-test-beakerlib : Check the results] *****
    changed: [fbf5a45ade937278f2d652bbec2c7236bf0eb59c6ef33f2e27708747f0f98232]

    PLAY RECAP ***********
    fbf5a45ade937278f2d652bbec2c7236bf0eb59c6ef33f2e27708747f0f98232 : ok=15 changed=10 unreachable=0 failed=0

    Test results:

    PASS smoke-test

  • Classic

    <snip>
    ==> default: TASK [standard-test-beakerlib : Make artifacts directory] ***
    ==> default: changed: [localhost]
    ==> default:
    ==> default: TASK [standard-test-beakerlib : Execute beakerlib tests] ***
    ==> default: changed: [localhost] => (item=smoke-test)
    ==> default:
    ==> default: TASK [standard-test-beakerlib : Make the master test summary log artifact] *
    ==> default: changed: [localhost] => (item=smoke-test)
    ==> default:
    ==> default: TASK [standard-test-beakerlib : Pull out the logs]
    *****
    ==> default: changed: [localhost]
    ==> default:
    ==> default: TASK [standard-test-beakerlib : Check the results]
    *****
    ==> default: changed: [localhost]
    ==> default:
    ==> default: PLAY RECAP
    *********
    *
    ==> default: localhost : ok=15 changed=11 unreachable=0 failed=0
    ==> default: ++ '[' 0 -ne 0 ']'
    ==> default: ++ cat /root/ca-certificates/artifacts/test.log
    ==> default: PASS smoke-test

[1] https://pagure.io/standard-test-roles/blob/master/f/roles/standard-test-beakerlib

You should be able to run these tests locally on your machine, as well. Please take a look at https://fedoraproject.org/wiki/CI/Tests for examples of how to do so.

If these tests are a bit opaque, do you have any other tests that we could help you add here (to dist-git), and which you would eventually be willing to gate on?

The core idea (of CI) is to provide you with valuable testing feedback in order to aid you. You will know that anything being shipped in Fedora (at least Fedora Atomic Host for now) has passed these tests, without you having to run them manually.

Besides contacting us on irc (#fedora-ci), we have also set up a repo on Pagure where you can raise general issues: https://pagure.io/fedora-ci/AtomicCi/

Thanks for the explanations. I currently cannot play with this, but it sounds you have confirmed these changes work for you and the enhancements will be useful, so I'll merge them.

Pull-Request has been merged by kengert

6 years ago