summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/apiv2/10-images.at35
-rw-r--r--test/apiv2/python/rest_api/test_v2_0_0_image.py6
-rwxr-xr-xtest/compose/test-compose2
-rw-r--r--test/e2e/build_test.go34
-rw-r--r--test/e2e/run_volume_test.go32
-rw-r--r--test/e2e/systemd_test.go7
-rw-r--r--test/system/070-build.bats49
-rw-r--r--test/system/410-selinux.bats5
-rwxr-xr-xtest/system/build-testimage65
-rw-r--r--test/system/helpers.bash9
10 files changed, 214 insertions, 30 deletions
diff --git a/test/apiv2/10-images.at b/test/apiv2/10-images.at
index 037a4c01f..9e464dbc7 100644
--- a/test/apiv2/10-images.at
+++ b/test/apiv2/10-images.at
@@ -147,4 +147,39 @@ t GET "images/get?names=alpine&names=busybox" 200 '[POSIX tar archive]'
img_cnt=$(tar xf "$WORKDIR/curl.result.out" manifest.json -O | jq "length")
is "$img_cnt" 2 "number of images in tar archive"
+# check build works when uploading container file as a tar, see issue #10660
+TMPD=$(mktemp -d podman-apiv2-test.build.XXXXXXXX)
+function cleanBuildTest() {
+ podman rmi -a -f
+ rm -rf "${TMPD}" &> /dev/null
+}
+CONTAINERFILE_TAR="${TMPD}/containerfile.tar"
+cat > $TMPD/containerfile << EOF
+FROM quay.io/libpod/alpine_labels:latest
+EOF
+tar --format=posix -C $TMPD -cvf ${CONTAINERFILE_TAR} containerfile &> /dev/null
+
+curl -XPOST --data-binary @<(cat $CONTAINERFILE_TAR) \
+ -H "content-type: application/x-tar" \
+ --dump-header "${TMPD}/headers.txt" \
+ -o "${TMPD}/response.txt" \
+ "http://$HOST:$PORT/v1.40/libpod/build?dockerfile=containerfile" &> /dev/null
+
+BUILD_TEST_ERROR=""
+
+if ! grep -q '200 OK' "${TMPD}/headers.txt"; then
+ echo -e "${red}NOK: Image build from tar failed response was not 200 OK"
+ BUILD_TEST_ERROR="1"
+fi
+
+if ! grep -q 'quay.io/libpod/alpine_labels' "${TMPD}/response.txt"; then
+ echo -e "${red}NOK: Image build from tar failed image name not in response"
+ BUILD_TEST_ERROR="1"
+fi
+
+cleanBuildTest
+if [[ "${BUILD_TEST_ERROR}" ]]; then
+ exit 1
+fi
+
# vim: filetype=sh
diff --git a/test/apiv2/python/rest_api/test_v2_0_0_image.py b/test/apiv2/python/rest_api/test_v2_0_0_image.py
index 2cd7bfa96..59dcea87f 100644
--- a/test/apiv2/python/rest_api/test_v2_0_0_image.py
+++ b/test/apiv2/python/rest_api/test_v2_0_0_image.py
@@ -86,10 +86,12 @@ class ImageTestCase(APITestCase):
self.assertTrue(keys["id"], "Expected to find id stanza")
self.assertTrue(keys["images"], "Expected to find images stanza")
self.assertTrue(keys["stream"], "Expected to find stream progress stanza's")
+
def test_create(self):
- r = requests.post(self.podman_url + "/v1.40/images/create?fromImage=alpine&platform=linux/amd64/v8", timeout=15)
+ r = requests.post(
+ self.podman_url + "/v1.40/images/create?fromImage=alpine&platform=linux/amd64/v8", timeout=15)
self.assertEqual(r.status_code, 200, r.text)
- r = requests.post(self.podman_url + "/v1.40/images/create?fromSrc=-&repo=fedora&message=testing123", timeout=15)
+ r = requests.post(self.podman_url + "/v1.40/images/create?fromSrc=-&repo=fedora&message=testing123&platform=linux/amd64", timeout=15)
self.assertEqual(r.status_code, 200, r.text)
def test_search_compat(self):
diff --git a/test/compose/test-compose b/test/compose/test-compose
index 981f78a79..70db6dd55 100755
--- a/test/compose/test-compose
+++ b/test/compose/test-compose
@@ -183,6 +183,8 @@ function test_port() {
fi
echo "# cat $WORKDIR/server.log:"
cat $WORKDIR/server.log
+ echo "# cat $logfile:"
+ cat $logfile
return
fi
diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go
index 6255690b1..abaacdd5e 100644
--- a/test/e2e/build_test.go
+++ b/test/e2e/build_test.go
@@ -604,4 +604,38 @@ RUN echo hello`, ALPINE)
Expect(inspect.OutputToString()).To(Equal("windows"))
})
+
+ It("podman build device test", func() {
+ if _, err := os.Lstat("/dev/fuse"); err != nil {
+ Skip(fmt.Sprintf("test requires stat /dev/fuse to work: %v", err))
+ }
+ containerfile := fmt.Sprintf(`FROM %s
+RUN ls /dev/fuse`, ALPINE)
+ containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile")
+ err := ioutil.WriteFile(containerfilePath, []byte(containerfile), 0755)
+ Expect(err).To(BeNil())
+ session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--file", containerfilePath, podmanTest.TempDir})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(125))
+
+ session = podmanTest.Podman([]string{"build", "--pull-never", "--device", "/dev/fuse", "-t", "test", "--file", containerfilePath, podmanTest.TempDir})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ })
+
+ It("podman build device rename test", func() {
+ SkipIfRootless("rootless builds do not currently support renaming devices")
+ containerfile := fmt.Sprintf(`FROM %s
+RUN ls /dev/test1`, ALPINE)
+ containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile")
+ err := ioutil.WriteFile(containerfilePath, []byte(containerfile), 0755)
+ Expect(err).To(BeNil())
+ session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--file", containerfilePath, podmanTest.TempDir})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(125))
+
+ session = podmanTest.Podman([]string{"build", "--pull-never", "--device", "/dev/zero:/dev/test1", "-t", "test", "--file", containerfilePath, podmanTest.TempDir})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ })
})
diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go
index 9b77aaef8..4be1b2009 100644
--- a/test/e2e/run_volume_test.go
+++ b/test/e2e/run_volume_test.go
@@ -668,4 +668,36 @@ USER testuser`, fedoraMinimal)
Expect(strings.Contains(test2.OutputToString(), testString)).To(BeTrue())
})
+
+ It("podman volume with uid and gid works", func() {
+ volName := "testVol"
+ volCreate := podmanTest.Podman([]string{"volume", "create", "--opt", "o=uid=1000", volName})
+ volCreate.WaitWithDefaultTimeout()
+ Expect(volCreate.ExitCode()).To(Equal(0))
+
+ volMount := podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/test", volName), ALPINE, "stat", "-c", "%u", "/test"})
+ volMount.WaitWithDefaultTimeout()
+ Expect(volMount.ExitCode()).To(Equal(0))
+ Expect(volMount.OutputToString()).To(Equal("1000"))
+
+ volName = "testVol2"
+ volCreate = podmanTest.Podman([]string{"volume", "create", "--opt", "o=gid=1000", volName})
+ volCreate.WaitWithDefaultTimeout()
+ Expect(volCreate.ExitCode()).To(Equal(0))
+
+ volMount = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/test", volName), ALPINE, "stat", "-c", "%g", "/test"})
+ volMount.WaitWithDefaultTimeout()
+ Expect(volMount.ExitCode()).To(Equal(0))
+ Expect(volMount.OutputToString()).To(Equal("1000"))
+
+ volName = "testVol3"
+ volCreate = podmanTest.Podman([]string{"volume", "create", "--opt", "o=uid=1000,gid=1000", volName})
+ volCreate.WaitWithDefaultTimeout()
+ Expect(volCreate.ExitCode()).To(Equal(0))
+
+ volMount = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/test", volName), ALPINE, "stat", "-c", "%u:%g", "/test"})
+ volMount.WaitWithDefaultTimeout()
+ Expect(volMount.ExitCode()).To(Equal(0))
+ Expect(volMount.OutputToString()).To(Equal("1000:1000"))
+ })
})
diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go
index b132750b0..8dc14d5f7 100644
--- a/test/e2e/systemd_test.go
+++ b/test/e2e/systemd_test.go
@@ -6,6 +6,7 @@ import (
"strings"
"time"
+ "github.com/containers/podman/v3/pkg/rootless"
. "github.com/containers/podman/v3/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -115,6 +116,12 @@ WantedBy=multi-user.target
conData := result.InspectContainerToJSON()
Expect(len(conData)).To(Equal(1))
Expect(conData[0].Config.SystemdMode).To(BeTrue())
+
+ if CGROUPSV2 || !rootless.IsRootless() {
+ stats := podmanTest.Podman([]string{"stats", "--no-stream", ctrName})
+ stats.WaitWithDefaultTimeout()
+ Expect(stats.ExitCode()).To(Equal(0))
+ }
})
It("podman create container with systemd entrypoint triggers systemd mode", func() {
diff --git a/test/system/070-build.bats b/test/system/070-build.bats
index 0f3f3fa7f..6843e28a5 100644
--- a/test/system/070-build.bats
+++ b/test/system/070-build.bats
@@ -29,6 +29,29 @@ EOF
run_podman rmi -f build_test
}
+@test "podman build test -f -" {
+ rand_filename=$(random_string 20)
+ rand_content=$(random_string 50)
+
+ tmpdir=$PODMAN_TMPDIR/build-test
+ mkdir -p $tmpdir
+ containerfile=$PODMAN_TMPDIR/Containerfile
+ cat >$containerfile <<EOF
+FROM $IMAGE
+RUN apk add nginx
+RUN echo $rand_content > /$rand_filename
+EOF
+
+ # The 'apk' command can take a long time to fetch files; bump timeout
+ PODMAN_TIMEOUT=240 run_podman build -t build_test -f - --format=docker $tmpdir < $containerfile
+ is "$output" ".*STEP 4: COMMIT" "COMMIT seen in log"
+
+ run_podman run --rm build_test cat /$rand_filename
+ is "$output" "$rand_content" "reading generated file in image"
+
+ run_podman rmi -f build_test
+}
+
@test "podman build - global runtime flags test" {
skip_if_remote "--runtime-flag flag not supported for remote"
@@ -794,6 +817,32 @@ EOF
run_podman rmi -f build_test
}
+@test "podman build -f test " {
+ tmpdir=$PODMAN_TMPDIR/build-test
+ subdir=$tmpdir/subdir
+ mkdir -p $subdir
+
+ containerfile1=$tmpdir/Containerfile1
+ cat >$containerfile1 <<EOF
+FROM scratch
+copy . /tmp
+EOF
+ containerfile2=$PODMAN_TMPDIR/Containerfile2
+ cat >$containerfile2 <<EOF
+FROM $IMAGE
+EOF
+ run_podman build -t build_test -f Containerfile1 $tmpdir
+ run_podman 125 build -t build_test -f Containerfile2 $tmpdir
+ is "$output" ".*Containerfile2: no such file or directory" "Containerfile2 should not exist"
+ run_podman build -t build_test -f $containerfile1 $tmpdir
+ run_podman build -t build_test -f $containerfile2 $tmpdir
+ run_podman build -t build_test -f $containerfile1
+ run_podman build -t build_test -f $containerfile2
+ run_podman build -t build_test -f $containerfile1 -f $containerfile2 $tmpdir
+ is "$output" ".*$IMAGE" "Containerfile2 is also passed to server"
+ run_podman rmi -f build_test
+}
+
function teardown() {
# A timeout or other error in 'build' can leave behind stale images
# that podman can't even see and which will cascade into subsequent
diff --git a/test/system/410-selinux.bats b/test/system/410-selinux.bats
index f8cee0e59..4ef9c8b30 100644
--- a/test/system/410-selinux.bats
+++ b/test/system/410-selinux.bats
@@ -183,7 +183,10 @@ function check_label() {
# runc and crun emit different diagnostics
runtime=$(podman_runtime)
case "$runtime" in
- crun) expect="\`/proc/thread-self/attr/exec\`: OCI runtime error: unable to assign security attribute" ;;
+ # crun 0.20.1 changes the error message
+ # from /proc/thread-self/attr/exec`: .* unable to assign
+ # to /proc/self/attr/keycreate`: .* unable to process
+ crun) expect="\`/proc/.*\`: OCI runtime error: unable to \(assign\|process\) security attribute" ;;
runc) expect="OCI runtime error: .*: failed to set /proc/self/attr/keycreate on procfs" ;;
*) skip "Unknown runtime '$runtime'";;
esac
diff --git a/test/system/build-testimage b/test/system/build-testimage
index 3e5b982ce..eb5849b5e 100755
--- a/test/system/build-testimage
+++ b/test/system/build-testimage
@@ -61,8 +61,8 @@ chmod 755 pause
# - check for updates @ https://hub.docker.com/_/alpine
# busybox-extras provides httpd needed in 500-networking.bats
cat >Containerfile <<EOF
-ARG ARCH=please-override-arch
-FROM docker.io/\${ARCH}/alpine:3.12.0
+ARG REPO=please-override-repo
+FROM docker.io/\${REPO}/alpine:3.13.5
RUN apk add busybox-extras
ADD testimage-id pause /home/podman/
LABEL created_by=$create_script
@@ -74,17 +74,46 @@ EOF
# --squash-all : needed by 'tree' test in 070-build.bats
podman rmi -f testimage &> /dev/null || true
+# There should always be a testimage tagged ':0000000<X>' (eight digits,
+# zero-padded sequence ID) in the same location; this is used by tests
+# which need to pull a non-locally-cached image. This image will rarely
+# if ever need to change, nor in fact does it even have to be a copy of
+# this testimage since all we use it for is 'true'.
+# However, it does need to be multiarch :-(
+zerotag_latest=$(skopeo list-tags docker://quay.io/libpod/testimage |\
+ jq -r '.Tags[]' |\
+ sort --version-sort |\
+ grep '^000' |\
+ tail -n 1)
+zerotag_next=$(printf "%08d" $((zerotag_latest + 1)))
+
+# We don't always need to push the :00xx image, but build it anyway.
+zeroimg=quay.io/libpod/testimage:${zerotag_next}
+buildah manifest create $zeroimg
+
# We need to use buildah because (as of 2021-02-23) only buildah has --manifest
# and because Dan says arch emulation is not currently working on podman
# (no further details).
# Arch emulation on Fedora requires the qemu-user-static package.
-for arch in amd64 arm64v8 ppc64le s390x;do
+for arch in amd64 arm64 ppc64le s390x;do
+ # docker.io repo is usually the same name as the desired arch; except
+ # for arm64, where podman needs to have the arch be 'arm64' but the
+ # image lives in 'arm64v8'.
+ repo=$arch
+ if [[ $repo = "arm64" ]]; then
+ repo="${repo}v8"
+ fi
+
${BUILDAH} bud \
--arch=$arch \
- --build-arg ARCH=$arch \
+ --build-arg REPO=$repo \
--manifest=testimage \
--squash \
.
+
+ # The zero-tag image
+ ${BUILDAH} pull --arch $arch docker.io/$repo/busybox:1.33.1
+ ${BUILDAH} manifest add $zeroimg docker.io/$repo/busybox:1.33.1
done
# Clean up
@@ -94,23 +123,13 @@ rm -rf $tmpdir
# Tag image and push (all arches) to quay.
remote_tag=quay.io/libpod/testimage:$YMD
podman tag testimage ${remote_tag}
-${BUILDAH} manifest push --all ${remote_tag} docker://${remote_tag}
+cat <<EOF
-# Side note: there should always be a testimage tagged ':0000000<X>'
-# (eight digits, zero-padded sequence ID) in the same location; this is
-# used by tests which need to pull a non-locally-cached image. This
-# image will rarely if ever need to change, nor in fact does it even
-# have to be a copy of this testimage since all we use it for is 'true'.
-# However, it does need to be multiarch :-(
-#
-# As of 2021-02-24 it is simply busybox, because it is super small,
-# but it's complicated because of multiarch:
-#
-# img=quay.io/libpod/testimage:0000000<current+1>
-# buildah manifest create $img
-# for arch in amd64 arm64v8 ppc64le s390x;do
-# buildah pull --arch $arch docker.io/$arch/busybox:1.32.0
-# buildah manifest add $img docker.io/$arch/busybox:1.32.0
-# done
-# buildah manifest push --all $img docker://$img
-#
+If you're happy with these images, run:
+
+ ${BUILDAH} manifest push --all ${remote_tag} docker://${remote_tag}
+ ${BUILDAH} manifest push --all ${zeroimg} docker://${zeroimg}
+
+(You do not always need to push the :0000 image)
+
+EOF
diff --git a/test/system/helpers.bash b/test/system/helpers.bash
index e0c208f57..1859a2168 100644
--- a/test/system/helpers.bash
+++ b/test/system/helpers.bash
@@ -7,14 +7,15 @@ PODMAN=${PODMAN:-podman}
PODMAN_TEST_IMAGE_REGISTRY=${PODMAN_TEST_IMAGE_REGISTRY:-"quay.io"}
PODMAN_TEST_IMAGE_USER=${PODMAN_TEST_IMAGE_USER:-"libpod"}
PODMAN_TEST_IMAGE_NAME=${PODMAN_TEST_IMAGE_NAME:-"testimage"}
-PODMAN_TEST_IMAGE_TAG=${PODMAN_TEST_IMAGE_TAG:-"20210427"}
+PODMAN_TEST_IMAGE_TAG=${PODMAN_TEST_IMAGE_TAG:-"20210610"}
PODMAN_TEST_IMAGE_FQN="$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:$PODMAN_TEST_IMAGE_TAG"
PODMAN_TEST_IMAGE_ID=
# Remote image that we *DO NOT* fetch or keep by default; used for testing pull
-# This changed from 0 to 1 on 2021-02-24 due to multiarch considerations; it
-# should change only very rarely.
-PODMAN_NONLOCAL_IMAGE_FQN="$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:00000002"
+# This has changed in 2021, from 0 through 3, various iterations of getting
+# multiarch to work. It should change only very rarely.
+PODMAN_NONLOCAL_IMAGE_TAG=${PODMAN_NONLOCAL_IMAGE_TAG:-"00000003"}
+PODMAN_NONLOCAL_IMAGE_FQN="$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:$PODMAN_NONLOCAL_IMAGE_TAG"
# Because who wants to spell that out each time?
IMAGE=$PODMAN_TEST_IMAGE_FQN