#1 Add CI tests using the standard test interface
Opened 2 years ago by esakaiev. Modified 2 years ago
git://fedorapeople.org/~esakaiev/keyutils new-tests  into  master

Adding keyutils tests
esakaiev • 2 years ago  
tests/request-key-d-parsing/Makefile
file added
+63

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

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

+ #

+ #   Makefile of /CoreOS/keyutils/Regression/request-key-d-parsing

+ #   Description: Verifies whether request-key processes /etc/request-key.d

+ #   Author: Jiri Jaburek <jjaburek@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2012 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/keyutils/Regression/request-key-d-parsing

+ 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)

+ 	test -x runtest.sh || chmod a+x runtest.sh

+ 

+ clean:

+ 	rm -f *~ $(BUILT_FILES)

+ 

+ 

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

+ 

+ $(METADATA): Makefile

+ 	@echo "Owner:           Jiri Jaburek <jjaburek@redhat.com>" > $(METADATA)

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

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

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

+ 	@echo "Description:     Verifies whether request-key processes /etc/request-key.d correctly" >> $(METADATA)

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

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

+ 	@echo "RunFor:          keyutils" >> $(METADATA)

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

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

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

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

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

+ 

+ 	rhts-lint $(METADATA)

tests/request-key-d-parsing/PURPOSE
file added
+10

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

+ PURPOSE of /CoreOS/keyutils/Regression/request-key-d-parsing

+ Description: Verifies whether request-key processes /etc/request-key.d

+ Author: Jiri Jaburek <jjaburek@redhat.com>

+ 

+ Test:

+   - basic /etc/request-key.d functionality (using user.conf)

+   - /etc/request-key.d precedence over /etc/request-key.conf

+   - a file in /etc/request-key.d should override /etc/request-key.conf

+     even when empty

+   - only /etc/request-key.d/<type>.conf file should be processed for <type> type

tests/request-key-d-parsing/runtest.sh
file added
+65

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

+ #!/bin/bash

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

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

+ #

+ #   runtest.sh of /CoreOS/keyutils/Regression/request-key-d-parsing

+ #   Description: Verifies whether request-key processes /etc/request-key.d

+ #   Author: Jiri Jaburek <jjaburek@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2012 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 Beaker environment

+ [ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="keyutils"

+ 

+ USERDESC="UserDesc"

+ USERVALUE="UserValue"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+         # env checks in Test phase - they're part of the regression test

+         rlAssertExists "/etc/request-key.conf" || rlDie

+         rlAssertExists "/etc/request-key.d" || rlDie

+ 

+         rlFileBackup "/etc/request-key.conf"

+         rlFileBackup --clean "/etc/request-key.d"

+ 

+         # clean request-key.conf, entry in request-key.d/user.conf, should work

+         rlRun "echo -n > /etc/request-key.conf" 0

+         rlRun "echo 'create user $USERDESC * |/bin/cat' > /etc/request-key.d/user.conf" 0

+         rlRun "keyctl new_session" 0

+         rlRun "key=$(keyctl request2 user $USERDESC $USERVALUE @s)" 0

+         rlRun "value=$(keyctl print "$key")" 0

+         rlRun "[ \"$value\" = \"$USERVALUE\" ]" 0

+         rlRun "keyctl unlink "$key" @s"

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlFileRestore

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

tests/standard-inventory-qcow2
file added
+291

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

+ #!/usr/bin/env python

+ 

+ import argparse

+ import errno

+ import json

+ import os

+ import shutil

+ import shlex

+ import signal

+ import socket

+ import subprocess

+ import sys

+ import tempfile

+ import time

+ import distutils.util

+ 

+ IDENTITY = """

+ -----BEGIN RSA PRIVATE KEY-----

+ MIIEpQIBAAKCAQEA1DrTSXQRF8isQQfPfK3U+eFC4zBrjur+Iy15kbHUYUeSHf5S

+ jXPYbHYqD1lHj4GJajC9okle9rykKFYZMmJKXLI6987wZ8vfucXo9/kwS6BDAJto

+ ZpZSj5sWCQ1PI0Ce8CbkazlTp5NIkjRfhXGP8mkNKMEhdNjaYceO49ilnNCIxhpb

+ eH5dH5hybmQQNmnzf+CGCCLBFmc4g3sFbWhI1ldyJzES5ZX3ahjJZYRUfnndoUM/

+ TzdkHGqZhL1EeFAsv5iV65HuYbchch4vBAn8jDMmHh8G1ixUCL3uAlosfarZLLyo

+ 3HrZ8U/llq7rXa93PXHyI/3NL/2YP3OMxE8baQIDAQABAoIBAQCxuOUwkKqzsQ9W

+ kdTWArfj3RhnKigYEX9qM+2m7TT9lbKtvUiiPc2R3k4QdmIvsXlCXLigyzJkCsqp

+ IJiPEbJV98bbuAan1Rlv92TFK36fBgC15G5D4kQXD/ce828/BSFT2C3WALamEPdn

+ v8Xx+Ixjokcrxrdeoy4VTcjB0q21J4C2wKP1wEPeMJnuTcySiWQBdAECCbeZ4Vsj

+ cmRdcvL6z8fedRPtDW7oec+IPkYoyXPktVt8WsQPYkwEVN4hZVBneJPCcuhikYkp

+ T3WGmPV0MxhUvCZ6hSG8D2mscZXRq3itXVlKJsUWfIHaAIgGomWrPuqC23rOYCdT

+ 5oSZmTvFAoGBAPs1FbbxDDd1fx1hisfXHFasV/sycT6ggP/eUXpBYCqVdxPQvqcA

+ ktplm5j04dnaQJdHZ8TPlwtL+xlWhmhFhlCFPtVpU1HzIBkp6DkSmmu0gvA/i07Z

+ pzo5Z+HRZFzruTQx6NjDtvWwiXVLwmZn2oiLeM9xSqPu55OpITifEWNjAoGBANhH

+ XwV6IvnbUWojs7uiSGsXuJOdB1YCJ+UF6xu8CqdbimaVakemVO02+cgbE6jzpUpo

+ krbDKOle4fIbUYHPeyB0NMidpDxTAPCGmiJz7BCS1fCxkzRgC+TICjmk5zpaD2md

+ HCrtzIeHNVpTE26BAjOIbo4QqOHBXk/WPen1iC3DAoGBALsD3DSj46puCMJA2ebI

+ 2EoWaDGUbgZny2GxiwrvHL7XIx1XbHg7zxhUSLBorrNW7nsxJ6m3ugUo/bjxV4LN

+ L59Gc27ByMvbqmvRbRcAKIJCkrB1Pirnkr2f+xx8nLEotGqNNYIawlzKnqr6SbGf

+ Y2wAGWKmPyEoPLMLWLYkhfdtAoGANsFa/Tf+wuMTqZuAVXCwhOxsfnKy+MNy9jiZ

+ XVwuFlDGqVIKpjkmJyhT9KVmRM/qePwgqMSgBvVOnszrxcGRmpXRBzlh6yPYiQyK

+ 2U4f5dJG97j9W7U1TaaXcCCfqdZDMKnmB7hMn8NLbqK5uLBQrltMIgt1tjIOfofv

+ BNx0raECgYEApAvjwDJ75otKz/mvL3rUf/SNpieODBOLHFQqJmF+4hrSOniHC5jf

+ f5GS5IuYtBQ1gudBYlSs9fX6T39d2avPsZjfvvSbULXi3OlzWD8sbTtvQPuCaZGI

+ Df9PUWMYZ3HRwwdsYovSOkT53fG6guy+vElUEDkrpZYczROZ6GUcx70=

+ -----END RSA PRIVATE KEY-----

+ """

+ 

+ USER_DATA = """#cloud-config

+ users:

+   - default

+   - name: root

+     groups: sudo

+     shell: /bin/bash

+     ssh_authorized_keys:

+       - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUOtNJdBEXyKxBB898rdT54ULjMGuO6v4jLXmRsdRhR5Id/lKNc9hsdioPWUePgYlqML2iSV72vKQoVhkyYkpcsjr3zvBny9+5xej3+TBLoEMAm2hmllKPmxYJDU8jQJ7wJuRrOVOnk0iSNF+FcY/yaQ0owSF02Nphx47j2KWc0IjGGlt4fl0fmHJuZBA2afN/4IYIIsEWZziDewVtaEjWV3InMRLllfdqGMllhFR+ed2hQz9PN2QcapmEvUR4UCy/mJXrke5htyFyHi8ECfyMMyYeHwbWLFQIve4CWix9qtksvKjcetnxT+WWrutdr3c9cfIj/c0v/Zg/c4zETxtp standard-test-qcow2

+ ssh_pwauth: True

+ chpasswd:

+   list: |

+     root:foobar

+   expire: False

+ runcmd:

+   - mkfs.ext4 /dev/sdb

+   - mount /dev/sdb /usr/local 

+   - sudo mount -o remount,rw /usr

+   - mkdir /expected /output

+ """

+ 

+ def main(argv):

+     parser = argparse.ArgumentParser(description="Inventory for a QCow2 test image")

+     parser.add_argument("--list", action="store_true", help="Verbose output")

+     parser.add_argument('--host', help="Get host variables")

+     parser.add_argument("subjects", nargs="*", default=shlex.split(os.environ.get("TEST_SUBJECTS", "")))

+     opts = parser.parse_args()

+ 

+     try:

+         if opts.host:

+             data = host(opts.host)

+         else:

+             data = list(opts.subjects)

+         sys.stdout.write(json.dumps(data, indent=4, separators=(',', ': ')))

+     except RuntimeError as ex:

+         sys.stderr.write("{0}: {1}\n".format(os.path.basename(sys.argv[0]), str(ex)))

+         return 1

+ 

+     return 0

+ 

+ 

+ def list(subjects):

+     hosts = []

+     variables = {}

+     for subject in subjects:

+         if subject.endswith((".qcow2", ".qcow2c")):

+             vars = host(subject)

+             if vars:

+                 hosts.append(subject)

+                 variables[subject] = vars

+     return {"localhost": {"hosts": hosts, "vars": {}}, "subjects": {"hosts": hosts, "vars": {}},

+             "_meta": {"hostvars": variables}}

+ 

+ 

+ def start_qemu(image, cloudinit, log, disk_directory=None, disk_size=None, portrange=(2222, 5555)):

+     for port in xrange(*portrange):

+         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

+         sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

+         try:

+             sock.bind(("127.0.0.3", port))

+ 

+             if disk_size:

+                 return subprocess.Popen(["/usr/bin/qemu-system-x86_64", "-m", "1024", image,

+                                          "-enable-kvm", "-snapshot", "-cdrom", cloudinit,

+                                          "-hdb", disk_directory,

+                                          "-net", "nic,model=virtio", "-net",

+                                          "user,hostfwd=tcp:127.0.0.3:{0}-:22".format(port),

+                                          "-device", "isa-serial,chardev=pts2", "-chardev", "file,id=pts2,path=" + log,

+                                          "-display", "none"], stdout=open(os.devnull, 'w')), port

+             else:

+                 return subprocess.Popen(["/usr/bin/qemu-system-x86_64", "-m", "1024", image,

+                                          "-enable-kvm", "-snapshot", "-cdrom", cloudinit,

+                                          "-net", "nic,model=virtio", "-net",

+                                          "user,hostfwd=tcp:127.0.0.3:{0}-:22".format(port),

+                                          "-device", "isa-serial,chardev=pts2", "-chardev", "file,id=pts2,path=" + log,

+                                          "-display", "none"], stdout=open(os.devnull, 'w')), port

+         except IOError:

+             pass

+         finally:

+             sock.close()

+     else:

+         raise RuntimeError("unable to find free local port to map SSH to")

+ 

+ 

+ def host(image):

+     null = open(os.devnull, 'w')

+ 

+     try:

+         tty = os.open("/dev/tty", os.O_WRONLY)

+         os.dup2(tty, 2)

+     except OSError:

+         tty = None

+         pass

+ 

+     # A directory for temporary stuff

+     directory = tempfile.mkdtemp(prefix="inventory-cloud")

+     identity = os.path.join(directory, "identity")

+     with open(identity, 'w') as f:

+         f.write(IDENTITY)

+     os.chmod(identity, 0o600)

+     metadata = os.path.join(directory, "meta-data")

+     with open(metadata, 'w') as f:

+         f.write("")

+     userdata = os.path.join(directory, "user-data")

+     with open(userdata, 'w') as f:

+         f.write(USER_DATA)

+ 

+     # Create additional disk

+     disk_size = None

+     disk_directory = None

+     try:

+         disk_size = os.environ.get("EXTEND_DISK_SIZE")

+         if disk_size:

+             sys.stderr.write("\nCreate additional cloud init disk DISK SIZE {}\n".format(disk_size))

+ 

+             disk_directory = "{}/atomic-host-disk2-{}".format(directory, disk_size)

+             subprocess.check_call(["qemu-img", "create", "-f", "qcow2", disk_directory, disk_size], stdout=null)

+ 

+     except KeyError:

+         sys.stderr.write("\nCouldn't create additional cloud init disk DISK SIZE\n")

+     pass

+ 

+     # Create our cloud init so we can log in

+     cloudinit = os.path.join(directory, "cloud-init.iso")

+     subprocess.check_call(["/usr/bin/genisoimage", "-input-charset", "utf-8",

+                            "-volid", "cidata", "-joliet", "-rock", "-quiet",

+                            "-output", cloudinit, userdata, metadata], stdout=null)

+ 

+     # Determine if virtual machine should be kept available for diagnosis after completion

+     try:

+         diagnose = distutils.util.strtobool(os.getenv("TEST_DEBUG", "0"))

+     except ValueError:

+         diagnose = 0

+ 

+     sys.stderr.write("Launching virtual machine for {0}\n".format(image))

+ 

+     # And launch the actual VM

+     artifacts = os.environ.get("TEST_ARTIFACTS", os.path.join(os.getcwd(), "artifacts"))

+     try:

+         os.makedirs(artifacts)

+     except OSError as exc:

+         if exc.errno != errno.EEXIST or not os.path.isdir(artifacts):

+             raise

+     log = os.path.join(artifacts, "{0}.log".format(os.path.basename(image)))

+ 

+     proc = None  # for failure detection

+     cpe = None  # for exception scoping

+     for tries in xrange(0, 5):

+         try:

+             proc, port = start_qemu(image, cloudinit, log, disk_directory=disk_directory, disk_size=disk_size)

+             break

+         except subprocess.CalledProcessError as cpe:

+             time.sleep(1)

+             continue

+     if proc is None:

+         raise RuntimeError("Could not launch VM for qcow2 image"

+                            " '{0}':{1}".format(image, cpe.output))

+ 

+     # The variables

+     variables = {"ansible_ssh_port": "{0}".format(port),

+                  "ansible_ssh_host": "127.0.0.3",

+                  "ansible_ssh_user": "root",

+                  "ansible_ssh_pass": "foobar",

+                  "ansible_ssh_private_key_file": identity,

+                  "ansible_ssh_common_args": "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"}

+ 

+     # Write out a handy inventory file, for our use and for debugging

+     args = " ".join(["{0}='{1}'".format(*item) for item in variables.items()])

+     inventory = os.path.join(directory, "inventory")

+     with open(inventory, "w") as f:

+         f.write("[subjects]\nlocalhost {1}\n".format(image, args))

+ 

+     # Wait for ssh to come up

+     ping = ["/usr/bin/ansible", "--inventory", inventory, "localhost", "--module-name", "raw", "--args", "/bin/true"]

+ 

+     for tries in xrange(0, 30):

+         try:

+             (pid, ret) = os.waitpid(proc.pid, os.WNOHANG)

+             if pid != 0:

+                 raise RuntimeError("qemu failed to launch qcow2 image: {0}".format(image))

+             subprocess.check_call(ping, stdout=null, stderr=null)

+             break

+         except subprocess.CalledProcessError:

+             time.sleep(3)

+     else:

+         # Kill the qemu process

+         try:

+             os.kill(proc.pid, signal.SIGTERM)

+         except OSError:

+             pass

+         raise RuntimeError("could not access launched qcow2 image: {0}".format(image))

+ 

+     # Process of our parent

+     ppid = os.getppid()

+ 

+     child = os.fork()

+     if child:

+         return variables

+ 

+     # Daemonize and watch the processes

+     os.chdir("/")

+     os.setsid()

+     os.umask(0)

+ 

+     if tty is None:

+         tty = null.fileno()

+ 

+     # Duplicate standard input to standard output and standard error.

+     os.dup2(null.fileno(), 0)

+     os.dup2(tty, 1)

+     os.dup2(tty, 2)

+ 

+     # Now wait for the parent process to go away, then kill the VM

+     while True:

+         time.sleep(3)

+         try:

+             os.kill(ppid, 0)

+             os.kill(proc.pid, 0)

+         except OSError:

+             break  # Either of the processes no longer exist

+ 

+     if diagnose:

+         sys.stderr.write("\n")

+         sys.stderr.write("DIAGNOSE: ssh -p {0} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "

+                          "root@{1} # password: {2}\n".format(port, "127.0.0.3", "foobar"))

+         sys.stderr.write("DIAGNOSE: export ANSIBLE_INVENTORY={0}\n".format(inventory))

+         sys.stderr.write("DIAGNOSE: kill {0} # when finished\n".format(os.getpid()))

+ 

+         def _signal_handler(*args):

+             sys.stderr.write("\nDIAGNOSE ending...\n")

+ 

+         signal.signal(signal.SIGTERM, _signal_handler)

+         signal.pause()

+ 

+     # Kill the qemu process

+     try:

+         os.kill(proc.pid, signal.SIGTERM)

+     except OSError:

+         pass

+ 

+     shutil.rmtree(directory)

+     sys.exit(0)

+ 

+ 

+ if __name__ == '__main__':

+     sys.exit(main(sys.argv))

tests/tests.yml
file added
+31

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

+ ---

+ # Tests that run in classic context

+ - hosts: localhost

+   roles:

+   #use rhts role as upstream test uses OUTPFILE and it conflicts how beakerlib

+   #role uses it to execute the test.

+   #https://upstreamfirst.fedorainfracloud.org/keyutils/issue/1

+   - role: standard-test-rhts

+     tags:

+     - classic

+     tests:

+     - request-key-d-parsing

+     - upstream

+     required_packages:

+     - keyutils

+     - gcc               # upstream needs this package

+     - kernel-headers    # upstream needs this package

+     - redhat-lsb-core   # upstream needs this package

+     - rpm-build         # upstream needs this package

+     - wget              # rlFetchSrcForInstalled needs this package

+ 

+ # Tests that run in atomic context

+ - hosts: localhost

+   roles:

+   - role: standard-test-beakerlib

+     tags:

+     - atomic

+     tests:

+     - request-key-d-parsing

+     required_packages:

+     - keyutils

tests/upstream/Makefile
file added
+63

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

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

+ #

+ #   Makefile of /CoreOS/keyutils/Sanity/run-upstream-testsuite

+ #   Description: runs test suite from the srpm package

+ #   Author: Karel Srot <ksrot@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2017 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 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/keyutils/Sanity/run-upstream-testsuite

+ 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)

