Skip to content

Commit

Permalink
Initial gingko work
Browse files Browse the repository at this point in the history
This implements the ginkgo integration test framework for
podman.  As tests are migrated from bats to ginkgo, we will
still run both integration suites.  When a test is migrated,
we remove the tests from bats at that time.  All new tests
should be just for the ginkgo framework.

One exception is that we only run the ginkgo suit in the
travis/ubuntu environment.  The CentOS and Fedora PAPR nodes
will more than cover those.

Signed-off-by: baude <[email protected]>

Closes: #261
Approved by: baude
  • Loading branch information
baude authored and rh-atomic-bot committed Jan 29, 2018
1 parent 562a5de commit dd133a1
Show file tree
Hide file tree
Showing 15 changed files with 860 additions and 352 deletions.
95 changes: 10 additions & 85 deletions .papr.sh
Original file line number Diff line number Diff line change
@@ -1,111 +1,36 @@
#!/bin/bash
set -xeuo pipefail

DIST=$(cat /etc/redhat-release | awk '{print $1}')
IMAGE=registry.fedoraproject.org/fedora:27
PACKAGER=dnf
NOTEST=${NOTEST:-0}
if [[ ${DIST} != "Fedora" ]]; then
PACKAGER=yum
IMAGE=registry.centos.org/centos/centos:7
fi

if test -z "${INSIDE_CONTAINER:-}"; then
source /etc/os-release

if [ -f /run/ostree-booted ]; then

# by default, the root LV on AH is only 3G, but we need a
# bit more for our tests. Only do resize on centos and fedora
# versions less than 27
if [[ "$VERSION_ID" != "27" ]]; then
lvresize -r -L +4G atomicos/root
fi

if [ ! -e /var/tmp/ostree-unlock-ovl.* ]; then
ostree admin unlock
fi
fi
# Restarting docker helps with permissions related to above.
systemctl restart docker

# somewhat mimic the spec conditional
if [ "$ID" == fedora ]; then
PYTHON=python3
else
PYTHON=python
fi
docker run --rm \
--privileged \
-v $PWD:/go/src/github.com/projectatomic/libpod \
-v /etc/yum.repos.d:/etc/yum.repos.d.host:ro \
-v /usr:/host/usr \
-v /etc:/host/etc \
-v /host:/host/var \
--workdir /go/src/github.com/projectatomic/libpod \
-e INSIDE_CONTAINER=1 \
-e PYTHON=$PYTHON \
-e NOTEST=$NOTEST \
${IMAGE} /go/src/github.com/projectatomic/libpod/.papr.sh
if [[ "${NOTEST}" -eq 1 ]]; then
exit
fi
systemd-detect-virt
script -qefc ./test/test_runner.sh
exit 0
fi

export GOPATH=/go
export PATH=$HOME/gopath/bin:$PATH
export GOSRC=/$GOPATH/src/github.com/projectatomic/libpod

${PACKAGER} install -y \
btrfs-progs-devel \
bzip2 \
device-mapper-devel \
findutils \
git \
glib2-devel \
gnupg \
golang \
gpgme-devel \
libassuan-devel \
libseccomp-devel \
libselinux-devel \
skopeo-containers \
runc \
make \
ostree-devel \
python \
which\
golang-github-cpuguy83-go-md2man


# PAPR adds a merge commit, for testing, which fails the
# short-commit-subject validation test, so tell git-validate.sh to only check
# up to, but not including, the merge commit.
export GITVALIDATE_TIP=$(cd $GOSRC; git log -2 --pretty='%H' | tail -n 1)
export TAGS="seccomp $($GOSRC/hack/btrfs_tag.sh) $($GOSRC/hack/libdm_tag.sh) $($GOSRC/hack/btrfs_installed_tag.sh) $($GOSRC/hack/ostree_tag.sh) $($GOSRC/hack/selinux_tag.sh)"

if [[ "${NOTEST}" -eq 0 ]]; then
make gofmt TAGS="${TAGS}"
make testunit TAGS="${TAGS}"
fi
make gofmt TAGS="${TAGS}"
make testunit TAGS="${TAGS}"

make install.tools TAGS="${TAGS}"

# Only check lint and gitvalidation on more recent
# distros with updated git and tooling
if [[ ${PACKAGER} != "yum" ]] && [[ "${NOTEST}" -eq 0 ]]; then
if [[ ${DIST} == "Fedora" ]]; then
HEAD=$GITVALIDATE_TIP make -C $GOSRC .gitvalidation TAGS="${TAGS}"
make lint
fi

# Make and install podman
make TAGS="${TAGS}"
make TAGS="${TAGS}" install PREFIX=/host/usr ETCDIR=/host/etc
make TAGS="${TAGS}" install PREFIX=/usr ETCDIR=/etc
make TAGS="${TAGS}" test-binaries

