diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/README.md | 115 | ||||
-rw-r--r-- | test/e2e/libpod_suite_test.go | 14 | ||||
-rw-r--r-- | test/e2e/load_test.go | 116 | ||||
-rw-r--r-- | test/e2e/mount_test.go | 64 | ||||
-rw-r--r-- | test/e2e/port_test.go | 82 | ||||
-rw-r--r-- | test/e2e/run_networking_test.go | 3 | ||||
-rw-r--r-- | test/e2e/search_test.go | 67 | ||||
-rw-r--r-- | test/helpers.bash | 359 | ||||
-rw-r--r-- | test/podman_build.bats | 265 | ||||
-rw-r--r-- | test/podman_load.bats | 81 | ||||
-rw-r--r-- | test/podman_mount.bats | 38 | ||||
-rw-r--r-- | test/podman_pause.bats | 112 | ||||
-rw-r--r-- | test/podman_port.bats | 43 | ||||
-rw-r--r-- | test/podman_search.bats | 43 | ||||
-rwxr-xr-x | test/test_runner.sh | 22 |
15 files changed, 378 insertions, 1046 deletions
diff --git a/test/README.md b/test/README.md index 1dd2e3c76..78fb52cab 100644 --- a/test/README.md +++ b/test/README.md @@ -1,106 +1,59 @@ -# CRIO Integration Tests +# Integration testing -Integration tests provide end-to-end testing of CRIO. +Our primary means of performing integration testing for libpod is with the +[Ginkgo](https://github.com/onsi/ginkgo) BDD testing framework. This allows +us to use native Golang to perform our tests and there is a strong affiliation +between Ginkgo and the Go test framework. -Note that integration tests do **not** replace unit tests. +## Installing dependencies +The dependencies for integration really consists of three things: +* ginkgo binary +* ginkgo sources +* gomega sources -As a rule of thumb, code should be tested thoroughly with unit tests. -Integration tests on the other hand are meant to test a specific feature end -to end. +The following instructions assume your GOPATH is ~/go. Adjust as needed for your +environment. -Integration tests are written in *bash* using the -[bats](https://github.com/sstephenson/bats) framework. - -## Running integration tests - -### Containerized tests - -The easiest way to run integration tests is with Docker: +### Installing ginko +Fetch and build ginkgo with the following command: ``` -$ make integration +GOPATH=~/go go get -u github.com/onsi/ginkgo/ginkgo ``` - -To run a single test bucket: +Now install the ginkgo binary into your path: ``` -$ make integration TESTFLAGS="runtimeversion.bats" +install -D -m 755 "$GOPATH"/bin/ginkgo /usr/bin/ ``` +You now have a ginkgo binary and its sources in your GOPATH. -### On your host - -To run the integration tests on your host, you will first need to setup a development environment plus -[bats](https://github.com/sstephenson/bats#installing-bats-from-source) -For example: +### Install gomega sources +The gomega sources can be simply installed with the command: ``` -$ cd ~/go/src/github.com -$ git clone https://github.com/sstephenson/bats.git -$ cd bats -$ ./install.sh /usr/local +GOPATH=~/go go get github.com/onsi/gomega/... ``` -You will also need to install the [CNI](https://github.com/containernetworking/cni) plugins as -the the default pod test template runs without host networking: +### Running the integration tests -``` -$ go get github.com/containernetworking/cni -$ cd "$GOPATH/src/github.com/containernetworking/cni" -$ git checkout -q d4bbce1865270cd2d2be558d6a23e63d314fe769 -$ ./build.sh \ -$ mkdir -p /opt/cni/bin \ -$ cp bin/* /opt/cni/bin/ -``` +You can run the entire suite of integration tests with the following command: -Then you can run the tests on your host: ``` -$ sudo make localintegration +GOPATH=~/go ginkgo -v tests/e2e/. ``` -To run a single test bucket: -``` -$ make localintegration TESTFLAGS="runtimeversion.bats" -``` +Note the trailing period on the command above. Also, **-v** invokes verbose mode. That +switch is optional. + +You can run a single file of integration tests using the go test command: -Or you can just run them directly using bats ``` -$ sudo bats test +GOPATH=~/go go test -v tests/e2e/libpod_suite_test.go tests/e2e/your_test.go ``` -#### Runtime selection -Tests on the host will run with `runc` as the default runtime. -However you can select other OCI compatible runtimes by setting -the `RUNTIME` environment variable. - -For example one could use the [Clear Containers](https://github.com/01org/cc-oci-runtime/wiki/Installation) -runtime instead of `runc`: +#### Run all tests like PAPR +You can closely emulate the PAPR run for Fedora with the following command: ``` -make localintegration RUNTIME=cc-oci-runtime +make integration.fedora ``` -## Writing integration tests - -[Helper functions] -(https://github.com/kubernetes-incubator/crio/blob/master/test/helpers.bash) -are provided in order to facilitate writing tests. - -```sh -#!/usr/bin/env bats - -# This will load the helpers. -load helpers - -# setup is called at the beginning of every test. -function setup() { -} - -# teardown is called at the end of every test. -function teardown() { - cleanup_test -} - -@test "crioctl runtimeversion" { - start_crio - crioctl runtimeversion - [ "$status" -eq 0 ] -} - -``` +This will run lint, git-validation, and gofmt tests and then execute unit and integration +tests as well. diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go index d6263beb2..e6f110dad 100644 --- a/test/e2e/libpod_suite_test.go +++ b/test/e2e/libpod_suite_test.go @@ -39,11 +39,12 @@ var ( INTEGRATION_ROOT string STORAGE_OPTIONS = "--storage-driver vfs" ARTIFACT_DIR = "/tmp/.artifacts" - CACHE_IMAGES = []string{"alpine", "busybox", fedoraMinimal} + CACHE_IMAGES = []string{"alpine", "busybox", fedoraMinimal, nginx} RESTORE_IMAGES = []string{"alpine", "busybox"} ALPINE = "docker.io/library/alpine:latest" BB_GLIBC = "docker.io/library/busybox:glibc" fedoraMinimal = "registry.fedoraproject.org/fedora-minimal:latest" + nginx = "docker.io/library/nginx:latest" defaultWaitTimeout = 90 ) @@ -427,3 +428,14 @@ func (s *PodmanSession) LineInOuputStartsWith(term string) bool { } return false } + +//LineInOutputContains returns true if a line in a +// session output starts with the supplied string +func (s *PodmanSession) LineInOuputContains(term string) bool { + for _, i := range s.OutputToStringArray() { + if strings.Contains(i, term) { + return true + } + } + return false +} diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go new file mode 100644 index 000000000..e36883b16 --- /dev/null +++ b/test/e2e/load_test.go @@ -0,0 +1,116 @@ +package integration + +import ( + "os" + "path/filepath" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman load", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + }) + + It("podman load input flag", func() { + outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") + + save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).To(Equal(0)) + + rmi := podmanTest.Podman([]string{"rmi", ALPINE}) + rmi.WaitWithDefaultTimeout() + Expect(rmi.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"load", "-i", outfile}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + + It("podman load oci-archive image", func() { + outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") + + save := podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).To(Equal(0)) + + rmi := podmanTest.Podman([]string{"rmi", ALPINE}) + rmi.WaitWithDefaultTimeout() + Expect(rmi.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"load", "-i", outfile}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + + It("podman load oci-archive with signature", func() { + outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") + + save := podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).To(Equal(0)) + + rmi := podmanTest.Podman([]string{"rmi", ALPINE}) + rmi.WaitWithDefaultTimeout() + Expect(rmi.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"load", "--signature-policy", "/etc/containers/policy.json", "-i", outfile}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + + It("podman load with quiet flag", func() { + outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") + + save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).To(Equal(0)) + + rmi := podmanTest.Podman([]string{"rmi", ALPINE}) + rmi.WaitWithDefaultTimeout() + Expect(rmi.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"load", "-q", "-i", outfile}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + + It("podman load directory", func() { + outdir := filepath.Join(podmanTest.TempDir, "alpine") + + save := podmanTest.Podman([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).To(Equal(0)) + + rmi := podmanTest.Podman([]string{"rmi", ALPINE}) + rmi.WaitWithDefaultTimeout() + Expect(rmi.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"load", "-i", outdir}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + + It("podman load bogus file", func() { + save := podmanTest.Podman([]string{"load", "-i", "foobar.tar"}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).ToNot(Equal(0)) + }) +}) diff --git a/test/e2e/mount_test.go b/test/e2e/mount_test.go new file mode 100644 index 000000000..cc1cc8edf --- /dev/null +++ b/test/e2e/mount_test.go @@ -0,0 +1,64 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman mount", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + }) + + It("podman mount", func() { + setup := podmanTest.Podman([]string{"create", ALPINE, "ls"}) + setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) + cid := setup.OutputToString() + + mount := podmanTest.Podman([]string{"mount", cid}) + mount.WaitWithDefaultTimeout() + Expect(mount.ExitCode()).To(Equal(0)) + + umount := podmanTest.Podman([]string{"umount", cid}) + umount.WaitWithDefaultTimeout() + Expect(umount.ExitCode()).To(Equal(0)) + }) + + It("podman mount with json format", func() { + setup := podmanTest.Podman([]string{"create", ALPINE, "ls"}) + setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) + cid := setup.OutputToString() + + mount := podmanTest.Podman([]string{"mount", cid}) + mount.WaitWithDefaultTimeout() + Expect(mount.ExitCode()).To(Equal(0)) + + j := podmanTest.Podman([]string{"mount", "--format=json"}) + j.WaitWithDefaultTimeout() + Expect(j.ExitCode()).To(Equal(0)) + Expect(j.IsJSONOutputValid()) + + umount := podmanTest.Podman([]string{"umount", cid}) + umount.WaitWithDefaultTimeout() + Expect(umount.ExitCode()).To(Equal(0)) + }) +}) diff --git a/test/e2e/port_test.go b/test/e2e/port_test.go new file mode 100644 index 000000000..963221253 --- /dev/null +++ b/test/e2e/port_test.go @@ -0,0 +1,82 @@ +package integration + +import ( + "os" + + "fmt" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "strings" +) + +var _ = Describe("Podman port", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman port all and latest", func() { + result := podmanTest.Podman([]string{"port", "-a", "-l"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).ToNot(Equal(0)) + }) + + It("podman port all and extra", func() { + result := podmanTest.Podman([]string{"port", "-a", "foobar"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).ToNot(Equal(0)) + }) + + It("podman port -l nginx", func() { + podmanTest.RestoreArtifact(nginx) + session := podmanTest.Podman([]string{"run", "-dt", "-P", "docker.io/library/nginx:latest"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"port", "-l"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + port := strings.Split(result.OutputToStringArray()[0], ":")[1] + Expect(result.LineInOuputStartsWith(fmt.Sprintf("80/udp -> 0.0.0.0:%s", port))).To(BeTrue()) + Expect(result.LineInOuputStartsWith(fmt.Sprintf("80/tcp -> 0.0.0.0:%s", port))).To(BeTrue()) + }) + + It("podman port -l port nginx", func() { + podmanTest.RestoreArtifact(nginx) + session := podmanTest.Podman([]string{"run", "-dt", "-P", "docker.io/library/nginx:latest"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"port", "-l", "80"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + port := strings.Split(result.OutputToStringArray()[0], ":")[1] + Expect(result.LineInOuputStartsWith(fmt.Sprintf("0.0.0.0:%s", port))).To(BeTrue()) + }) + + It("podman port -a nginx", func() { + podmanTest.RestoreArtifact(nginx) + session := podmanTest.Podman([]string{"run", "-dt", "-P", "docker.io/library/nginx:latest"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"port", "-a"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) +}) diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index e60da148d..68be154f5 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -68,7 +68,8 @@ var _ = Describe("Podman rmi", func() { }) It("podman run network expose ports in image metadata", func() { - session := podmanTest.Podman([]string{"run", "-dt", "-P", "docker.io/library/nginx:latest"}) + podmanTest.RestoreArtifact(nginx) + session := podmanTest.Podman([]string{"run", "-dt", "-P", nginx}) session.Wait(90) Expect(session.ExitCode()).To(Equal(0)) results := podmanTest.Podman([]string{"inspect", "-l"}) diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go new file mode 100644 index 000000000..fbe5a4580 --- /dev/null +++ b/test/e2e/search_test.go @@ -0,0 +1,67 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman search", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman search", func() { + search := podmanTest.Podman([]string{"search", "alpine"}) + search.WaitWithDefaultTimeout() + Expect(search.ExitCode()).To(Equal(0)) + Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1)) + Expect(search.LineInOuputContains("docker.io/library/alpine")).To(BeTrue()) + }) + + It("podman search registry flag", func() { + search := podmanTest.Podman([]string{"search", "--registry", "registry.fedoraproject.org", "fedora-minimal"}) + search.WaitWithDefaultTimeout() + Expect(search.ExitCode()).To(Equal(0)) + Expect(search.LineInOuputContains("fedoraproject.org/fedora-minimal")).To(BeTrue()) + }) + + It("podman search format flag", func() { + search := podmanTest.Podman([]string{"search", "--format", "table {{.Index}} {{.Name}}", "alpine"}) + search.WaitWithDefaultTimeout() + Expect(search.ExitCode()).To(Equal(0)) + Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1)) + Expect(search.LineInOuputContains("docker.io/library/alpine")).To(BeTrue()) + }) + + It("podman search no-trunc flag", func() { + search := podmanTest.Podman([]string{"search", "alpine"}) + search.WaitWithDefaultTimeout() + Expect(search.ExitCode()).To(Equal(0)) + Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1)) + Expect(search.LineInOuputContains("docker.io/library/alpine")).To(BeTrue()) + }) + + It("podman search limit flag", func() { + search := podmanTest.Podman([]string{"search", "--limit", "3", "alpine"}) + search.WaitWithDefaultTimeout() + Expect(search.ExitCode()).To(Equal(0)) + Expect(len(search.OutputToStringArray())).To(Equal(4)) + }) +}) diff --git a/test/helpers.bash b/test/helpers.bash deleted file mode 100644 index 222e7bb26..000000000 --- a/test/helpers.bash +++ /dev/null @@ -1,359 +0,0 @@ -#!/bin/bash - -# Root directory of integration tests. -INTEGRATION_ROOT=$(dirname "$(readlink -f "$BASH_SOURCE")") - -# Test data path. -TESTDATA="${INTEGRATION_ROOT}/testdata" - -# Root directory of the repository. -if [[ ! -z "$CRIO_ROOT" ]]; then - CRIO_ROOT=${CRIO_ROOT} -elif [[ ! -z "$TRAVIS" ]]; then - CRIO_ROOT="/go/src/github.com/projectatomic/libpod" -elif [[ ! -z "$PAPR" ]]; then - CRIO_ROOT="/var/tmp/checkout" -else - CRIO_ROOT=$(cd "$INTEGRATION_ROOT/.."; pwd -P) -fi - -PODMAN_BINARY=${PODMAN_BINARY:-${CRIO_ROOT}/bin/podman} -# Path of the default seccomp profile. -SECCOMP_PROFILE=${SECCOMP_PROFILE:-${CRIO_ROOT}/seccomp.json} -# Name of the default apparmor profile. -APPARMOR_PROFILE=${APPARMOR_PROFILE:-crio-default} -# Conmon -CONMON=${CONMON:-conmon} -CONMON_PATH=$(command -v $CONMON || true) -CONMON_BINARY=${CONMON_PATH:-/usr/libexec/crio/conmon} -# Runtime -RUNTIME=${RUNTIME:-runc} -RUNTIME_PATH=$(command -v $RUNTIME || true) -RUNTIME_BINARY=${RUNTIME_PATH:-/usr/local/sbin/runc} -# Path of the apparmor_parser binary. -APPARMOR_PARSER_BINARY=${APPARMOR_PARSER_BINARY:-/sbin/apparmor_parser} -# Path of the apparmor profile for test. -APPARMOR_TEST_PROFILE_PATH=${APPARMOR_TEST_PROFILE_PATH:-${TESTDATA}/apparmor_test_deny_write} -# Path of the apparmor profile for unloading crio-default. -FAKE_CRIO_DEFAULT_PROFILE_PATH=${FAKE_CRIO_DEFAULT_PROFILE_PATH:-${TESTDATA}/fake_crio_default} -# Name of the apparmor profile for test. -APPARMOR_TEST_PROFILE_NAME=${APPARMOR_TEST_PROFILE_NAME:-apparmor-test-deny-write} -# Path of boot config. -BOOT_CONFIG_FILE_PATH=${BOOT_CONFIG_FILE_PATH:-/boot/config-`uname -r`} -# Path of apparmor parameters file. -APPARMOR_PARAMETERS_FILE_PATH=${APPARMOR_PARAMETERS_FILE_PATH:-/sys/module/apparmor/parameters/enabled} -# Path of the bin2img binary. -BIN2IMG_BINARY=${BIN2IMG_BINARY:-${CRIO_ROOT}/test/bin2img/bin2img} -# Path of the copyimg binary. -COPYIMG_BINARY=${COPYIMG_BINARY:-${CRIO_ROOT}/test/copyimg/copyimg} -# Path of tests artifacts. -ARTIFACTS_PATH=${ARTIFACTS_PATH:-${CRIO_ROOT}/.artifacts} -# Path of the checkseccomp binary. -CHECKSECCOMP_BINARY=${CHECKSECCOMP_BINARY:-${CRIO_ROOT}/test/checkseccomp/checkseccomp} -# XXX: This is hardcoded inside cri-o at the moment. -DEFAULT_LOG_PATH=/var/log/crio/pods -# Cgroup manager to be used -CGROUP_MANAGER=${CGROUP_MANAGER:-cgroupfs} -# Image volumes handling -IMAGE_VOLUMES=${IMAGE_VOLUMES:-mkdir} -# Container pids limit -PIDS_LIMIT=${PIDS_LIMIT:-1024} -# Log size max limit -LOG_SIZE_MAX_LIMIT=${LOG_SIZE_MAX_LIMIT:--1} - -if [[ ! -d "/test.dir" ]]; then - mkdir /test.dir -fi - -TESTDIR=$(mktemp -p /test.dir -d) - -declare -A -g IMAGES -IMAGES+=(["alpine"]=docker.io/library/alpine:latest ["busybox"]=docker.io/library/busybox:latest) - -BB_GLIBC="docker.io/library/busybox:glibc" -BB="docker.io/library/busybox:latest" -ALPINE="docker.io/library/alpine:latest" -FEDORA_MINIMAL="registry.fedoraproject.org/fedora-minimal:latest" - -# podman pull needs a configuration file for shortname pulls -export REGISTRIES_CONFIG_PATH="$INTEGRATION_ROOT/registries.conf" - -# Setup default hooks dir -HOOKSDIR=$TESTDIR/hooks -mkdir ${HOOKSDIR} -HOOKS_OPTS="--hooks-dir-path=$HOOKSDIR" - -# Setup default secrets mounts -MOUNT_PATH="$TESTDIR/secrets" -mkdir ${MOUNT_PATH} -MOUNT_FILE="${MOUNT_PATH}/test.txt" -touch ${MOUNT_FILE}} -echo "Testing secrets mounts!" > ${MOUNT_FILE} - -DEFAULT_MOUNTS_OPTS="--default-mounts=${MOUNT_PATH}:/container/path1" - -# We may need to set some default storage options. -case "$(stat -f -c %T ${TESTDIR})" in - aufs) - # None of device mapper, overlay, or aufs can be used dependably over aufs, and of course btrfs and zfs can't, - # and we have to explicitly specify the "vfs" driver in order to use it, so do that now. - STORAGE_OPTIONS=${STORAGE_OPTIONS:---storage-driver vfs} - ;; -esac - -if [ -e /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then - . /etc/selinux/config - filelabel=$(awk -F'"' '/^file.*=.*/ {print $2}' /etc/selinux/${SELINUXTYPE}/contexts/lxc_contexts) - chcon -R ${filelabel} $TESTDIR -fi - -LIBPOD_CNI_CONFIG="$TESTDIR/etc/cni/net.d/" -LIBPOD_CNI_PLUGIN=${LIBPOD_CNI_PLUGIN:-/opt/cni/bin/} -POD_CIDR="10.88.0.0/16" -POD_CIDR_MASK="10.88.*.*" - -# Make sure the cni config dirs are created and populate them with the default configs -mkdir -p ${LIBPOD_CNI_CONFIG} -cp ${CRIO_ROOT}/cni/* ${LIBPOD_CNI_CONFIG} - -PODMAN_OPTIONS="--root $TESTDIR/crio $STORAGE_OPTIONS --runroot $TESTDIR/crio-run --runtime ${RUNTIME_BINARY} --conmon ${CONMON_BINARY} --cni-config-dir ${LIBPOD_CNI_CONFIG}" - -PATH=$PATH:$TESTDIR - -for key in ${!IMAGES[@]}; do - if ! [ -d "$ARTIFACTS_PATH"/${key} ]; then - mkdir -p "$ARTIFACTS_PATH"/${key} - if ! "$COPYIMG_BINARY" --import-from=docker://${IMAGES[${key}]} --export-to=dir:"$ARTIFACTS_PATH"/${key} --signature-policy="$INTEGRATION_ROOT"/policy.json ; then - echo "Error pulling docker://${IMAGES[${key}]}" - rm -fr "$ARTIFACTS_PATH"/${key} - exit 1 - fi - fi - -done - -### -# Buildah related variables -### -BUILDAH_BINARY=${BUILDAH_BINARY:-$(dirname ${BASH_SOURCE})/../buildah} -BUILDAH_IMGTYPE_BINARY=${BUILDAH_IMGTYPE_BINARY:-$(dirname ${BASH_SOURCE})/../imgtype} -BUILDAH_TESTSDIR=${BUILDAH_TESTSDIR:-$(dirname ${BASH_SOURCE})} -BUILDAH_STORAGE_DRIVER=${BUILDAH_STORAGE_DRIVER:-vfs} -#BUILDAH_PATH=$(dirname ${BASH_SOURCE})/..:${BUILDAH_PATH} - -# Make sure we have a copy of the redis:alpine image. -if ! [ -d "$ARTIFACTS_PATH"/redis-image ]; then - mkdir -p "$ARTIFACTS_PATH"/redis-image - if ! "$COPYIMG_BINARY" --import-from=docker://redis:alpine --export-to=dir:"$ARTIFACTS_PATH"/redis-image --signature-policy="$INTEGRATION_ROOT"/policy.json ; then - echo "Error pulling docker://redis" - rm -fr "$ARTIFACTS_PATH"/redis-image - exit 1 - fi -fi - -# TODO: remove the code below for pulling redis:alpine using a canonical reference once -# https://github.com/kubernetes-incubator/cri-o/issues/531 is complete and we can -# pull the image using a tagged reference and then subsequently find the image without -# having to explicitly record the canonical reference as one of the image's names -if ! [ -d "$ARTIFACTS_PATH"/redis-image-digest ]; then - mkdir -p "$ARTIFACTS_PATH"/redis-image-digest - if ! "$COPYIMG_BINARY" --import-from=docker://redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b --export-to=dir:"$ARTIFACTS_PATH"/redis-image-digest --signature-policy="$INTEGRATION_ROOT"/policy.json ; then - echo "Error pulling docker://redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b" - rm -fr "$ARTIFACTS_PATH"/redis-image-digest - exit 1 - fi -fi - -# Make sure we have a copy of the runcom/stderr-test image. -if ! [ -d "$ARTIFACTS_PATH"/stderr-test ]; then - mkdir -p "$ARTIFACTS_PATH"/stderr-test - if ! "$COPYIMG_BINARY" --import-from=docker://runcom/stderr-test:latest --export-to=dir:"$ARTIFACTS_PATH"/stderr-test --signature-policy="$INTEGRATION_ROOT"/policy.json ; then - echo "Error pulling docker://stderr-test" - rm -fr "$ARTIFACTS_PATH"/stderr-test - exit 1 - fi -fi - -# Make sure we have a copy of the busybox:latest image. -if ! [ -d "$ARTIFACTS_PATH"/busybox-image ]; then - mkdir -p "$ARTIFACTS_PATH"/busybox-image - if ! "$COPYIMG_BINARY" --import-from=docker://busybox --export-to=dir:"$ARTIFACTS_PATH"/busybox-image --signature-policy="$INTEGRATION_ROOT"/policy.json ; then - echo "Error pulling docker://busybox" - rm -fr "$ARTIFACTS_PATH"/busybox-image - exit 1 - fi -fi - -# Communicate with Docker on the host machine. -# Should rarely use this. -function docker_host() { - command docker "$@" -} - -# Retry a command $1 times until it succeeds. Wait $2 seconds between retries. -function retry() { - local attempts=$1 - shift - local delay=$1 - shift - local i - - for ((i=0; i < attempts; i++)); do - run "$@" - if [[ "$status" -eq 0 ]] ; then - return 0 - fi - sleep $delay - done - - echo "Command \"$@\" failed $attempts times. Output: $output" - false -} - -# Waits until the given crio becomes reachable. -function wait_until_reachable() { - retry 15 1 crictl status -} - -function cleanup_test() { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} rm --force --all" - echo "$output" - rm -rf "$TESTDIR" -} - - -function load_apparmor_profile() { - "$APPARMOR_PARSER_BINARY" -r "$1" -} - -function remove_apparmor_profile() { - "$APPARMOR_PARSER_BINARY" -R "$1" -} - -function is_seccomp_enabled() { - if ! "$CHECKSECCOMP_BINARY" ; then - echo 0 - return - fi - echo 1 -} - -function is_apparmor_enabled() { - if [[ -f "$APPARMOR_PARAMETERS_FILE_PATH" ]]; then - out=$(cat "$APPARMOR_PARAMETERS_FILE_PATH") - if [[ "$out" =~ "Y" ]]; then - echo 1 - return - fi - fi - echo 0 -} - -function check_pod_cidr() { - run crioctl ctr execsync --id $1 ip addr show dev eth0 scope global 2>&1 - echo "$output" - [ "$status" -eq 0 ] - [[ "$output" =~ $POD_CIDR_MASK ]] -} - -function parse_pod_ip() { - for arg - do - cidr=`echo "$arg" | grep $POD_CIDR_MASK` - if [ "$cidr" == "$arg" ] - then - echo `echo "$arg" | sed "s/\/[0-9][0-9]//"` - fi - done -} - -function get_host_ip() { - gateway_dev=`ip -o route show default 0.0.0.0/0 | sed 's/.*dev \([^[:space:]]*\).*/\1/'` - [ "$gateway_dev" ] - host_ip=`ip -o -4 addr show dev $gateway_dev scope global | sed 's/.*inet \([0-9.]*\).*/\1/'` -} - -function ping_pod() { - inet=`crioctl ctr execsync --id $1 ip addr show dev eth0 scope global 2>&1 | grep inet` - - IFS=" " - ip=`parse_pod_ip $inet` - - ping -W 1 -c 5 $ip - - echo $? -} - -function ping_pod_from_pod() { - inet=`crioctl ctr execsync --id $1 ip addr show dev eth0 scope global 2>&1 | grep inet` - - IFS=" " - ip=`parse_pod_ip $inet` - - run crioctl ctr execsync --id $2 ping -W 1 -c 2 $ip - echo "$output" - [ "$status" -eq 0 ] -} - - -function cleanup_network_conf() { - rm -rf $LIBPOD_CNI_CONFIG - - echo 0 -} - -function temp_sandbox_conf() { - sed -e s/\"namespace\":.*/\"namespace\":\ \"$1\",/g "$TESTDATA"/sandbox_config.json > $TESTDIR/sandbox_config_$1.json -} - -function copy_images() { - for key in ${!IMAGES[@]}; do - "$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTIONS --runroot "$TESTDIR/crio-run" --image-name=${IMAGES[${key}]} --import-from=dir:"$ARTIFACTS_PATH"/${key} --add-name=${IMAGES[${key}]} - done -} - -### -# Buildah Functions -### -function setup() { - suffix=$(dd if=/dev/urandom bs=12 count=1 status=none | base64 | tr +/ABCDEFGHIJKLMNOPQRSTUVWXYZ _.abcdefghijklmnopqrstuvwxyz) - TESTDIR=${BATS_TMPDIR}/tmp.${suffix} - rm -fr ${TESTDIR} - mkdir -p ${TESTDIR}/{root,runroot} -} - -function starthttpd() { - pushd ${2:-${TESTDIR}} > /dev/null - cp ${BUILDAH_TESTSDIR}/serve.go . - go build serve.go - HTTP_SERVER_PORT=$((RANDOM+32768)) - ./serve ${HTTP_SERVER_PORT} ${1:-${BATS_TMPDIR}} & - HTTP_SERVER_PID=$! - popd > /dev/null -} - -function stophttpd() { - if test -n "$HTTP_SERVER_PID" ; then - kill -HUP ${HTTP_SERVER_PID} - unset HTTP_SERVER_PID - unset HTTP_SERVER_PORT - fi - true -} - -function teardown() { - stophttpd - rm -fr ${TESTDIR} -} - -function createrandom() { - dd if=/dev/urandom bs=1 count=${2:-256} of=${1:-${BATS_TMPDIR}/randomfile} status=none -} - -function buildah() { - ${BUILDAH_BINARY} --debug --root ${TESTDIR}/root --runroot ${TESTDIR}/runroot --storage-driver ${BUILDAH_STORAGE_DRIVER} "$@" -} - -function imgtype() { - ${BUILDAH_IMGTYPE_BINARY} -root ${TESTDIR}/root -runroot ${TESTDIR}/runroot -storage-driver ${BUILDAH_STORAGE_DRIVER} "$@" -} diff --git a/test/podman_build.bats b/test/podman_build.bats deleted file mode 100644 index 91bb573f8..000000000 --- a/test/podman_build.bats +++ /dev/null @@ -1,265 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -@test "build-from-scratch" { - if ! which buildah ; then - skip "Buildah not installed" - fi - target=scratch-image - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} ${BUILDAH_TESTSDIR}/build/from-scratch - cid=$(buildah from ${target}) - podman rm ${cid} - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$output" = "" ] - [ "$status" -eq 0 ] -} - -@test "build-from-multiple-files-one-from" { - if ! which buildah ; then - skip "Buildah not installed" - fi - target=scratch-image - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.scratch -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.nofrom - cid=$(buildah from ${target}) - root=$(buildah mount ${cid}) - cmp $root/Dockerfile1 ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.scratch - cmp $root/Dockerfile2.nofrom ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.nofrom - run test -s $root/etc/passwd - [ "$status" -ne 0 ] - podman rm ${cid} - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$status" -eq 0 ] - [ "$output" = "" ] - - target=alpine-image - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.alpine -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.nofrom - cid=$(buildah from ${target}) - root=$(buildah mount ${cid}) - cmp $root/Dockerfile1 ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.alpine - cmp $root/Dockerfile2.nofrom ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.nofrom - run test -s $root/etc/passwd - [ "$status" -eq 0 ] - podman rm ${cid} - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$status" -eq 0 ] - [ "$output" = "" ] -} - -@test "build-from-multiple-files-two-froms" { - if ! which buildah ; then - skip "Buildah not installed" - fi - target=scratch-image - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.scratch -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.withfrom - cid=$(buildah from ${target}) - root=$(buildah mount ${cid}) - cmp $root/Dockerfile1 ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.scratch - cmp $root/Dockerfile2.withfrom ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.withfrom - run test -s $root/etc/passwd - [ "$status" -ne 0 ] - podman rm ${cid} - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$status" -eq 0 ] - [ "$output" = "" ] - - target=alpine-image - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.alpine -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.withfrom - cid=$(buildah from ${target}) - root=$(buildah mount ${cid}) - cmp $root/Dockerfile1 ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.alpine - cmp $root/Dockerfile2.withfrom ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.withfrom - run test -s $root/etc/passwd - [ "$status" -eq 0 ] - podman rm ${cid} - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$status" -eq 0 ] - [ "$output" = "" ] -} - -@test "build-preserve-subvolumes" { - if ! which buildah ; then - skip "Buildah not installed" - fi - # This Dockerfile needs us to be able to handle a working RUN instruction. - if ! which runc ; then - skip - fi - target=volume-image - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} ${BUILDAH_TESTSDIR}/build/preserve-volumes - cid=$(buildah from ${target}) - root=$(buildah mount ${cid}) - test -s $root/vol/subvol/subsubvol/subsubvolfile - run test -s $root/vol/subvol/subvolfile - [ "$status" -ne 0 ] - test -s $root/vol/volfile - test -s $root/vol/Dockerfile - test -s $root/vol/Dockerfile2 - run test -s $root/vol/anothervolfile - [ "$status" -ne 0 ] - podman rm ${cid} - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$output" = "" ] -} - -@test "build-http-Dockerfile" { - if ! which buildah ; then - skip "Buildah not installed" - fi - starthttpd ${BUILDAH_TESTSDIR}/build/from-scratch - target=scratch-image - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f http://0.0.0.0:${HTTP_SERVER_PORT}/Dockerfile . - stophttpd - cid=$(buildah from ${target}) - podman rm ${cid} - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$output" = "" ] -} - -@test "build-http-context-with-Dockerfile" { - if ! which buildah ; then - skip "Buildah not installed" - fi - starthttpd ${BUILDAH_TESTSDIR}/build/http-context - target=scratch-image - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} http://0.0.0.0:${HTTP_SERVER_PORT}/context.tar - stophttpd - cid=$(buildah from ${target}) - podman rm ${cid} - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$output" = "" ] -} - -@test "build-http-context-dir-with-Dockerfile-pre" { - if ! which buildah ; then - skip "Buildah not installed" - fi - starthttpd ${BUILDAH_TESTSDIR}/build/http-context-subdir - target=scratch-image - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f context/Dockerfile http://0.0.0.0:${HTTP_SERVER_PORT}/context.tar - stophttpd - cid=$(buildah from ${target}) - podman rm ${cid} - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$output" = "" ] -} - -@test "build-http-context-dir-with-Dockerfile-post" { - if ! which buildah ; then - skip "Buildah not installed" - fi - starthttpd ${BUILDAH_TESTSDIR}/build/http-context-subdir - target=scratch-image - podman build http://0.0.0.0:${HTTP_SERVER_PORT}/context.tar --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f context/Dockerfile - stophttpd - cid=$(buildah from ${target}) - podman rm ${cid} - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$output" = "" ] -} - -@test "build-git-context" { - if ! which buildah ; then - skip "Buildah not installed" - fi - # We need git and ssh to be around to handle cloning a repository. - if ! which git ; then - skip - fi - if ! which ssh ; then - skip - fi - target=giturl-image - # Any repo should do, but this one is small and is FROM: scratch. - gitrepo=git://github.com/projectatomic/nulecule-library - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} "${gitrepo}" - cid=$(buildah from ${target}) - podman rm ${cid} - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$output" = "" ] -} - -@test "build-github-context" { - if ! which buildah ; then - skip "Buildah not installed" - fi - target=github-image - # Any repo should do, but this one is small and is FROM: scratch. - gitrepo=github.com/projectatomic/nulecule-library - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} "${gitrepo}" - cid=$(buildah from ${target}) - podman rm ${cid} - buildah --debug=false images -q - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$output" = "" ] -} - -@test "build-additional-tags" { - if ! which buildah ; then - skip "Buildah not installed" - fi - target=scratch-image - target2=another-scratch-image - target3=so-many-scratch-images - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -t ${target2} -t ${target3} ${BUILDAH_TESTSDIR}/build/from-scratch - run buildah --debug=false images - cid=$(buildah from ${target}) - podman rm ${cid} - cid=$(buildah from library/${target2}) - podman rm ${cid} - cid=$(buildah from ${target3}:latest) - podman rm ${cid} - podman rmi -f $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$output" = "" ] -} - -@test "build-volume-perms" { - if ! which buildah ; then - skip "Buildah not installed" - fi - # This Dockerfile needs us to be able to handle a working RUN instruction. - if ! which runc ; then - skip - fi - target=volume-image - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} ${BUILDAH_TESTSDIR}/build/volume-perms - cid=$(buildah from ${target}) - root=$(buildah mount ${cid}) - run test -s $root/vol/subvol/subvolfile - [ "$status" -ne 0 ] - run stat -c %f $root/vol/subvol - [ "$output" = 41ed ] - podman rm ${cid} - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$output" = "" ] -} - -@test "build-from-glob" { - if ! which buildah ; then - skip "Buildah not installed" - fi - target=alpine-image - podman build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f Dockerfile2.glob ${BUILDAH_TESTSDIR}/build/from-multiple-files - cid=$(buildah from ${target}) - root=$(buildah mount ${cid}) - cmp $root/Dockerfile1.alpine ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.alpine - cmp $root/Dockerfile2.withfrom ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.withfrom - podman rm ${cid} - podman rmi $(buildah --debug=false images -q) - run buildah --debug=false images -q - [ "$output" = "" ] -} diff --git a/test/podman_load.bats b/test/podman_load.bats deleted file mode 100644 index ca93a5522..000000000 --- a/test/podman_load.bats +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function setup() { - copy_images -} - -function teardown() { - cleanup_test -} -@test "podman load input flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save -o alpine.tar $ALPINE - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi $ALPINE - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} load -i alpine.tar - echo "$output" - [ "$status" -eq 0 ] - rm -f alpine.tar -} - -@test "podman load oci-archive image" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save -o alpine.tar --format oci-archive $ALPINE - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi $ALPINE - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} load -i alpine.tar - echo "$output" - [ "$status" -eq 0 ] - rm -f alpine.tar -} - -@test "podman load oci-archive image with signature-policy" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save -o alpine.tar --format oci-archive $ALPINE - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi $ALPINE - [ "$status" -eq 0 ] - cp /etc/containers/policy.json /tmp - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} load --signature-policy /tmp/policy.json -i alpine.tar - echo "$output" - [ "$status" -eq 0 ] - rm -f /tmp/policy.json - rm -f alpine.tar -} - -@test "podman load using quiet flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save -o alpine.tar $ALPINE - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi $ALPINE - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} load -q -i alpine.tar - echo "$output" - [ "$status" -eq 0 ] - rm -f alpine.tar -} - -@test "podman load directory" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save --format oci-dir -o alp-dir $ALPINE - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi $ALPINE - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} load -i alp-dir - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi alp-dir - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman load non-existent file" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} load -i alpine.tar - echo "$output" - [ "$status" -ne 0 ] -} diff --git a/test/podman_mount.bats b/test/podman_mount.bats deleted file mode 100644 index f3d04fb98..000000000 --- a/test/podman_mount.bats +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -IMAGE="redis:alpine" - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "mount" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} create $BB ls - echo "$output" - [ "$status" -eq 0 ] - ctr_id="$output" - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} mount $ctr_id - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} mount --notruncate | grep $ctr_id" - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} unmount $ctr_id - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} mount $ctr_id - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} mount --format=json | python -m json.tool | grep $ctr_id" - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} unmount $ctr_id - echo "$output" - [ "$status" -eq 0 ] -} diff --git a/test/podman_pause.bats b/test/podman_pause.bats deleted file mode 100644 index 4e98eb130..000000000 --- a/test/podman_pause.bats +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function setup() { - copy_images -} - -function teardown() { - cleanup_test -} - -@test "pause a bogus container" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pause foobar - echo "$output" - [ "$status" -eq 125 ] -} - -@test "unpause a bogus container" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} unpause foobar - echo "$output" - [ "$status" -eq 125 ] -} - -@test "pause a created container by id" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $BB sleep 60 - echo "$output" - [ "$status" -eq 0 ] - ctr_id=`echo "$output" | tail -n 1` - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pause $ctr_id - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} unpause $ctr_id - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rm -f $ctr_id - echo "$output" - [ "$status" -eq 0 ] -} - -@test "pause a running container by id" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $BB sleep 60 - echo "$output" - [ "$status" -eq 0 ] - ctr_id=`echo "$output" | tail -n 1` - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pause $ctr_id - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} unpause $ctr_id - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rm -f $ctr_id - echo "$output" - [ "$status" -eq 0 ] -} - -@test "unpause a running container" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $BB sleep 60 - echo "$output" - [ "$status" -eq 0 ] - ctr_id=`echo "$output" | tail -n 1` - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} unpause $ctr_id - echo "$output" - [ "$status" -eq 125 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rm -f $ctr_id - echo "$output" - [ "$status" -eq 0 ] -} - -@test "remove a paused container by id" { - skip "Test needs to wait for --force to work for podman rm" - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $BB sleep 60 - echo "$output" - [ "$status" -eq 0 ] - ctr_id=`echo "$output" | tail -n 1` - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pause $ctr_id - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rm $ctr_id - echo "$output" - [ "$status" -eq 125 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rm --force $ctr_id - echo "$output" - [ "$status" -eq 0 ] -} - -@test "stop a paused container created by id" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $BB sleep 60 - echo "$output" - [ "$status" -eq 0 ] - ctr_id=`echo "$output" | tail -n 1` - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pause $ctr_id - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} stop $ctr_id - echo "$output" - [ "$status" -eq 125 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} unpause $ctr_id - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a --filter id=$ctr_id - echo "$output" - [ "$status" -eq 0 ] - # Container should be running after unpause and shouldn't - # be removable without the force flag. - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rm $ctr_id - echo "$output" - [ "$status" -eq 125 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rm -f $ctr_id - echo "$output" - [ "$status" -eq 0 ] -} diff --git a/test/podman_port.bats b/test/podman_port.bats deleted file mode 100644 index d13227b3c..000000000 --- a/test/podman_port.bats +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "podman port all and latest" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} port -a -l - echo "$output" - echo "$status" - [ "$status" -ne 0 ] -} - -@test "podman port all and extra" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} port -a foobar - echo "$output" - echo "$status" - [ "$status" -ne 0 ] -} - -@test "podman port nginx" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -dt -P docker.io/library/nginx:latest - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} port -l - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} port -l 80 - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} port -l 80/tcp - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} port -a - echo "$output" - [ "$status" -eq 0 ] -} diff --git a/test/podman_search.bats b/test/podman_search.bats deleted file mode 100644 index 07621d722..000000000 --- a/test/podman_search.bats +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -@test "podman search" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} search alpine - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman search registry flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} search --registry registry.fedoraproject.org fedora - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman search filter flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} search --filter=is-official alpine - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman search format flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} search --format "table {{.Index}} {{.Name}}" alpine - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman search no-trunc flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} search --no-trunc alpine - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman search limit flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} search --limit 3 alpine - echo "$output" - [ "$status" -eq 0 ] -}
\ No newline at end of file diff --git a/test/test_runner.sh b/test/test_runner.sh deleted file mode 100755 index c97d8d0f7..000000000 --- a/test/test_runner.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -set -e - -cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" - -# Load the helpers. -. helpers.bash - -function execute() { - >&2 echo "++ $@" - eval "$@" -} - -# Tests to run. Defaults to all. -if [[ -z "${TESTS}" ]]; then - TESTS=${@:-.} -else - TESTS=$TESTS -fi - -# Run the tests. -execute time bats --tap $TESTS |