+ 	test -x runtest.sh || chmod a+x runtest.sh

+ 

+ clean:

+ 	rm -f *~ $(BUILT_FILES)

+ 

+ 

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

+ 

+ $(METADATA): Makefile

+ 	@echo "Owner:           Karel Srot <ksrot@redhat.com>" > $(METADATA)

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

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

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

+ 	@echo "Description:     runs test suite from the srpm package" >> $(METADATA)

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

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

+ 	@echo "RunFor:          keyutils" >> $(METADATA)

+ 	@echo "Requires:        keyutils redhat-lsb-core" >> $(METADATA)

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

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

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

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

+ 

+ 	rhts-lint $(METADATA)

tests/upstream/PURPOSE
file added
+3

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

+ PURPOSE of /CoreOS/keyutils/Sanity/run-upstream-testsuite

+ Description: runs test suite from the srpm package

+ Author: Karel Srot <ksrot@redhat.com>

tests/upstream/runtest.sh
file added
+55

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

+ #!/bin/bash

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

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

+ #

+ #   runtest.sh of /CoreOS/keyutils/Sanity/run-upstream-testsuite

+ #   Description: runs test suite from the srpm package

+ #   Author: Karel Srot <ksrot@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2017 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 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 Beaker environment

+ . /usr/bin/rhts-environment.sh || exit 1

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="keyutils"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+         rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"

+         rlRun "pushd $TmpDir"

+         rlFetchSrcForInstalled $PACKAGE

+         rlRun "rpm -i $PACKAGE-*.src.rpm"

+         rlRun "rpmbuild -bc ~/rpmbuild/SPECS/keyutils.spec"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+         rlRun -s "cd ~/rpmbuild/BUILD/keyutils*/ && make test"

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlRun "rpmbuild --clean ~/rpmbuild/SPECS/keyutils.spec"

+         rlRun "popd"

+         rlRun "rm -r $TmpDir" 0 "Removing tmp directory"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

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 Atomic. Test logs are stored in the artifacts directory.

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

Test environmentcd ar

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

Run tests for Classic

    # export ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)
        # curl -o keyutils.rpm https://kojipkgs.fedoraproject.org/packages/keyutils/1.5.10/3.fc27/x86_64/keyutils-1.5.10-3.fc27.x86_64.rpm 
    # export TEST_SUBJECTS=$PWD/keyutils.rpm
        # sudo su - 
        # ansible-playbook --tags=classic tests.yml

Run tests for Atomic

    # export ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)
        # curl -Lo atomic.qcow2 https://ftp-stud.hs-esslingen.de/pub/Mirrors/alt.fedoraproject.org/atomic/stable/Fedora-Atomic-26-20171030.0/CloudImages/x86_64/images/Fedora-Atomic-26-20171030.0.x86_64.qcow2 
    # export TEST_SUBJECTS=$PWD/atomic.qcow2
        # export EXTEND_DISK_SIZE=8G
        # ansible-playbook -i standard-inventory-qcow2 --tags=atomic tests.yml

Snip of the example test run for Classic tests:

PLAY RECAP ******************************************************************************************************************************************************************
rpms                       : ok=35   changed=13   unreachable=0    failed=0 

PASS request-key-d-parsing
PASS upstream

Snip of the example test run for Atomic tests:

PLAY RECAP ******************************************************************************************************************************************************************
/home/esaka/package_testing/upstream_first/keyutils/atomic.qcow2 : ok=18   changed=10   unreachable=0    failed=0

PASS request-key-d-parsing
PASS upstream

Tests passed under F-27, Rawhide