Add CI tests using the standard test interface

This commit is contained in:
Bruno Goncalves 2017-10-19 10:48:24 +02:00
parent 5d5ebcb425
commit 651216ed6a
10 changed files with 3951 additions and 0 deletions

View File

@ -0,0 +1,76 @@
# Copyright (c) 2006 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 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: Jakub Krysl <jkrysl@redhat.com>
# The toplevel namespace within which the test lives.
TOPLEVEL_NAMESPACE=kernel
# The name of the package under test:
PACKAGE_NAME=storage
# The path of the test below the package:
RELATIVE_PATH=lvm/device-mapper-persistent-data/thin
# Version of the Test. Used with make tag.
export TESTVERSION=1.0
# The combined namespace of the test.
export TEST=/$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
# A phony target is one that is not really the name of a file.
# It is just a name for some commands to be executed when you
# make an explicit request. There are two reasons to use a
# phony target: to avoid a conflict with a file of the same
# name, and to improve performance.
.PHONY: all install download clean
# executables to be built should be added here, they will be generated on the system under test.
BUILT_FILES=
# data files, .c files, scripts anything needed to either compile the test and/or run it.
FILES=$(METADATA) runtest.sh PURPOSE
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
chmod a+x ./runtest.sh
clean:
rm -f *~ *.rpm $(BUILT_FILES)
# You may need to add other targets e.g. to build executables from source code
# Add them here:
# Include Common Makefile
include /usr/share/rhts/lib/rhts-make.include
# Generate the testinfo.desc here:
$(METADATA): Makefile
@touch $(METADATA)
# Change to the test owner's name
@echo "Owner: Jakub Krysl <jkrysl@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "License: GPL" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Description: Testing thin tools provided by device-mapper-persistent-data">> $(METADATA)
@echo "TestTime: 1h" >> $(METADATA)
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
@echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
@echo "RhtsRequires: kernel-kernel-storage-misc-env_setup" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,30 @@
#===========================================================================
#
# PURPOSE file for:
# /kernel/storage/lvm/device-mapper-persistent-data/thin
#
# Description:
# Testing thin tools provided by device-mapper-persistent-data
#
# Bugs related:
#
#
# Author(s):
# Jakub Krysl
# <jkrysl@redhat.com>
#
#===========================================================================
# Note:
# As with some of Storage tests, at the end of the test it will check
# for errors on the logs.
# This check if implemented on /kernel/storage/include/python_modules
# LogChecker.py module
#
# To avoid Storage tests reporting error that were caused before the test
# started to run is recommended to run /kernel/storage/misc/log_checker
# just before running this test
#===========================================================================
# This task takes optional parameters:
#
#===========================================================================
# EndFile

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

18
tests/functions_test/runtest.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
# Copyright (c) 2017 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 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: Jakub Krysl <jkrysl@redhat.com>
rhts-run-simple-test functions_test ./dmpd_functions.py

26
tests/tests.yml Normal file
View File

@ -0,0 +1,26 @@
---
# Tests suitable to run in classic environment
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- classic
tests:
- tools_not_linked_usr
- functions_test
required_packages:
- findutils # beakerlib needs find command
- which # tools_not_linked_usr needs which command
# Tests suitable to run in container and atomic environments
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- container
- atomic
tests:
- tools_not_linked_usr
required_packages:
- findutils # beakerlib needs find command
- which # tools_not_linked_usr needs which command

View File

@ -0,0 +1,75 @@
# Copyright (c) 2006 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 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, see http://www.gnu.org/licenses/.
#
# Author: Bruno Goncalves <bgoncalv@redhat.com>
# The toplevel namespace within which the test lives.
TOPLEVEL_NAMESPACE=kernel
# The name of the package under test:
PACKAGE_NAME=storage
# The path of the test below the package:
RELATIVE_PATH=lvm/device-mapper-persistent-data/tools_not_linked_usr
# Version of the Test. Used with make tag.
export TESTVERSION=1.0
# The combined namespace of the test.
export TEST=/$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
# A phony target is one that is not really the name of a file.
# It is just a name for some commands to be executed when you
# make an explicit request. There are two reasons to use a
# phony target: to avoid a conflict with a file of the same
# name, and to improve performance.
.PHONY: all install download clean
# executables to be built should be added here, they will be generated on the system under test.
BUILT_FILES=
# data files, .c files, scripts anything needed to either compile the test and/or run it.
FILES=$(METADATA) runtest.sh PURPOSE tools_not_linked_usr.py
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
chmod a+x ./runtest.sh
chmod a+x ./tools_not_linked_usr.py
clean:
rm -f *~ *.rpm $(BUILT_FILES)
# You may need to add other targets e.g. to build executables from source code
# Add them here:
# Include Common Makefile
include /usr/share/rhts/lib/rhts-make.include
# Generate the testinfo.desc here:
$(METADATA): Makefile
@touch $(METADATA)
# Change to the test owner's name
@echo "Owner: Bruno Goncalves <bgoncalv@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "License: GPL" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Description: Make sure tools are not linked to lib under /usr.">> $(METADATA)
@echo "TestTime: 1h" >> $(METADATA)
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
@echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,13 @@
#===========================================================================
#
# Description:
# Make sure tools are not using any library that is linked to /usr
#
# Bugs related:
#
# Author(s):
# Bruno Goncalves
# <bgoncalv@redhat.com>
#
#===========================================================================
# EndFile

View File

@ -0,0 +1,18 @@
#!/bin/sh
# Copyright (c) 2006 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 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: Bruno Goncalves <bgoncalv@redhat.com>
rhts-run-simple-test tools_not_linked_usr ./tools_not_linked_usr.py

View File

@ -0,0 +1,93 @@
#!/usr/bin/python
# Copyright (c) 2006 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 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, see http://www.gnu.org/licenses/.
#
# Author: Bruno Goncalves <bgoncalv@redhat.com>
from os import walk
import subprocess
import sys
import re
def run(cmd):
print "INFO: Running '%s'..." % cmd
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
stdout, stderr = p.communicate()
retcode = p.returncode
output = stdout + stderr
print output
return retcode, output
def start_test():
#if uses any library linked to /usr this my affect the tools during boot
print ("INFO: Making sure tools provided by device-mapper-persistent-data "
"are not linked to /usr")
#Paths where we should have no libraries linked from
lib_paths = ["/usr/"]
package = "device-mapper-persistent-data"
run("yum install -y %s" % package)
#Get all tools that we need to check
ret, output = run("rpm -ql %s | grep \"sbin/\"" % package)
if ret != 0:
print("FAIL: Could not get the tools shipped from %s" % package)
return False
tools = output.split("\n")
error = False
for tool in tools:
if not tool:
#skip any blank line
continue
tool_error = 0
for lib_path in lib_paths:
print "INFO: Checking if %s is not linked to libraries at %s" % (tool, lib_path)
ret, linked_lib = run("ldd %s" % tool)
if ret != 0:
print("FAIL: Could not list dynamically libraries for %s" % (tool))
tool_error += 1
else:
#The command executed sucessfuly
#check if any library linked is from lib_path
links = linked_lib.split("\n")
for link in links:
if re.match(".*%s.*" % lib_path, link):
print("FAIL: %s is linked to %s" % (tool, link))
tool_error += 1
if tool_error == 0:
print("%s is not linked to %s" % (tool, lib_path))
else:
#found some error in at least 1 tool
error = True
if error:
return False
return True
def main():
if not start_test():
print "FAIL: test failed"
sys.exit(1)
print "PASS: Test pass"
sys.exit(0)
main()