# Add the new bats core instead of the deprecated bats
git clone https://github.com/bats-core/bats-core /bats-core
cd /bats-core
install -D -m 755 libexec/* /host/usr/bin/
# Run the ginkgo integration tests
GOPATH=/go ginkgo test/e2e/.
# Run the bats integration tests
script -qefc ./test/test_runner.sh
exit 0
12 changes: 3 additions & 9 deletions .papr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,13 @@ host:
distro: fedora/27/atomic
specs:
ram: 8192
cpus: 4

required: true
timeout: 45m

tests:
- CRIO_ROOT=/var/tmp/checkout PODMAN_BINARY=/usr/bin/podman CONMON_BINARY=/usr/libexec/crio/conmon PAPR=1 sh .papr.sh

packages:
- cri-o
- containernetworking-cni

extra-repos:
- name: updatestesting
baseurl: http://download.fedoraproject.org/pub/fedora/linux/updates/testing/27/x86_64/
- sh .papr_prepare.sh

---

Expand All @@ -29,6 +22,7 @@ host:
distro: centos/7/atomic/smoketested
specs:
ram: 8192
cpus: 4
extra-repos:
- name: epel
metalink: https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
Expand Down
16 changes: 16 additions & 0 deletions .papr_prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -xeuo pipefail

DIST=$(cat /etc/redhat-release | awk '{print $1}')
IMAGE=fedorapodmanbuild
PYTHON=python3
if [[ ${DIST} != "Fedora" ]]; then
IMAGE=centospodmanbuild
PYTHON=python
fi

# Build the test image
docker build -t ${IMAGE} -f Dockerfile.${DIST} .

# Run the tests
docker run --rm --privileged -v $PWD:/go/src/github.com/projectatomic/libpod --workdir /go/src/github.com/projectatomic/libpod -e PYTHON=$PYTHON -e STORAGE_OPTIONS="--storage-driver=vfs" -e CRIO_ROOT="/go/src/github.com/projectatomic/libpod" -e PODMAN_BINARY="/usr/bin/podman" -e CONMON_BINARY="/usr/libexec/crio/conmon" -e DIST=$DIST $IMAGE sh .papr.sh
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ RUN set -x \
&& cp "$GOPATH"/bin/crictl /usr/bin/ \
&& rm -rf "$GOPATH"

# Install ginkgo
RUN set -x \
&& export GOPATH=/go \
&& go get -u github.com/onsi/ginkgo/ginkgo \
&& install -D -m 755 "$GOPATH"/bin/ginkgo /usr/bin/

# Install gomega
RUN set -x \
&& export GOPATH=/go \
&& go get github.com/onsi/gomega/...

# Install cni config
#RUN make install.cni
RUN mkdir -p /etc/cni/net.d/
COPY cni/87-podman-bridge.conflist /etc/cni/net.d/87-podman-bridge.conflist

# Make sure we have some policy for pulling images
RUN mkdir -p /etc/containers
COPY test/policy.json /etc/containers/policy.json
Expand Down
78 changes: 78 additions & 0 deletions Dockerfile.CentOSDev
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
FROM registry.centos.org/centos/centos:7

RUN yum -y install btrfs-progs-devel \
bzip2 \
device-mapper-devel \
findutils \
git \
glib2-devel \
gnupg \
golang \
gpgme-devel \
libassuan-devel \
libseccomp-devel \
libselinux-devel \
skopeo-containers \
runc \
make \
ostree-devel \
python \
which\
golang-github-cpuguy83-go-md2man \
iptables && yum clean all

# install bats
RUN cd /tmp \
&& git clone https://github.com/sstephenson/bats.git \
&& cd bats \
&& git reset --hard 03608115df2071fff4eaaff1605768c275e5f81f \
&& ./install.sh /usr/local \
&& rm -fr /tmp/bats

# Install CNI plugins
ENV CNI_COMMIT 7480240de9749f9a0a5c8614b17f1f03e0c06ab9
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/containernetworking/plugins.git "$GOPATH/src/github.com/containernetworking/plugins" \
&& cd "$GOPATH/src/github.com/containernetworking/plugins" \
&& git checkout -q "$CNI_COMMIT" \
&& ./build.sh \
&& mkdir -p /usr/libexec/cni \
&& cp bin/* /usr/libexec/cni \
&& rm -rf "$GOPATH"

# Install ginkgo
RUN set -x \
&& export GOPATH=/go \
&& go get -u github.com/onsi/ginkgo/ginkgo \
&& install -D -m 755 "$GOPATH"/bin/ginkgo /usr/bin/

# Install gomega
RUN set -x \
&& export GOPATH=/go \
&& go get github.com/onsi/gomega/...

# Install conmon
ENV CRIO_COMMIT 814c6ab0913d827543696b366048056a31d9529c
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/kubernetes-incubator/cri-o.git "$GOPATH/src/github.com/kubernetes-incubator/cri-o.git" \
&& cd "$GOPATH/src/github.com/kubernetes-incubator/cri-o.git" \
&& git fetch origin --tags \
&& git checkout -q "$CRIO_COMMIT" \
&& mkdir bin \
&& make conmon \
&& install -D -m 755 bin/conmon /usr/libexec/crio/conmon \
&& rm -rf "$GOPATH"

# Install cni config
#RUN make install.cni
RUN mkdir -p /etc/cni/net.d/
COPY cni/87-podman-bridge.conflist /etc/cni/net.d/87-podman-bridge.conflist

# Make sure we have some policy for pulling images
RUN mkdir -p /etc/containers
COPY test/policy.json /etc/containers/policy.json
COPY test/redhat_sigstore.yaml /etc/containers/registries.d/registry.access.redhat.com.yaml

WORKDIR /go/src/github.com/projectatomic/libpod
67 changes: 67 additions & 0 deletions Dockerfile.Fedora
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM registry.fedoraproject.org/fedora:27

RUN dnf -y install btrfs-progs-devel \
bzip2 \
device-mapper-devel \
findutils \
git \
glib2-devel \
gnupg \
golang \
gpgme-devel \
libassuan-devel \
libseccomp-devel \
libselinux-devel \
skopeo-containers \
runc \
make \
ostree-devel \
python \
which\
golang-github-cpuguy83-go-md2man \
crio \
procps-ng \
iptables && dnf clean all

# install bats
RUN cd /tmp \
&& git clone https://github.com/sstephenson/bats.git \
&& cd bats \
&& git reset --hard 03608115df2071fff4eaaff1605768c275e5f81f \
&& ./install.sh /usr/local \
&& rm -fr /tmp/bats

# Install CNI plugins
ENV CNI_COMMIT 7480240de9749f9a0a5c8614b17f1f03e0c06ab9
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/containernetworking/plugins.git "$GOPATH/src/github.com/containernetworking/plugins" \
&& cd "$GOPATH/src/github.com/containernetworking/plugins" \
&& git checkout -q "$CNI_COMMIT" \
&& ./build.sh \
&& mkdir -p /usr/libexec/cni \
&& cp bin/* /usr/libexec/cni \
&& rm -rf "$GOPATH"

# Install ginkgo
RUN set -x \
&& export GOPATH=/go \
&& go get -u github.com/onsi/ginkgo/ginkgo \
&& install -D -m 755 "$GOPATH"/bin/ginkgo /usr/bin/

# Install gomega
RUN set -x \
&& export GOPATH=/go \
&& go get github.com/onsi/gomega/...

# Install cni config
#RUN make install.cni
RUN mkdir -p /etc/cni/net.d/
COPY cni/87-podman-bridge.conflist /etc/cni/net.d/87-podman-bridge.conflist

# Make sure we have some policy for pulling images
RUN mkdir -p /etc/containers
COPY test/policy.json /etc/containers/policy.json
COPY test/redhat_sigstore.yaml /etc/containers/registries.d/registry.access.redhat.com.yaml

WORKDIR /go/src/github.com/projectatomic/libpod
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions
OCIUMOUNTINSTALLDIR=$(PREFIX)/share/oci-umount/oci-umount.d

SELINUXOPT ?= $(shell test -x /usr/sbin/selinuxenabled && selinuxenabled && echo -Z)
PACKAGES ?= $(shell go list -tags "${BUILDTAGS}" ./... | grep -v github.com/projectatomic/libpod/vendor)
PACKAGES ?= $(shell go list -tags "${BUILDTAGS}" ./... | grep -v github.com/projectatomic/libpod/vendor | grep -v e2e)

COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
GIT_COMMIT := $(if $(shell git status --porcelain --untracked-files=no),"${COMMIT_NO}-dirty","${COMMIT_NO}")
Expand Down Expand Up @@ -110,10 +110,16 @@ dbuild: libpodimage
integration: libpodimage
docker run -e STORAGE_OPTIONS="--storage-driver=vfs" -e TESTFLAGS -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} make localintegration

integration.fedora:
DIST=Fedora sh .papr_prepare.sh
testunit:
$(GO) test -tags "$(BUILDTAGS)" -cover $(PACKAGES)

ginkgo:
ginkgo -v test/e2e/

localintegration: test-binaries
ginkgo -v test/e2e/.
bash -i ./test/test_runner.sh ${TESTFLAGS}

vagrant-check:
Expand Down
Loading

0 comments on commit dd133a1

Please sign in to comment.