New tests subpackage

Define a new podman-tests subpackage, containing a set of
tests intended to be run as gates. As of this initial checkin,
this consists of a set of BATS tests in /usr/share/podman .

Include a configuration for running under Fedora CI

Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
Ed Santiago 2019-01-18 10:59:24 -07:00
parent 594b7dca26
commit aea393b7eb
3 changed files with 39 additions and 79 deletions

View File

@ -44,7 +44,7 @@ Epoch: 2
Epoch: 1 Epoch: 1
%endif %endif
Version: 1.2.0 Version: 1.2.0
Release: 15.dev.git%{shortcommit0}%{?dist} Release: 16.dev.git%{shortcommit0}%{?dist}
Summary: Manage Pods, Containers and Container Images Summary: Manage Pods, Containers and Container Images
License: ASL 2.0 License: ASL 2.0
URL: https://podman.io/ URL: https://podman.io/
@ -197,7 +197,7 @@ Conflicts: docker
Conflicts: docker-latest Conflicts: docker-latest
Conflicts: docker-ce Conflicts: docker-ce
Conflicts: docker-ee Conflicts: docker-ee
Conflicts: moby-engine Conflicts: moby-engine
%description docker %description docker
This package installs a script named docker that emulates the Docker CLI by This package installs a script named docker that emulates the Docker CLI by
@ -364,6 +364,18 @@ This package contains unit tests for project
providing packages with %{import_path} prefix. providing packages with %{import_path} prefix.
%endif %endif
%package tests
Summary: Tests for %{name}
Requires: %{name} = %{epoch}:%{version}-%{release}
Requires: bats
Requires: jq
%description tests
%{summary}
This package contains system tests for %{name}
%prep %prep
%autosetup -Sgit -n %{repo}-%{commit0} %autosetup -Sgit -n %{repo}-%{commit0}
@ -472,13 +484,16 @@ export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath}
%if ! 0%{?gotest:1} %if ! 0%{?gotest:1}
%global gotest go test %global gotest go test
%endif %endif
%gotest %{import_path}/cmd/%{name} %gotest %{import_path}/cmd/%{name}
%gotest %{import_path}/libkpod %gotest %{import_path}/libkpod
%gotest %{import_path}/libpod %gotest %{import_path}/libpod
%gotest %{import_path}/pkg/registrar %gotest %{import_path}/pkg/registrar
%endif %endif
install -d -p %{buildroot}/%{_datadir}/%{name}/test/system
cp -pav test/system %{buildroot}/%{_datadir}/%{name}/test/
#define license tag if not already defined #define license tag if not already defined
%{!?_licensedir:%global license %doc} %{!?_licensedir:%global license %doc}
@ -517,7 +532,14 @@ export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath}
podman system renumber podman system renumber
exit 0 exit 0
%files tests
%license LICENSE
%{_datadir}/%{name}/test
%changelog %changelog
* Wed Mar 13 2019 Eduardo Santiago <santiago@redhat.com> - 2:1.2.0-16.dev.git883566f
- new -tests subpackage
* Wed Mar 13 2019 Lokesh Mandvekar (Bot) <lsm5+bot@fedoraproject.org> - 2:1.2.0-15.dev.git883566f * Wed Mar 13 2019 Lokesh Mandvekar (Bot) <lsm5+bot@fedoraproject.org> - 2:1.2.0-15.dev.git883566f
- autobuilt 883566f - autobuilt 883566f
@ -1299,4 +1321,3 @@ containernetworking-cni
* Wed Jan 10 2018 Frantisek Kluknavsky <fkluknav@redhat.com> - 0-0.1.gitc1b2278 * Wed Jan 10 2018 Frantisek Kluknavsky <fkluknav@redhat.com> - 0-0.1.gitc1b2278
- First package for Fedora - First package for Fedora

View File

@ -3,80 +3,11 @@
# Simple podman tests # Simple podman tests
# #
set -x rm -f /tmp/test.log /tmp/test.debug.log
exec >/tmp/test.debug.log 2>&1 # Log program versions
rpm -q podman podman-tests >/tmp/test.debug.log
echo "************************************************************************" bats /usr/share/podman/test/system &> /tmp/test.log
echo "* This log contains the debug output from test_podman.sh."
echo "*"
echo "* Short test PASS/FAIL summary is in test.log"
echo "************************************************************************"
rm -f /tmp/test.log echo "bats completed with status $?" >>/tmp/test.debug.log
touch /tmp/test.log
counter_file=/tmp/test.counter.txt
echo 0 >| $counter_file
do_test() {
local cmd="$1"; shift
local expected_status="$1"; shift
local expected_stdout="$1"; shift
counter=$(expr $(< $counter_file) + 1)
echo $counter >| $counter_file
# Make debug log easier to read
echo
echo "--------------------------------------------------------------------"
echo "-- test $counter"
echo
stdout=$(eval podman $cmd)
status=$?
if [ $status -ne $expected_status ]; then
echo "FAIL $counter $cmd: status=$status (expected $expected_status)" >>/tmp/test.log
return
fi
if [ "$expected_stdout" = "-" ]; then
:
elif [ -z "$expected_stdout" ]; then
if [ -n "$stdout" ]; then
echo "FAIL $counter $cmd : stdout='$stdout' (expected '')" >>/tmp/test.log
return
fi
else
if ! expr "$stdout" : "$expected_stdout"; then
echo "FAIL $counter $cmd : stdout='$stdout' (expected '$expected_stdout')" >>/tmp/test.log
return
fi
fi
echo "PASS $counter $cmd" >>/tmp/test.log
}
# Clean slate
do_test "rm -a -f" 0 "-"
do_test "rmi -a -f" 0 "-"
do_test "info --format '{{.host.rootless}}'" 0 "false"
do_test "info --format '{{.store.GraphDriverName}}'" 0 "overlay"
do_test "pull alpine" 0 "-"
do_test "images --format {{.Repository}}:{{.Tag}}" 0 \
"docker.io/library/alpine:latest"
do_test "run alpine sh -c 'echo hi'" 0 "hi"
do_test "run alpine date" 0 "-"
do_test "run alpine /bin/false" 1 ""
do_test "ps -a | wc -l" 0 "4"
do_test "ps -a | grep false | grep -q 'Exited (1)'" 0 ""
# Final exit status: nonzero if the word FAIL is present in results
if grep -q FAIL /tmp/test.log; then
exit 1
fi
exit 0

View File

@ -2,8 +2,15 @@
- hosts: localhost - hosts: localhost
vars: vars:
- artifacts: ./artifacts - artifacts: ./artifacts
# FIXME! It would be cleaner to include 'podman' in this list; but the
# dnf module is broken in ansible <= 2.8, it doesn't report failures
# to install as long as _one_ package installs! So if podman installs
# but podman-tests doesn't, the `dnf` stanza succeeds, then the test
# one fails with a less-than-helpful error.
#
# See https://github.com/ansible/ansible/pull/49760
- required_packages: - required_packages:
- podman - podman-tests
tags: tags:
- classic - classic
- container - container
@ -14,6 +21,7 @@
enablerepo=updates-testing enablerepo=updates-testing
- block: - block:
# FIXME: how to make two passes, one as root and one rootless?
- name: Run test - name: Run test
script: ./test_podman.sh script: ./test_podman.sh
always: always: