diff options
Diffstat (limited to 'test')
45 files changed, 938 insertions, 232 deletions
diff --git a/test/apiv2/10-images.at b/test/apiv2/10-images.at index 1f5722a0c..c105a9278 100644 --- a/test/apiv2/10-images.at +++ b/test/apiv2/10-images.at @@ -43,7 +43,7 @@ t POST "images/create?fromImage=alpine" '' 200 t POST "images/create?fromImage=alpine&tag=latest" '' 200 -t POST "images/create?fromImage=docker.io/library/alpine&tag=sha256:acd3ca9941a85e8ed16515bfc5328e4e2f8c128caa72959a58a127b7801ee01f" '' 200 +t POST "images/create?fromImage=quay.io/libpod/alpine&tag=sha256:fa93b01658e3a5a1686dc3ae55f170d8de487006fb53a28efcd12ab0710a2e5f" '' 200 # Display the image history t GET libpod/images/nonesuch/history 404 diff --git a/test/apiv2/12-imagesMore.at b/test/apiv2/12-imagesMore.at index d720ffa65..896e685cd 100644 --- a/test/apiv2/12-imagesMore.at +++ b/test/apiv2/12-imagesMore.at @@ -23,7 +23,7 @@ t GET libpod/images/$IMAGE/json 200 \ .RepoTags[1]=localhost:5000/myrepo:mytag # Run registry container -podman run -d --name registry -p 5000:5000 docker.io/library/registry:2.6 /entrypoint.sh /etc/docker/registry/config.yml +podman run -d --name registry -p 5000:5000 quay.io/libpod/registry:2.6 /entrypoint.sh /etc/docker/registry/config.yml # Push to local registry # FIXME: this is failing: @@ -44,5 +44,5 @@ t DELETE libpod/containers/registry?force=true 204 # Remove images t DELETE libpod/images/$IMAGE 200 \ .ExitCode=0 -t DELETE libpod/images/docker.io/library/registry:2.6 200 \ +t DELETE libpod/images/quay.io/libpod/registry:2.6 200 \ .ExitCode=0 diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at index c7055dfc4..b35c27215 100644 --- a/test/apiv2/20-containers.at +++ b/test/apiv2/20-containers.at @@ -4,7 +4,7 @@ # # WORKDIR=/data -ENV_WORKDIR_IMG=docker.io/library/redis:alpine +ENV_WORKDIR_IMG=quay.io/libpod/testimage:20200929 podman pull $IMAGE &>/dev/null podman pull $ENV_WORKDIR_IMG &>/dev/null diff --git a/test/apiv2/30-volumes.at b/test/apiv2/30-volumes.at index b599680e3..aa167a97a 100644 --- a/test/apiv2/30-volumes.at +++ b/test/apiv2/30-volumes.at @@ -3,12 +3,66 @@ # volume-related tests # -# -# FIXME: endpoints seem to be unimplemented, return 404 -# -if false; then -t GET libpod/volumes/json 200 null -t POST libpod/volumes/create name=foo 201 -fi +## create volume +t GET libpod/info 200 +volumepath=$(jq -r ".store.volumePath" <<<"$output") +t POST libpod/volumes/create name=foo1 201 \ + .Name=foo1 \ + .Driver=local \ + .Mountpoint=$volumepath/foo1/_data \ + .CreatedAt~[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}.* \ + .Labels={} \ + .Options=null +t POST libpod/volumes/create '' 201 +t POST libpod/volumes/create \ + '"Name":"foo2","Label":{"testlabel":"testonly"},"Options":{"type":"tmpfs","o":"nodev,noexec"}}' 201 \ + .Name=foo2 \ + .Labels.testlabel=testonly \ + .Options.type=tmpfs \ + .Options.o=nodev,noexec + +# Negative test +# We have created a volume named "foo1" +t POST libpod/volumes/create name=foo1 500 \ + .cause="volume already exists" \ + .message~.* \ + .response=500 + +## list volume +t GET libpod/volumes/json 200 \ + .[0].Name~.* \ + .[0].Mountpoint~.* \ + .[0].CreatedAt~[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}.* +# -G --data-urlencode 'filters={"name":["foo1"]}' +t GET libpod/volumes/json?filters=%7B%22name%22%3A%5B%22foo1%22%5D%7D 200 length=1 .[0].Name=foo1 +# -G --data-urlencode 'filters={"name":["foo1","foo2"]}' +t GET libpod/volumes/json?filters=%7B%22name%22%3A%20%5B%22foo1%22%2C%20%22foo2%22%5D%7D 200 length=2 .[0].Name=foo1 .[1].Name=foo2 +# -G --data-urlencode 'filters={"name":["notexist"]}' +t GET libpod/volumes/json?filters=%7B%22name%22%3A%5B%22notexists%22%5D%7D 200 length=0 + +## inspect volume +t GET libpod/volumes/foo1/json 200 \ + .Name=foo1 \ + .Mountpoint=$volumepath/foo1/_data \ + .CreatedAt~[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}.* +t GET libpod/volumes/notexist/json 404 \ + .cause="no such volume" \ + .message~.* \ + .response=404 + +## Remove volumes +t DELETE libpod/volumes/foo1 204 +#After remove foo1 volume, this volume should not exist +t GET libpod/volumes/foo1/json 404 +# Negative test +t DELETE libpod/volumes/foo1 404 \ + .cause="no such volume" \ + .message~.* \ + .response=404 + +## Prune volumes +t POST libpod/volumes/prune "" 200 +#After prune volumes, there should be no volume existing +t GET libpod/volumes/json 200 length=0 # vim: filetype=sh diff --git a/test/apiv2/rest_api/__init__.py b/test/apiv2/rest_api/__init__.py index e69de29bb..5f0777d58 100644 --- a/test/apiv2/rest_api/__init__.py +++ b/test/apiv2/rest_api/__init__.py @@ -0,0 +1,132 @@ +import configparser +import json +import os +import shutil +import subprocess +import sys +import tempfile + + +class Podman(object): + """ + Instances hold the configuration and setup for running podman commands + """ + + def __init__(self): + """Initialize a Podman instance with global options""" + binary = os.getenv("PODMAN", "bin/podman") + self.cmd = [binary, "--storage-driver=vfs"] + + cgroupfs = os.getenv("CGROUP_MANAGER", "cgroupfs") + self.cmd.append(f"--cgroup-manager={cgroupfs}") + + if os.getenv("DEBUG"): + self.cmd.append("--log-level=debug") + + self.anchor_directory = tempfile.mkdtemp(prefix="podman_restapi_") + self.cmd.append("--root=" + os.path.join(self.anchor_directory, "crio")) + self.cmd.append("--runroot=" + os.path.join(self.anchor_directory, "crio-run")) + + os.environ["REGISTRIES_CONFIG_PATH"] = os.path.join( + self.anchor_directory, "registry.conf" + ) + p = configparser.ConfigParser() + p.read_dict( + { + "registries.search": {"registries": "['docker.io']"}, + "registries.insecure": {"registries": "[]"}, + "registries.block": {"registries": "[]"}, + } + ) + with open(os.environ["REGISTRIES_CONFIG_PATH"], "w") as w: + p.write(w) + + os.environ["CNI_CONFIG_PATH"] = os.path.join( + self.anchor_directory, "cni", "net.d" + ) + os.makedirs(os.environ["CNI_CONFIG_PATH"], exist_ok=True) + self.cmd.append("--cni-config-dir=" + os.environ["CNI_CONFIG_PATH"]) + cni_cfg = os.path.join( + os.environ["CNI_CONFIG_PATH"], "87-podman-bridge.conflist" + ) + # json decoded and encoded to ensure legal json + buf = json.loads( + """ + { + "cniVersion": "0.3.0", + "name": "podman", + "plugins": [{ + "type": "bridge", + "bridge": "cni0", + "isGateway": true, + "ipMasq": true, + "ipam": { + "type": "host-local", + "subnet": "10.88.0.0/16", + "routes": [{ + "dst": "0.0.0.0/0" + }] + } + }, + { + "type": "portmap", + "capabilities": { + "portMappings": true + } + } + ] + } + """ + ) + with open(cni_cfg, "w") as w: + json.dump(buf, w) + + def open(self, command, *args, **kwargs): + """Podman initialized instance to run a given command + + :param self: Podman instance + :param command: podman sub-command to run + :param args: arguments and options for command + :param kwargs: See subprocess.Popen() for shell keyword + :return: subprocess.Popen() instance configured to run podman instance + """ + cmd = self.cmd.copy() + cmd.append(command) + cmd.extend(args) + + shell = kwargs.get("shell", False) + + return subprocess.Popen( + cmd, + shell=shell, + stdin=subprocess.DEVNULL, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + + def run(self, command, *args, **kwargs): + """Podman initialized instance to run a given command + + :param self: Podman instance + :param command: podman sub-command to run + :param args: arguments and options for command + :param kwargs: See subprocess.Popen() for shell and check keywords + :return: subprocess.Popen() instance configured to run podman instance + """ + cmd = self.cmd.copy() + cmd.append(command) + cmd.extend(args) + + check = kwargs.get("check", False) + shell = kwargs.get("shell", False) + + return subprocess.run( + cmd, + shell=shell, + check=check, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + + def tear_down(self): + shutil.rmtree(self.anchor_directory, ignore_errors=True) diff --git a/test/apiv2/rest_api/test_rest_v2_0_0.py b/test/apiv2/rest_api/test_rest_v2_0_0.py index 3376f8402..5dfd1fc02 100644 --- a/test/apiv2/rest_api/test_rest_v2_0_0.py +++ b/test/apiv2/rest_api/test_rest_v2_0_0.py @@ -1,5 +1,4 @@ import json -import os import subprocess import sys import time @@ -9,27 +8,25 @@ from multiprocessing import Process import requests from dateutil.parser import parse +from test.apiv2.rest_api import Podman + PODMAN_URL = "http://localhost:8080" def _url(path): - return PODMAN_URL + "/v1.0.0/libpod" + path - - -def podman(): - binary = os.getenv("PODMAN_BINARY") - if binary is None: - binary = "bin/podman" - return binary + return PODMAN_URL + "/v2.0.0/libpod" + path def ctnr(path): - r = requests.get(_url("/containers/json?all=true")) try: + r = requests.get(_url("/containers/json?all=true")) ctnrs = json.loads(r.text) except Exception as e: - sys.stderr.write("Bad container response: {}/{}".format(r.text, e)) - raise e + msg = f"Bad container response: {e}" + if r is not None: + msg = msg + " " + r.text + sys.stderr.write(msg + "\n") + raise return path.format(ctnrs[0]["Id"]) @@ -44,50 +41,50 @@ def validateObjectFields(buffer): class TestApi(unittest.TestCase): - podman = None + podman = None # initialized podman configuration for tests + service = None # podman service instance def setUp(self): super().setUp() - if TestApi.podman.poll() is not None: - sys.stderr.write(f"podman service returned {TestApi.podman.returncode}\n") - sys.exit(2) - requests.get( - _url("/images/create?fromSrc=docker.io%2Falpine%3Alatest")) - # calling out to podman is easier than the API for running a container - subprocess.run([podman(), "run", "alpine", "/bin/ls"], - check=True, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) + + try: + TestApi.podman.run("run", "alpine", "/bin/ls", check=True) + except subprocess.CalledProcessError as e: + if e.stdout: + sys.stdout.write("\nRun Stdout:\n" + e.stdout.decode("utf-8")) + if e.stderr: + sys.stderr.write("\nRun Stderr:\n" + e.stderr.decode("utf-8")) + raise @classmethod def setUpClass(cls): super().setUpClass() - TestApi.podman = subprocess.Popen( - [ - podman(), "system", "service", "tcp:localhost:8080", - "--log-level=debug", "--time=0" - ], - shell=False, - stdin=subprocess.DEVNULL, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, + TestApi.podman = Podman() + TestApi.service = TestApi.podman.open( + "system", "service", "tcp:localhost:8080", "--log-level=debug", "--time=0" ) + # give the service some time to be ready... time.sleep(2) + returncode = TestApi.service.poll() + if returncode is not None: + raise subprocess.CalledProcessError(returncode, "podman system service") + + r = requests.post(_url("/images/pull?reference=docker.io%2Falpine%3Alatest")) + if r.status_code != 200: + raise subprocess.CalledProcessError( + r.status_code, f"podman images pull docker.io/alpine:latest {r.text}" + ) + @classmethod def tearDownClass(cls): - TestApi.podman.terminate() - stdout, stderr = TestApi.podman.communicate(timeout=0.5) + TestApi.service.terminate() + stdout, stderr = TestApi.service.communicate(timeout=0.5) if stdout: - print("\nService Stdout:\n" + stdout.decode('utf-8')) + sys.stdout.write("\nService Stdout:\n" + stdout.decode("utf-8")) if stderr: - print("\nService Stderr:\n" + stderr.decode('utf-8')) - - if TestApi.podman.returncode > 0: - sys.stderr.write(f"podman exited with error code {TestApi.podman.returncode}\n") - sys.exit(2) - + sys.stderr.write("\nService Stderr:\n" + stderr.decode("utf-8")) return super().tearDownClass() def test_info(self): @@ -160,6 +157,7 @@ class TestApi(unittest.TestCase): self.assertIsNone(r.text) def test_attach_containers(self): + self.skipTest("FIXME: Test timeouts") r = requests.post(_url(ctnr("/containers/{}/attach")), timeout=5) self.assertIn(r.status_code, (101, 500), r.text) @@ -242,5 +240,5 @@ class TestApi(unittest.TestCase): self.assertEqual(r.status_code, 200, r.text) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/apiv2/rest_api/test_rest_v1_0_0.py b/test/apiv2/rest_api/v1_test_rest_v1_0_0.py index 2e574e015..acd6273ef 100644 --- a/test/apiv2/rest_api/test_rest_v1_0_0.py +++ b/test/apiv2/rest_api/v1_test_rest_v1_0_0.py @@ -43,16 +43,16 @@ class TestApi(unittest.TestCase): def setUp(self): super().setUp() if TestApi.podman.poll() is not None: - sys.stderr.write("podman service returned {}", - TestApi.podman.returncode) + sys.stderr.write("podman service returned {}", TestApi.podman.returncode) sys.exit(2) - requests.get( - _url("/images/create?fromSrc=docker.io%2Falpine%3Alatest")) + requests.get(_url("/images/create?fromSrc=docker.io%2Falpine%3Alatest")) # calling out to podman is easier than the API for running a container - subprocess.run([podman(), "run", "alpine", "/bin/ls"], - check=True, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) + subprocess.run( + [podman(), "run", "alpine", "/bin/ls"], + check=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) @classmethod def setUpClass(cls): @@ -60,8 +60,12 @@ class TestApi(unittest.TestCase): TestApi.podman = subprocess.Popen( [ - podman(), "system", "service", "tcp:localhost:8080", - "--log-level=debug", "--time=0" + podman(), + "system", + "service", + "tcp:localhost:8080", + "--log-level=debug", + "--time=0", ], shell=False, stdin=subprocess.DEVNULL, @@ -75,13 +79,14 @@ class TestApi(unittest.TestCase): TestApi.podman.terminate() stdout, stderr = TestApi.podman.communicate(timeout=0.5) if stdout: - print("\nService Stdout:\n" + stdout.decode('utf-8')) + print("\nService Stdout:\n" + stdout.decode("utf-8")) if stderr: - print("\nService Stderr:\n" + stderr.decode('utf-8')) + print("\nService Stderr:\n" + stderr.decode("utf-8")) if TestApi.podman.returncode > 0: - sys.stderr.write("podman exited with error code {}\n".format( - TestApi.podman.returncode)) + sys.stderr.write( + "podman exited with error code {}\n".format(TestApi.podman.returncode) + ) sys.exit(2) return super().tearDownClass() @@ -222,13 +227,14 @@ class TestApi(unittest.TestCase): def validateObjectFields(self, buffer): - objs = json.loads(buffer) - if not isinstance(objs, dict): - for o in objs: - _ = o["Id"] - else: - _ = objs["Id"] - return objs - -if __name__ == '__main__': + objs = json.loads(buffer) + if not isinstance(objs, dict): + for o in objs: + _ = o["Id"] + else: + _ = objs["Id"] + return objs + + +if __name__ == "__main__": unittest.main() diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index 572e55fe5..ea15e2b8d 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -226,7 +226,7 @@ var _ = Describe("Podman build", func() { podmanTest.StartRemoteService() } podmanTest.RestoreAllArtifacts() - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest RUN printenv http_proxy` dockerfilePath := filepath.Join(podmanTest.TempDir, "Dockerfile") diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 206c66f9f..678b2c882 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -515,6 +515,14 @@ func (s *PodmanSessionIntegration) InspectPodToJSON() define.InspectPodData { return i } +// InspectPodToJSON takes the sessions output from an inspect and returns json +func (s *PodmanSessionIntegration) InspectPodArrToJSON() []define.InspectPodData { + var i []define.InspectPodData + err := jsoniter.Unmarshal(s.Out.Contents(), &i) + Expect(err).To(BeNil()) + return i +} + // CreatePod creates a pod with no infra container // it optionally takes a pod name func (p *PodmanTestIntegration) CreatePod(name string) (*PodmanSessionIntegration, int, string) { @@ -605,12 +613,10 @@ func SkipIfRootlessCgroupsV1(reason string) { } } -func SkipIfUnprevilegedCPULimits() { +func SkipIfUnprivilegedCPULimits() { info := GetHostDistributionInfo() - if isRootless() && - info.Distribution == "fedora" && - (info.Version == "31" || info.Version == "32") { - ginkgo.Skip("Rootless Fedora doesn't have permission to set CPU limits before version 33") + if isRootless() && info.Distribution == "fedora" { + ginkgo.Skip("Rootless Fedora doesn't have permission to set CPU limits") } } @@ -621,6 +627,13 @@ func SkipIfRootless(reason string) { } } +func SkipIfNotRootless(reason string) { + checkReason(reason) + if os.Geteuid() == 0 { + ginkgo.Skip("[notRootless]: " + reason) + } +} + func SkipIfNotFedora() { info := GetHostDistributionInfo() if info.Distribution != "fedora" { diff --git a/test/e2e/config.go b/test/e2e/config.go index 54e39f9d2..e66cd6846 100644 --- a/test/e2e/config.go +++ b/test/e2e/config.go @@ -1,18 +1,18 @@ package integration var ( - redis = "docker.io/library/redis:alpine" + redis = "quay.io/libpod/redis:alpine" fedoraMinimal = "quay.io/libpod/fedora-minimal:latest" - ALPINE = "docker.io/library/alpine:latest" - ALPINELISTTAG = "docker.io/library/alpine:3.10.2" - ALPINELISTDIGEST = "docker.io/library/alpine@sha256:72c42ed48c3a2db31b7dafe17d275b634664a708d901ec9fd57b1529280f01fb" - ALPINEAMD64DIGEST = "docker.io/library/alpine@sha256:acd3ca9941a85e8ed16515bfc5328e4e2f8c128caa72959a58a127b7801ee01f" + ALPINE = "quay.io/libpod/alpine:latest" + ALPINELISTTAG = "quay.io/libpod/alpine:3.10.2" + ALPINELISTDIGEST = "quay.io/libpod/alpine@sha256:fa93b01658e3a5a1686dc3ae55f170d8de487006fb53a28efcd12ab0710a2e5f" + ALPINEAMD64DIGEST = "quay.io/libpod/alpine@sha256:634a8f35b5f16dcf4aaa0822adc0b1964bb786fca12f6831de8ddc45e5986a00" ALPINEAMD64ID = "961769676411f082461f9ef46626dd7a2d1e2b2a38e6a44364bcbecf51e66dd4" - ALPINEARM64DIGEST = "docker.io/library/alpine@sha256:db7f3dcef3d586f7dd123f107c93d7911515a5991c4b9e51fa2a43e46335a43e" + ALPINEARM64DIGEST = "quay.io/libpod/alpine@sha256:f270dcd11e64b85919c3bab66886e59d677cf657528ac0e4805d3c71e458e525" ALPINEARM64ID = "915beeae46751fc564998c79e73a1026542e945ca4f73dc841d09ccc6c2c0672" infra = "k8s.gcr.io/pause:3.2" - BB = "docker.io/library/busybox:latest" - healthcheck = "docker.io/libpod/alpine_healthcheck:latest" + BB = "quay.io/libpod/busybox:latest" + healthcheck = "quay.io/libpod/alpine_healthcheck:latest" ImageCacheDir = "/tmp/podman/imagecachedir" fedoraToolbox = "registry.fedoraproject.org/f32/fedora-toolbox:latest" @@ -20,8 +20,8 @@ var ( // The intention behind blocking all syscalls is to prevent // regressions in the future. The required syscalls can vary // depending on which runtime we're using. - alpineSeccomp = "docker.io/libpod/alpine-with-seccomp:label" + alpineSeccomp = "quay.io/libpod/alpine-with-seccomp:label" // This image has a bogus/invalid seccomp profile which should // yield a json error when being read. - alpineBogusSeccomp = "docker.io/libpod/alpine-with-bogus-seccomp:label" + alpineBogusSeccomp = "quay.io/libpod/alpine-with-bogus-seccomp:label" ) diff --git a/test/e2e/config_amd64.go b/test/e2e/config_amd64.go index 151120058..2323c7e6b 100644 --- a/test/e2e/config_amd64.go +++ b/test/e2e/config_amd64.go @@ -8,7 +8,7 @@ var ( CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, registry, infra, labels, healthcheck, ubi_init, ubi_minimal} nginx = "quay.io/libpod/alpine_nginx:latest" BB_GLIBC = "docker.io/library/busybox:glibc" - registry = "docker.io/library/registry:2.6" + registry = "quay.io/libpod/registry:2.6" labels = "quay.io/libpod/alpine_labels:latest" ubi_minimal = "registry.access.redhat.com/ubi8-minimal" ubi_init = "registry.access.redhat.com/ubi8-init" diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go index 0a9fa990c..6d349ba5b 100644 --- a/test/e2e/cp_test.go +++ b/test/e2e/cp_test.go @@ -204,6 +204,42 @@ var _ = Describe("Podman cp", func() { os.Remove("file.tar") }) + It("podman cp tar --extract", func() { + testctr := "testctr" + setup := podmanTest.RunTopContainer(testctr) + setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"exec", testctr, "mkdir", "/foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + path, err := os.Getwd() + Expect(err).To(BeNil()) + testDirPath := filepath.Join(path, "TestDir4") + err = os.Mkdir(testDirPath, 0777) + Expect(err).To(BeNil()) + defer os.RemoveAll(testDirPath) + f, err := os.Create(filepath.Join(testDirPath, "a.txt")) + Expect(err).To(BeNil()) + _, err = f.Write([]byte("Hello World!!!\n")) + f.Close() + cmd := exec.Command("tar", "-cvf", "file.tar", "TestDir4") + exec.Command("tar", "-cvf", "/home/mvasek/file.tar", testDirPath) + _, err = cmd.Output() + Expect(err).To(BeNil()) + defer os.Remove("file.tar") + + session = podmanTest.Podman([]string{"cp", "--extract", "file.tar", "testctr:/foo/"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"exec", testctr, "cat", "/foo/TestDir4/a.txt"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("Hello World!!!")) + }) + It("podman cp symlink", func() { session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index 6b0f7a7af..d9378abca 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -271,11 +271,11 @@ var _ = Describe("Podman create", func() { }) It("podman create --pull", func() { - session := podmanTest.PodmanNoCache([]string{"create", "--pull", "never", "--name=foo", "debian"}) + session := podmanTest.PodmanNoCache([]string{"create", "--pull", "never", "--name=foo", "testimage:00000000"}) session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError()) - session = podmanTest.PodmanNoCache([]string{"create", "--pull", "always", "--name=foo", "debian"}) + session = podmanTest.PodmanNoCache([]string{"create", "--pull", "always", "--name=foo", "testimage:00000000"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index a698cd4b3..f61f52589 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -87,14 +87,12 @@ var _ = Describe("Podman exec", func() { session := podmanTest.Podman([]string{"exec", "--env", "FOO=BAR", "test1", "printenv", "FOO"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ := session.GrepString("BAR") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(Equal("BAR")) session = podmanTest.Podman([]string{"exec", "--env", "PATH=/bin", "test1", "printenv", "PATH"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ = session.GrepString("/bin") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(Equal("/bin")) }) It("podman exec os.Setenv env", func() { @@ -107,8 +105,7 @@ var _ = Describe("Podman exec", func() { session := podmanTest.Podman([]string{"exec", "--env", "FOO", "test1", "printenv", "FOO"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ := session.GrepString("BAR") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(Equal("BAR")) os.Unsetenv("FOO") }) @@ -142,8 +139,7 @@ var _ = Describe("Podman exec", func() { session := podmanTest.Podman([]string{"exec", "--interactive", "--tty", "test1", "/usr/bin/stty", "--all"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ := session.GrepString(" onlcr") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(" onlcr")) }) It("podman exec simple command with user", func() { @@ -199,14 +195,12 @@ var _ = Describe("Podman exec", func() { session := podmanTest.Podman([]string{"exec", "--workdir", "/tmp", "test1", "pwd"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ := session.GrepString("/tmp") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(Equal("/tmp")) session = podmanTest.Podman([]string{"exec", "-w", "/tmp", "test1", "pwd"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ = session.GrepString("/tmp") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(Equal("/tmp")) }) It("podman exec missing working directory test", func() { @@ -280,7 +274,7 @@ var _ = Describe("Podman exec", func() { exec := podmanTest.Podman([]string{"exec", "-ti", ctrName2, "id"}) exec.WaitWithDefaultTimeout() Expect(exec.ExitCode()).To(Equal(0)) - Expect(strings.Contains(exec.OutputToString(), fmt.Sprintf("%s(%s)", gid, groupName))).To(BeTrue()) + Expect(exec.OutputToString()).To(ContainSubstring(fmt.Sprintf("%s(%s)", gid, groupName))) }) It("podman exec preserves container groups with --user and --group-add", func() { @@ -300,9 +294,9 @@ RUN useradd -u 1000 auser` exec.WaitWithDefaultTimeout() Expect(exec.ExitCode()).To(Equal(0)) output := exec.OutputToString() - Expect(strings.Contains(output, "4000(first)")).To(BeTrue()) - Expect(strings.Contains(output, "4001(second)")).To(BeTrue()) - Expect(strings.Contains(output, "1000(auser)")).To(BeTrue()) + Expect(output).To(ContainSubstring("4000(first)")) + Expect(output).To(ContainSubstring("4001(second)")) + Expect(output).To(ContainSubstring("1000(auser)")) // Kill the container just so the test does not take 15 seconds to stop. kill := podmanTest.Podman([]string{"kill", ctrName}) @@ -323,7 +317,7 @@ RUN useradd -u 1000 auser` data := podmanTest.InspectContainer(ctrName) Expect(len(data)).To(Equal(1)) Expect(len(data[0].ExecIDs)).To(Equal(1)) - Expect(strings.Contains(exec1.OutputToString(), data[0].ExecIDs[0])).To(BeTrue()) + Expect(exec1.OutputToString()).To(ContainSubstring(data[0].ExecIDs[0])) exec2 := podmanTest.Podman([]string{"exec", "-t", "-i", ctrName, "ps", "-a"}) exec2.WaitWithDefaultTimeout() diff --git a/test/e2e/exists_test.go b/test/e2e/exists_test.go index 1076dfc61..1408e59bb 100644 --- a/test/e2e/exists_test.go +++ b/test/e2e/exists_test.go @@ -39,6 +39,7 @@ var _ = Describe("Podman image|container exists", func() { Expect(session).Should(Exit(0)) }) It("podman image exists in local storage by short name", func() { + Skip("FIXME-8165: shortnames don't seem to work with quay (#8176)") session := podmanTest.Podman([]string{"image", "exists", "alpine"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go index 71e73af9c..403f15fa7 100644 --- a/test/e2e/healthcheck_run_test.go +++ b/test/e2e/healthcheck_run_test.go @@ -81,7 +81,7 @@ var _ = Describe("Podman healthcheck run", func() { }) It("podman healthcheck that should fail", func() { - session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "docker.io/libpod/badhealthcheck:latest"}) + session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "quay.io/libpod/badhealthcheck:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index 9344132d9..b42061c20 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -41,8 +41,8 @@ var _ = Describe("Podman images", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2)) - Expect(session.LineInOuputStartsWith("docker.io/library/alpine")).To(BeTrue()) - Expect(session.LineInOuputStartsWith("docker.io/library/busybox")).To(BeTrue()) + Expect(session.LineInOuputStartsWith("quay.io/libpod/alpine")).To(BeTrue()) + Expect(session.LineInOuputStartsWith("quay.io/libpod/busybox")).To(BeTrue()) }) It("podman images with no images prints header", func() { @@ -62,8 +62,8 @@ var _ = Describe("Podman images", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2)) - Expect(session.LineInOuputStartsWith("docker.io/library/alpine")).To(BeTrue()) - Expect(session.LineInOuputStartsWith("docker.io/library/busybox")).To(BeTrue()) + Expect(session.LineInOuputStartsWith("quay.io/libpod/alpine")).To(BeTrue()) + Expect(session.LineInOuputStartsWith("quay.io/libpod/busybox")).To(BeTrue()) }) It("podman images with multiple tags", func() { @@ -80,13 +80,13 @@ var _ = Describe("Podman images", func() { session = podmanTest.PodmanNoCache([]string{"images"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session.LineInOutputContainsTag("docker.io/library/alpine", "latest") - session.LineInOutputContainsTag("docker.io/library/busybox", "glibc") - session.LineInOutputContainsTag("foo", "a") - session.LineInOutputContainsTag("foo", "b") - session.LineInOutputContainsTag("foo", "c") - session.LineInOutputContainsTag("bar", "a") - session.LineInOutputContainsTag("bar", "b") + Expect(session.LineInOutputContainsTag("quay.io/libpod/alpine", "latest")).To(BeTrue()) + Expect(session.LineInOutputContainsTag("quay.io/libpod/busybox", "latest")).To(BeTrue()) + Expect(session.LineInOutputContainsTag("localhost/foo", "a")).To(BeTrue()) + Expect(session.LineInOutputContainsTag("localhost/foo", "b")).To(BeTrue()) + Expect(session.LineInOutputContainsTag("localhost/foo", "c")).To(BeTrue()) + Expect(session.LineInOutputContainsTag("localhost/bar", "a")).To(BeTrue()) + Expect(session.LineInOutputContainsTag("localhost/bar", "b")).To(BeTrue()) session = podmanTest.PodmanNoCache([]string{"images", "-qn"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) @@ -98,8 +98,8 @@ var _ = Describe("Podman images", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2)) - Expect(session.LineInOuputStartsWith("docker.io/library/alpine")).To(BeTrue()) - Expect(session.LineInOuputStartsWith("docker.io/library/busybox")).To(BeTrue()) + Expect(session.LineInOuputStartsWith("quay.io/libpod/alpine")).To(BeTrue()) + Expect(session.LineInOuputStartsWith("quay.io/libpod/busybox")).To(BeTrue()) }) It("podman empty images list in JSON format", func() { @@ -152,10 +152,10 @@ var _ = Describe("Podman images", func() { It("podman images filter reference", func() { podmanTest.RestoreAllArtifacts() - result := podmanTest.PodmanNoCache([]string{"images", "-q", "-f", "reference=docker.io*"}) + result := podmanTest.PodmanNoCache([]string{"images", "-q", "-f", "reference=quay.io*"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - Expect(len(result.OutputToStringArray())).To(Equal(2)) + Expect(len(result.OutputToStringArray())).To(Equal(3)) retapline := podmanTest.PodmanNoCache([]string{"images", "-f", "reference=a*pine"}) retapline.WaitWithDefaultTimeout() @@ -176,7 +176,7 @@ var _ = Describe("Podman images", func() { }) It("podman images filter before image", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest RUN apk update && apk add strace ` podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") @@ -188,7 +188,7 @@ RUN apk update && apk add strace }) It("podman images workingdir from image", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest WORKDIR /test ` podmanTest.BuildImage(dockerfile, "foobar.com/workdir:latest", "false") @@ -204,10 +204,10 @@ WORKDIR /test rmi.WaitWithDefaultTimeout() Expect(rmi).Should(Exit(0)) - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest ` podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") - result := podmanTest.PodmanNoCache([]string{"images", "-q", "-f", "after=docker.io/library/alpine:latest"}) + result := podmanTest.PodmanNoCache([]string{"images", "-q", "-f", "after=quay.io/libpod/alpine:latest"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) Expect(len(result.OutputToStringArray())).To(Equal(0)) @@ -219,17 +219,17 @@ WORKDIR /test rmi.WaitWithDefaultTimeout() Expect(rmi).Should(Exit(0)) - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest ` podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") - result := podmanTest.PodmanNoCache([]string{"image", "list", "-q", "-f", "after=docker.io/library/alpine:latest"}) + result := podmanTest.PodmanNoCache([]string{"image", "list", "-q", "-f", "after=quay.io/libpod/alpine:latest"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) Expect(result.OutputToStringArray()).Should(HaveLen(0), "list filter output: %q", result.OutputToString()) }) It("podman images filter dangling", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest ` podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") @@ -240,6 +240,7 @@ WORKDIR /test }) It("podman pull by digest and list --all", func() { + Skip("FIXME-8165: 'rmi -af' fails with 'layer not known' (#6510)") // Prevent regressing on issue #7651. digestPullAndList := func(noneTag bool) { session := podmanTest.Podman([]string{"pull", ALPINEAMD64DIGEST}) @@ -341,7 +342,7 @@ WORKDIR /test It("podman images --all flag", func() { SkipIfRemote("FIXME This should work on podman-remote, problem is with podman-remote build") podmanTest.RestoreAllArtifacts() - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest RUN mkdir hello RUN touch test.txt ENV foo=bar @@ -359,7 +360,7 @@ ENV foo=bar }) It("podman images filter by label", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest LABEL version="1.0" LABEL "com.example.vendor"="Example Vendor" ` @@ -436,7 +437,7 @@ LABEL "com.example.vendor"="Example Vendor" }) It("podman images --filter readonly", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest ` podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") result := podmanTest.Podman([]string{"images", "-f", "readonly=true"}) diff --git a/test/e2e/info_test.go b/test/e2e/info_test.go index 49f5f0ce6..bc4e6212b 100644 --- a/test/e2e/info_test.go +++ b/test/e2e/info_test.go @@ -5,9 +5,9 @@ import ( "io/ioutil" "os" "os/exec" + "os/user" "path/filepath" - "github.com/containers/podman/v2/pkg/rootless" . "github.com/containers/podman/v2/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -78,39 +78,35 @@ var _ = Describe("Podman Info", func() { }) It("podman info rootless storage path", func() { - if !rootless.IsRootless() { - Skip("test of rootless_storage_path is only meaningful as rootless") - } + SkipIfNotRootless("test of rootless_storage_path is only meaningful as rootless") SkipIfRemote("Only tests storage on local client") - oldHOME, hasHOME := os.LookupEnv("HOME") + configPath := filepath.Join(podmanTest.TempDir, ".config", "containers", "storage.conf") + os.Setenv("CONTAINERS_STORAGE_CONF", configPath) defer func() { - if hasHOME { - os.Setenv("HOME", oldHOME) - } else { - os.Unsetenv("HOME") - } + os.Unsetenv("CONTAINERS_STORAGE_CONF") }() - os.Setenv("HOME", podmanTest.TempDir) - configPath := filepath.Join(os.Getenv("HOME"), ".config", "containers", "storage.conf") err := os.RemoveAll(filepath.Dir(configPath)) Expect(err).To(BeNil()) err = os.MkdirAll(filepath.Dir(configPath), os.ModePerm) Expect(err).To(BeNil()) - rootlessStoragePath := `"/tmp/$HOME/$USER/$UID"` + rootlessStoragePath := `"/tmp/$HOME/$USER/$UID/storage"` driver := `"overlay"` storageOpt := `"/usr/bin/fuse-overlayfs"` storageConf := []byte(fmt.Sprintf("[storage]\ndriver=%s\nrootless_storage_path=%s\n[storage.options]\nmount_program=%s", driver, rootlessStoragePath, storageOpt)) err = ioutil.WriteFile(configPath, storageConf, os.ModePerm) Expect(err).To(BeNil()) - expect := filepath.Join("/tmp", os.Getenv("HOME"), os.Getenv("USER"), os.Getenv("UID")) + u, err := user.Current() + Expect(err).To(BeNil()) + + expect := filepath.Join("/tmp", os.Getenv("HOME"), u.Username, u.Uid, "storage") podmanPath := podmanTest.PodmanTest.PodmanBinary cmd := exec.Command(podmanPath, "info", "--format", "{{.Store.GraphRoot}}") out, err := cmd.CombinedOutput() fmt.Println(string(out)) Expect(err).To(BeNil()) - Expect(string(out)).To(ContainSubstring(expect)) + Expect(string(out)).To(Equal(expect)) }) }) diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go index d4de7a65c..9ede3384f 100644 --- a/test/e2e/inspect_test.go +++ b/test/e2e/inspect_test.go @@ -40,7 +40,7 @@ var _ = Describe("Podman inspect", func() { Expect(session.ExitCode()).To(Equal(0)) Expect(session.IsJSONOutputValid()).To(BeTrue()) imageData := session.InspectImageJSON() - Expect(imageData[0].RepoTags[0]).To(Equal("docker.io/library/alpine:latest")) + Expect(imageData[0].RepoTags[0]).To(Equal("quay.io/libpod/alpine:latest")) }) It("podman inspect bogus container", func() { @@ -289,4 +289,145 @@ var _ = Describe("Podman inspect", func() { Expect(baseJSON[0].HostConfig.SecurityOpt).To(Equal([]string{"label=type:spc_t,label=level:s0", "seccomp=unconfined"})) }) + It("podman inspect pod", func() { + podName := "testpod" + create := podmanTest.PodmanNoCache([]string{"pod", "create", "--name", podName}) + create.WaitWithDefaultTimeout() + Expect(create.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", podName}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(Equal(0)) + Expect(inspect.IsJSONOutputValid()).To(BeTrue()) + podData := inspect.InspectPodArrToJSON() + Expect(podData[0].Name).To(Equal(podName)) + }) + + It("podman inspect pod with type", func() { + podName := "testpod" + create := podmanTest.PodmanNoCache([]string{"pod", "create", "--name", podName}) + create.WaitWithDefaultTimeout() + Expect(create.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", "--type", "pod", podName}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(Equal(0)) + Expect(inspect.IsJSONOutputValid()).To(BeTrue()) + podData := inspect.InspectPodArrToJSON() + Expect(podData[0].Name).To(Equal(podName)) + }) + + It("podman inspect latest pod", func() { + SkipIfRemote("--latest flag n/a") + podName := "testpod" + create := podmanTest.PodmanNoCache([]string{"pod", "create", "--name", podName}) + create.WaitWithDefaultTimeout() + Expect(create.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", "--type", "pod", "--latest"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(Equal(0)) + Expect(inspect.IsJSONOutputValid()).To(BeTrue()) + podData := inspect.InspectPodArrToJSON() + Expect(podData[0].Name).To(Equal(podName)) + }) + It("podman inspect latest defaults to latest container", func() { + SkipIfRemote("--latest flag n/a") + podName := "testpod" + pod := podmanTest.PodmanNoCache([]string{"pod", "create", "--name", podName}) + pod.WaitWithDefaultTimeout() + Expect(pod.ExitCode()).To(Equal(0)) + + inspect1 := podmanTest.Podman([]string{"inspect", "--type", "pod", podName}) + inspect1.WaitWithDefaultTimeout() + Expect(inspect1.ExitCode()).To(Equal(0)) + Expect(inspect1.IsJSONOutputValid()).To(BeTrue()) + podData := inspect1.InspectPodArrToJSON() + infra := podData[0].Containers[0].Name + + inspect := podmanTest.Podman([]string{"inspect", "--latest"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(Equal(0)) + Expect(inspect.IsJSONOutputValid()).To(BeTrue()) + containerData := inspect.InspectContainerToJSON() + Expect(containerData[0].Name).To(Equal(infra)) + }) + + It("podman inspect network", func() { + name, path := generateNetworkConfig(podmanTest) + defer removeConf(path) + + session := podmanTest.Podman([]string{"inspect", name, "--format", "{{.cniVersion}}"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.LineInOutputContains("0.3.0")).To(BeTrue()) + }) + + It("podman inspect a volume", func() { + session := podmanTest.Podman([]string{"volume", "create", "myvol"}) + session.WaitWithDefaultTimeout() + volName := session.OutputToString() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"inspect", volName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.IsJSONOutputValid()).To(BeTrue()) + }) + + It("podman inspect a volume with --format", func() { + session := podmanTest.Podman([]string{"volume", "create", "myvol"}) + session.WaitWithDefaultTimeout() + volName := session.OutputToString() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"inspect", "--format", "{{.Name}}", volName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal(volName)) + }) + It("podman inspect --type container on a pod should fail", func() { + podName := "testpod" + create := podmanTest.PodmanNoCache([]string{"pod", "create", "--name", podName}) + create.WaitWithDefaultTimeout() + Expect(create.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", "--type", "container", podName}) + inspect.WaitWithDefaultTimeout() + Expect(inspect).To(ExitWithError()) + }) + + It("podman inspect --type network on a container should fail", func() { + ctrName := "testctr" + create := podmanTest.PodmanNoCache([]string{"create", "--name", ctrName, ALPINE}) + create.WaitWithDefaultTimeout() + Expect(create.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", "--type", "network", ctrName}) + inspect.WaitWithDefaultTimeout() + Expect(inspect).To(ExitWithError()) + }) + + It("podman inspect --type pod on a container should fail", func() { + ctrName := "testctr" + create := podmanTest.PodmanNoCache([]string{"create", "--name", ctrName, ALPINE}) + create.WaitWithDefaultTimeout() + Expect(create.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", "--type", "pod", ctrName}) + inspect.WaitWithDefaultTimeout() + Expect(inspect).To(ExitWithError()) + }) + + It("podman inspect --type volume on a container should fail", func() { + ctrName := "testctr" + create := podmanTest.PodmanNoCache([]string{"create", "--name", ctrName, ALPINE}) + create.WaitWithDefaultTimeout() + Expect(create.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", "--type", "volume", ctrName}) + inspect.WaitWithDefaultTimeout() + Expect(inspect).To(ExitWithError()) + }) + }) diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go index dd91381d9..e85a38c66 100644 --- a/test/e2e/load_test.go +++ b/test/e2e/load_test.go @@ -166,7 +166,7 @@ var _ = Describe("Podman load", func() { Skip("skip on ppc64le") } outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - alpVersion := "docker.io/library/alpine:3.2" + alpVersion := "quay.io/libpod/alpine:3.2" pull := podmanTest.PodmanNoCache([]string{"pull", alpVersion}) pull.WaitWithDefaultTimeout() diff --git a/test/e2e/manifest_test.go b/test/e2e/manifest_test.go index b85132814..29a62e5bb 100644 --- a/test/e2e/manifest_test.go +++ b/test/e2e/manifest_test.go @@ -55,7 +55,12 @@ var _ = Describe("Podman manifest", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"manifest", "inspect", "docker.io/library/busybox"}) + session = podmanTest.PodmanNoCache([]string{"manifest", "inspect", "quay.io/libpod/busybox"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + + // inspect manifest of single image + session = podmanTest.PodmanNoCache([]string{"manifest", "inspect", "quay.io/libpod/busybox@sha256:6655df04a3df853b029a5fac8836035ac4fab117800c9a6c4b69341bb5306c3d"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) }) diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 7ab8dc6f8..1d683e987 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -1092,7 +1092,7 @@ var _ = Describe("Podman play kube", func() { }) It("podman play kube with pull always", func() { - oldBB := "docker.io/library/busybox:1.30.1" + oldBB := "quay.io/libpod/busybox:1.30.1" pull := podmanTest.Podman([]string{"pull", oldBB}) pull.WaitWithDefaultTimeout() @@ -1123,7 +1123,7 @@ var _ = Describe("Podman play kube", func() { }) It("podman play kube with latest image should always pull", func() { - oldBB := "docker.io/library/busybox:1.30.1" + oldBB := "quay.io/libpod/busybox:1.30.1" pull := podmanTest.Podman([]string{"pull", oldBB}) pull.WaitWithDefaultTimeout() @@ -1406,7 +1406,7 @@ spec: It("podman play kube allows setting resource limits", func() { SkipIfContainerized("Resource limits require a running systemd") SkipIfRootlessCgroupsV1("Limits require root or cgroups v2") - SkipIfUnprevilegedCPULimits() + SkipIfUnprivilegedCPULimits() podmanTest.CgroupManager = "systemd" var ( diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index 83a66d2b9..be0a2f6f0 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -382,7 +382,7 @@ var _ = Describe("Podman pod create", func() { }) It("podman create pod with --infra-image", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest entrypoint ["/fromimage"] ` podmanTest.BuildImage(dockerfile, "localhost/infra", "false") @@ -409,7 +409,7 @@ entrypoint ["/fromimage"] }) It("podman create pod with --infra-command --infra-image", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest entrypoint ["/fromimage"] ` podmanTest.BuildImage(dockerfile, "localhost/infra", "false") @@ -446,4 +446,34 @@ entrypoint ["/fromimage"] Expect(check.ExitCode()).To(Equal(0)) Expect(check.OutputToString()).To(Equal("[port_handler=slirp4netns]")) }) + + It("podman pod status test", func() { + podName := "testpod" + create := podmanTest.Podman([]string{"pod", "create", "--name", podName}) + create.WaitWithDefaultTimeout() + Expect(create.ExitCode()).To(Equal(0)) + + status1 := podmanTest.Podman([]string{"pod", "inspect", "--format", "{{ .State }}", podName}) + status1.WaitWithDefaultTimeout() + Expect(status1.ExitCode()).To(Equal(0)) + Expect(strings.Contains(status1.OutputToString(), "Created")).To(BeTrue()) + + ctr1 := podmanTest.Podman([]string{"run", "--pod", podName, "-d", ALPINE, "top"}) + ctr1.WaitWithDefaultTimeout() + Expect(ctr1.ExitCode()).To(Equal(0)) + + status2 := podmanTest.Podman([]string{"pod", "inspect", "--format", "{{ .State }}", podName}) + status2.WaitWithDefaultTimeout() + Expect(status2.ExitCode()).To(Equal(0)) + Expect(strings.Contains(status2.OutputToString(), "Running")).To(BeTrue()) + + ctr2 := podmanTest.Podman([]string{"create", "--pod", podName, ALPINE, "top"}) + ctr2.WaitWithDefaultTimeout() + Expect(ctr2.ExitCode()).To(Equal(0)) + + status3 := podmanTest.Podman([]string{"pod", "inspect", "--format", "{{ .State }}", podName}) + status3.WaitWithDefaultTimeout() + Expect(status3.ExitCode()).To(Equal(0)) + Expect(strings.Contains(status3.OutputToString(), "Degraded")).To(BeTrue()) + }) }) diff --git a/test/e2e/pod_pod_namespaces.go b/test/e2e/pod_pod_namespaces.go index 41e9c5683..20b8bdb39 100644 --- a/test/e2e/pod_pod_namespaces.go +++ b/test/e2e/pod_pod_namespaces.go @@ -60,6 +60,25 @@ var _ = Describe("Podman pod create", func() { Expect(NAMESPACE1).To(Equal(NAMESPACE2)) }) + It("podman pod container share ipc && /dev/shm ", func() { + session := podmanTest.Podman([]string{"pod", "create"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + podID := session.OutputToString() + + session = podmanTest.Podman([]string{"pod", "start", podID}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"run", "--rm", "--pod", podID, ALPINE, "touch", "/dev/shm/test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"run", "--rm", "--pod", podID, ALPINE, "ls", "/dev/shm/test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + It("podman pod container dontshare PIDNS", func() { session := podmanTest.Podman([]string{"pod", "create"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index 11d0b8c9b..f3a66e58a 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -232,12 +232,19 @@ var _ = Describe("Podman ps", func() { }) It("podman ps ancestor filter flag", func() { - _, ec, _ := podmanTest.RunLsContainer("test1") + _, ec, cid := podmanTest.RunLsContainer("test1") Expect(ec).To(Equal(0)) - result := podmanTest.Podman([]string{"ps", "-a", "--filter", "ancestor=docker.io/library/alpine:latest"}) + result := podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "-a", "--filter", "ancestor=quay.io/libpod/alpine:latest"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(Equal(cid)) + + // Query just by image name, without :latest tag + result = podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "-a", "--filter", "ancestor=quay.io/libpod/alpine"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(Equal(cid)) }) It("podman ps id filter flag", func() { diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index 08ab50de1..5ccefe285 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -41,21 +41,21 @@ var _ = Describe("Podman pull", func() { }) It("podman pull from docker with tag", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "busybox:glibc"}) + session := podmanTest.PodmanNoCache([]string{"pull", "quay.io/libpod/testdigest_v2s2:20200210"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "busybox:glibc"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "testdigest_v2s2:20200210"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull from docker without tag", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "busybox"}) + session := podmanTest.PodmanNoCache([]string{"pull", "quay.io/libpod/testdigest_v2s2"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "busybox"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "testdigest_v2s2"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) @@ -81,11 +81,11 @@ var _ = Describe("Podman pull", func() { }) It("podman pull by digest", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "alpine@sha256:1072e499f3f655a032e88542330cf75b02e7bdf673278f701d7ba61629ee3ebe"}) + session := podmanTest.PodmanNoCache([]string{"pull", "quay.io/libpod/testdigest_v2s2@sha256:755f4d90b3716e2bf57060d249e2cd61c9ac089b1233465c5c2cb2d7ee550fdb"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "alpine:none"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "testdigest_v2s2:none"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go index 7cb489113..cd62bf3b9 100644 --- a/test/e2e/rmi_test.go +++ b/test/e2e/rmi_test.go @@ -191,14 +191,14 @@ var _ = Describe("Podman rmi", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest RUN mkdir hello RUN touch test.txt ENV foo=bar ` podmanTest.BuildImage(dockerfile, "test", "true") - dockerfile = `FROM docker.io/library/alpine:latest + dockerfile = `FROM quay.io/libpod/alpine:latest RUN mkdir hello RUN touch test.txt RUN mkdir blah @@ -256,7 +256,7 @@ var _ = Describe("Podman rmi", func() { }) It("podman rmi -a with parent|child images", func() { - dockerfile := `FROM docker.io/library/alpine:latest AS base + dockerfile := `FROM quay.io/libpod/alpine:latest AS base RUN touch /1 ENV LOCAL=/1 RUN find $LOCAL diff --git a/test/e2e/run_entrypoint_test.go b/test/e2e/run_entrypoint_test.go index db802946e..2185d6b13 100644 --- a/test/e2e/run_entrypoint_test.go +++ b/test/e2e/run_entrypoint_test.go @@ -33,7 +33,7 @@ var _ = Describe("Podman run entrypoint", func() { }) It("podman run no command, entrypoint, or cmd", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest ENTRYPOINT [] CMD [] ` @@ -44,7 +44,7 @@ CMD [] }) It("podman run entrypoint", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] ` podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false") @@ -55,7 +55,7 @@ ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] }) It("podman run entrypoint with cmd", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest CMD [ "-v"] ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] ` @@ -67,7 +67,7 @@ ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] }) It("podman run entrypoint with user cmd overrides image cmd", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest CMD [ "-v"] ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] ` @@ -79,7 +79,7 @@ ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] }) It("podman run entrypoint with user cmd no image cmd", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] ` podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false") @@ -91,7 +91,7 @@ ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] It("podman run user entrypoint overrides image entrypoint and image cmd", func() { SkipIfRemote("FIXME: podman-remote not handling passing --entrypoint=\"\" flag correctly") - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest CMD ["-i"] ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] ` @@ -108,7 +108,7 @@ ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] }) It("podman run user entrypoint with command overrides image entrypoint and image cmd", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest CMD ["-i"] ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] ` diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 9f6fd8602..a3cc352b1 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -594,4 +594,39 @@ var _ = Describe("Podman run networking", func() { Expect(run.ExitCode()).To(BeZero()) Expect(strings.Contains(run.OutputToString(), hostname)).To(BeTrue()) }) + + It("podman run check dnsname plugin", func() { + pod := "testpod" + session := podmanTest.Podman([]string{"pod", "create", "--name", pod}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + + net := "dnsNetTest" + session = podmanTest.Podman([]string{"network", "create", net}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(net) + + pod2 := "testpod2" + session = podmanTest.Podman([]string{"pod", "create", "--network", net, "--name", pod2}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + + session = podmanTest.Podman([]string{"run", "--name", "con1", "--network", net, ALPINE, "nslookup", "con1"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + + session = podmanTest.Podman([]string{"run", "--name", "con2", "--pod", pod, "--network", net, ALPINE, "nslookup", "con2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + + session = podmanTest.Podman([]string{"run", "--name", "con3", "--pod", pod2, ALPINE, "nslookup", "con3"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(1)) + Expect(session.ErrorToString()).To(ContainSubstring("can't resolve 'con3'")) + + session = podmanTest.Podman([]string{"run", "--name", "con4", "--network", net, ALPINE, "nslookup", pod2}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + }) }) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index e6bba9f67..deb4419af 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -315,6 +315,39 @@ var _ = Describe("Podman run", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.OutputToString()).To(ContainSubstring("00000000a80425fb")) + + session = podmanTest.Podman([]string{"run", "--user=1000:1000", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("0000000000000002")) + + session = podmanTest.Podman([]string{"run", "--user=1000:1000", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) + + session = podmanTest.Podman([]string{"run", "--user=0", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) + + session = podmanTest.Podman([]string{"run", "--user=0:0", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) + + if os.Geteuid() > 0 { + if os.Getenv("SKIP_USERNS") != "" { + Skip("Skip userns tests.") + } + if _, err := os.Stat("/proc/self/uid_map"); err != nil { + Skip("User namespaces not supported.") + } + session = podmanTest.Podman([]string{"run", "--userns=keep-id", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("0000000000000002")) + } }) It("podman run user capabilities test with image", func() { diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index 79fc4d737..bdaef9259 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -134,7 +134,7 @@ var _ = Describe("Podman save", func() { defer os.Setenv("GNUPGHOME", origGNUPGHOME) port := 5000 - session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", strings.Join([]string{strconv.Itoa(port), strconv.Itoa(port)}, ":"), "docker.io/registry:2.6"}) + session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", strings.Join([]string{strconv.Itoa(port), strconv.Itoa(port)}, ":"), "quay.io/libpod/registry:2.6"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) { diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index 4f2751099..424a191c5 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -460,4 +460,11 @@ registries = ['{{.Host}}:{{.Port}}']` search.WaitWithDefaultTimeout() Expect(len(search.OutputToStringArray()) == 0).To(BeTrue()) }) + + It("podman search with limit over 100", func() { + search := podmanTest.Podman([]string{"search", "--limit", "130", "registry.redhat.io/rhel"}) + search.WaitWithDefaultTimeout() + Expect(search.ExitCode()).To(Equal(0)) + Expect(len(search.OutputToStringArray())).To(Equal(131)) + }) }) diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go index 218c250cd..48294943b 100644 --- a/test/e2e/systemd_test.go +++ b/test/e2e/systemd_test.go @@ -59,7 +59,7 @@ WantedBy=multi-user.target Expect(stop.ExitCode()).To(Equal(0)) }() - create := podmanTest.Podman([]string{"create", "--name", "redis", "redis"}) + create := podmanTest.Podman([]string{"create", "--name", "redis", redis}) create.WaitWithDefaultTimeout() Expect(create.ExitCode()).To(Equal(0)) diff --git a/test/e2e/tag_test.go b/test/e2e/tag_test.go index 72d5cad77..3b43b0e20 100644 --- a/test/e2e/tag_test.go +++ b/test/e2e/tag_test.go @@ -41,7 +41,7 @@ var _ = Describe("Podman tag", func() { results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) inspectData := results.InspectImageJSON() - Expect(StringInSlice("docker.io/library/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) + Expect(StringInSlice("quay.io/libpod/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) Expect(StringInSlice("localhost/foobar:latest", inspectData[0].RepoTags)).To(BeTrue()) }) @@ -54,7 +54,7 @@ var _ = Describe("Podman tag", func() { results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) inspectData := results.InspectImageJSON() - Expect(StringInSlice("docker.io/library/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) + Expect(StringInSlice("quay.io/libpod/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) Expect(StringInSlice("localhost/foobar:latest", inspectData[0].RepoTags)).To(BeTrue()) }) @@ -67,7 +67,7 @@ var _ = Describe("Podman tag", func() { results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) inspectData := results.InspectImageJSON() - Expect(StringInSlice("docker.io/library/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) + Expect(StringInSlice("quay.io/libpod/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) Expect(StringInSlice("localhost/foobar:new", inspectData[0].RepoTags)).To(BeTrue()) }) diff --git a/test/e2e/toolbox_test.go b/test/e2e/toolbox_test.go index fbff8d19e..822159fc2 100644 --- a/test/e2e/toolbox_test.go +++ b/test/e2e/toolbox_test.go @@ -30,10 +30,12 @@ import ( "os" "os/exec" "os/user" + "path" "strconv" "strings" "syscall" + "github.com/containers/podman/v2/pkg/rootless" . "github.com/containers/podman/v2/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -371,10 +373,23 @@ var _ = Describe("Toolbox-specific testing", func() { currentUser, err := user.Current() Expect(err).To(BeNil()) + session = podmanTest.Podman([]string{"run", "-v", fmt.Sprintf("%s:%s", currentUser.HomeDir, currentUser.HomeDir), "--userns=keep-id", fedoraToolbox, "sh", "-c", "echo $HOME"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.OutputToString()).To(ContainSubstring(currentUser.HomeDir)) + + if rootless.IsRootless() { + location := path.Dir(currentUser.HomeDir) + volumeArg := fmt.Sprintf("%s:%s", location, location) + session = podmanTest.Podman([]string{"run", + "--userns=keep-id", + "--volume", volumeArg, + fedoraToolbox, "sh", "-c", "echo $HOME"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring(currentUser.HomeDir)) + } }) }) diff --git a/test/e2e/tree_test.go b/test/e2e/tree_test.go index eeb00440c..22d53a8ea 100644 --- a/test/e2e/tree_test.go +++ b/test/e2e/tree_test.go @@ -35,7 +35,7 @@ var _ = Describe("Podman image tree", func() { It("podman image tree", func() { SkipIfRemote("Does not work on remote client") - dockerfile := `FROM docker.io/library/busybox:latest + dockerfile := `FROM quay.io/libpod/busybox:latest RUN mkdir hello RUN touch test.txt ENV foo=bar @@ -45,14 +45,14 @@ ENV foo=bar session := podmanTest.PodmanNoCache([]string{"image", "tree", "test:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"image", "tree", "--whatrequires", "docker.io/library/busybox:latest"}) + session = podmanTest.PodmanNoCache([]string{"image", "tree", "--whatrequires", "quay.io/libpod/busybox:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.PodmanNoCache([]string{"rmi", "test:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "docker.io/library/busybox:latest"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "quay.io/libpod/busybox:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/volume_ls_test.go b/test/e2e/volume_ls_test.go index 1cb6440aa..cda118bf1 100644 --- a/test/e2e/volume_ls_test.go +++ b/test/e2e/volume_ls_test.go @@ -110,4 +110,27 @@ var _ = Describe("Podman volume ls", func() { Expect(lsDangling.ExitCode()).To(Equal(0)) Expect(lsDangling.OutputToString()).To(ContainSubstring(volName1)) }) + It("podman ls volume with multiple --filter flag", func() { + session := podmanTest.Podman([]string{"volume", "create", "--label", "foo=bar", "myvol"}) + volName := session.OutputToString() + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"volume", "create", "--label", "foo2=bar2", "anothervol"}) + anotherVol := session.OutputToString() + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"volume", "create"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo", "--filter", "label=foo2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(3)) + Expect(session.OutputToStringArray()[1]).To(ContainSubstring(volName)) + Expect(session.OutputToStringArray()[2]).To(ContainSubstring(anotherVol)) + + }) }) diff --git a/test/registries.conf b/test/registries.conf index f27a282d6..0559c9e52 100644 --- a/test/registries.conf +++ b/test/registries.conf @@ -1,10 +1,17 @@ # Note that changing the order here may break tests. -[registries.search] -registries = ['docker.io', 'quay.io', 'registry.fedoraproject.org'] +unqualified-search-registries = ['docker.io', 'quay.io', 'registry.fedoraproject.org'] -[registries.insecure] -registries = [] +[[registry]] +# In Nov. 2020, Docker rate-limits image pulling. To avoid hitting these +# limits while testing, always use the google mirror for qualified and +# unqualified `docker.io` images. +# Ref: https://cloud.google.com/container-registry/docs/pulling-cached-images +prefix="docker.io" +location="mirror.gcr.io" -#blocked (docker only) -[registries.block] -registries = [] +# 2020-10-27 a number of images are not present in gcr.io, and podman +# barfs spectacularly when trying to fetch them. We've hand-copied +# those to quay, using skopeo copy --all ... +[[registry]] +prefix="docker.io/library" +location="quay.io/libpod" diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 8712dc72d..b0c855d81 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -14,8 +14,8 @@ load helpers # ...but check the configured runtime engine, and switch to crun as needed run_podman info --format '{{ .Host.OCIRuntime.Path }}' if expr "$output" : ".*/crun"; then - err_no_such_cmd="Error: executable file.* not found in \$PATH: No such file or directory: OCI runtime command not found error" - err_no_exec_dir="Error: open executable: Operation not permitted: OCI runtime permission denied error" + err_no_such_cmd="Error: executable file.* not found in \$PATH: No such file or directory: OCI not found" + err_no_exec_dir="Error: open executable: Operation not permitted: OCI permission denied" fi tests=" @@ -413,6 +413,17 @@ json-file | f else is "$output" "" "LogPath (driver=$driver)" fi + + if [[ $driver != 'none' ]]; then + run_podman logs myctr + is "$output" "$msg" "check that podman logs works as expected" + else + run_podman 125 logs myctr + if ! is_remote; then + is "$output" ".*this container is using the 'none' log driver, cannot read logs.*" \ + "podman logs does not work with none log driver" + fi + fi run_podman rm myctr done < <(parse_table "$tests") @@ -462,34 +473,53 @@ json-file | f # run with --runtime should preserve the named runtime @test "podman run : full path to --runtime is preserved" { - skip_if_cgroupsv1 - skip_if_remote - run_podman run -d --runtime '/usr/bin/crun' $IMAGE sleep 60 + skip_if_remote "podman-remote does not support --runtime option" + + # Get configured runtime + run_podman info --format '{{.Host.OCIRuntime.Path}}' + runtime="$output" + + # Assumes that /var/tmp is not mounted noexec; this is usually safe + new_runtime="/var/tmp/myruntime$(random_string 12)" + cp --preserve $runtime $new_runtime + + run_podman run -d --runtime "$new_runtime" $IMAGE sleep 60 cid="$output" run_podman inspect --format '{{.OCIRuntime}}' $cid - is "$output" "/usr/bin/crun" - + is "$output" "$new_runtime" "podman inspect shows configured runtime" run_podman kill $cid + run_podman rm $cid + rm -f $new_runtime } # Regression test for issue #8082 @test "podman run : look up correct image name" { - # Create a 2nd tag for the local image. - local name="localhost/foo/bar" - run_podman tag $IMAGE $name + # Create a 2nd tag for the local image. Force to lower case, and apply it. + local newtag="localhost/$(random_string 10)/$(random_string 8)" + newtag=${newtag,,} + run_podman tag $IMAGE $newtag + + # Create a container with the 2nd tag and make sure that it's being + # used. #8082 always inaccurately used the 1st tag. + run_podman create $newtag + cid="$output" + + run_podman inspect --format "{{.ImageName}}" $cid + is "$output" "$newtag" "container .ImageName is the container-create name" - # Create a container with the 2nd tag and make sure that it's being - # used. #8082 always inaccurately used the 1st tag. - run_podman create $name - cid="$output" + # Same thing, but now with a :tag, and making sure it works with --name + newtag2="${newtag}:$(random_string 6|tr A-Z a-z)" + run_podman tag $IMAGE $newtag2 - run_podman inspect --format "{{.ImageName}}" $cid - is "$output" "$name" + cname="$(random_string 14|tr A-Z a-z)" + run_podman create --name $cname $newtag2 + run_podman inspect --format "{{.ImageName}}" $cname + is "$output" "$newtag2" "container .ImageName is the container-create name" - # Clean up. - run_podman rm $cid - run_podman untag $IMAGE $name + # Clean up. + run_podman rm $cid $cname + run_podman untag $IMAGE $newtag $newtag2 } # vim: filetype=sh diff --git a/test/system/060-mount.bats b/test/system/060-mount.bats index ece87acf6..73d210084 100644 --- a/test/system/060-mount.bats +++ b/test/system/060-mount.bats @@ -78,4 +78,77 @@ load helpers is "$output" "" "podman image mount, no args, after umount" } +@test "podman run --mount image" { + skip_if_rootless "too hard to test rootless" + + # Run a container with an image mount + run_podman run --rm --mount type=image,src=$IMAGE,dst=/image-mount $IMAGE diff /etc/os-release /image-mount/etc/os-release + + # Make sure the mount is read only + run_podman 1 run --rm --mount type=image,src=$IMAGE,dst=/image-mount $IMAGE touch /image-mount/read-only + is "$output" "touch: /image-mount/read-only: Read-only file system" + + # Make sure that rw,readwrite work + run_podman run --rm --mount type=image,src=$IMAGE,dst=/image-mount,rw=true $IMAGE touch /image-mount/readwrite + run_podman run --rm --mount type=image,src=$IMAGE,dst=/image-mount,readwrite=true $IMAGE touch /image-mount/readwrite + + skip_if_remote "mounting remote is meaningless" + + # The mount should be cleaned up during container removal as no other entity mounted the image + run_podman image umount $IMAGE + is "$output" "" "image mount should have been cleaned up during container removal" + + # Now make sure that the image mount is not cleaned up during container removal when another entity mounted the image + run_podman image mount $IMAGE + run_podman run --rm --mount type=image,src=$IMAGE,dst=/image-mount $IMAGE diff /etc/os-release /image-mount/etc/os-release + + run_podman image inspect --format '{{.ID}}' $IMAGE + iid="$output" + + run_podman image umount $IMAGE + is "$output" "$iid" "podman image umount: image ID of what was umounted" + + run_podman image umount $IMAGE + is "$output" "" "image mount should have been cleaned up via 'image umount'" + + # Run a container in the background (source is the ID instead of name) + run_podman run -d --mount type=image,src=$iid,dst=/image-mount,readwrite=true $IMAGE sleep infinity + cid="$output" + + # Unmount the image + run_podman image umount $IMAGE + is "$output" "$iid" "podman image umount: image ID of what was umounted" + run_podman image umount $IMAGE + is "$output" "" "image mount should have been cleaned up via 'image umount'" + + # Make sure that the mount in the container is unaffected + run_podman exec $cid diff /etc/os-release /image-mount/etc/os-release + run_podman exec $cid find /image-mount/etc/ + + # Clean up + run_podman rm -f $cid +} + +@test "podman run --mount image inspection" { + skip_if_rootless "too hard to test rootless" + + # Run a container in the background + run_podman run -d --mount type=image,src=$IMAGE,dst=/image-mount,rw=true $IMAGE sleep infinity + cid="$output" + + run_podman inspect --format "{{(index .Mounts 0).Type}}" $cid + is "$output" "image" "inspect data includes image mount type" + + run_podman inspect --format "{{(index .Mounts 0).Source}}" $cid + is "$output" "$IMAGE" "inspect data includes image mount source" + + run_podman inspect --format "{{(index .Mounts 0).Destination}}" $cid + is "$output" "/image-mount" "inspect data includes image mount source" + + run_podman inspect --format "{{(index .Mounts 0).RW}}" $cid + is "$output" "true" "inspect data includes image mount source" + + run_podman rm -f $cid +} + # vim: filetype=sh diff --git a/test/system/065-cp.bats b/test/system/065-cp.bats index a350c2173..6bf897790 100644 --- a/test/system/065-cp.bats +++ b/test/system/065-cp.bats @@ -148,7 +148,7 @@ load helpers is "$output" "" "output from podman cp 1" run_podman 125 cp --pause=false $srcdir/$rand_filename2 cpcontainer:/tmp/d2/x/ - is "$output" "Error: failed to get stat of dest path .*stat.* no such file or directory" "cp will not create nonexistent destination directory" + is "$output" ".*stat.* no such file or directory" "cp will not create nonexistent destination directory" run_podman cp --pause=false $srcdir/$rand_filename3 cpcontainer:/tmp/d3/x is "$output" "" "output from podman cp 3" diff --git a/test/system/090-events.bats b/test/system/090-events.bats new file mode 100644 index 000000000..8a9db41fa --- /dev/null +++ b/test/system/090-events.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats -*- bats -*- +# +# tests for podman events functionality +# + +load helpers + +@test "events with a filter by label" { + skip_if_remote "FIXME: -remote does not include labels in event output" + cname=test-$(random_string 30 | tr A-Z a-z) + labelname=$(random_string 10) + labelvalue=$(random_string 15) + + run_podman run --label $labelname=$labelvalue --name $cname --rm $IMAGE ls + + expect=".* container start [0-9a-f]\+ (image=$IMAGE, name=$cname,.* ${labelname}=${labelvalue}" + run_podman events --filter type=container --filter container=$cname --filter label=${labelname}=${labelvalue} --filter event=start --stream=false + is "$output" "$expect" "filtering by container name and label" + + # Same thing, but without the container-name filter + run_podman events --filter type=container --filter label=${labelname}=${labelvalue} --filter event=start --stream=false + is "$output" "$expect" "filtering just by label" + + # Now filter just by container name, no label + run_podman events --filter type=container --filter container=$cname --filter event=start --stream=false + is "$output" "$expect" "filtering just by label" +} diff --git a/test/system/160-volumes.bats b/test/system/160-volumes.bats index 9f4bb76a2..c19e61669 100644 --- a/test/system/160-volumes.bats +++ b/test/system/160-volumes.bats @@ -119,7 +119,7 @@ EOF # noexec option. This should fail. # ARGH. Unfortunately, runc (used for cgroups v1) produces a different error local expect_rc=126 - local expect_msg='.* OCI runtime permission denied.*' + local expect_msg='.* OCI permission denied.*' run_podman info --format '{{ .Host.OCIRuntime.Path }}' if expr "$output" : ".*/runc"; then expect_rc=1 diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats index 1d17c8cad..b0f645c53 100644 --- a/test/system/200-pod.bats +++ b/test/system/200-pod.bats @@ -116,6 +116,30 @@ function teardown() { run_podman 1 pod exists $podname } +@test "podman pod - communicating via /dev/shm " { + if is_remote && is_rootless; then + skip "FIXME: pending #7139" + fi + + podname=pod$(random_string) + run_podman 1 pod exists $podname + run_podman pod create --infra=true --name=$podname + podid="$output" + run_podman pod exists $podname + run_podman pod exists $podid + + run_podman run --rm --pod $podname $IMAGE touch /dev/shm/test1 + run_podman run --rm --pod $podname $IMAGE ls /dev/shm/test1 + is "$output" "/dev/shm/test1" + + # ...then rm the pod, then rmi the pause image so we don't leave strays. + run_podman pod rm $podname + + # Pod no longer exists + run_podman 1 pod exists $podid + run_podman 1 pod exists $podname +} + # Random byte function octet() { echo $(( $RANDOM & 255 )) diff --git a/test/utils/utils.go b/test/utils/utils.go index a45ce7b36..dd836f258 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -14,7 +14,7 @@ import ( "github.com/containers/storage/pkg/parsers/kernel" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/onsi/gomega/gexec" + . "github.com/onsi/gomega/gexec" ) var ( @@ -48,7 +48,7 @@ type PodmanTest struct { // PodmanSession wraps the gexec.session so we can extend it type PodmanSession struct { - *gexec.Session + *Session } // HostOS is a simple struct for the test os @@ -96,7 +96,7 @@ func (p *PodmanTest) PodmanAsUserBase(args []string, uid, gid uint32, cwd string command.ExtraFiles = extraFiles - session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) + session, err := Start(command, GinkgoWriter, GinkgoWriter) if err != nil { Fail(fmt.Sprintf("unable to run podman command: %s\n%v", strings.Join(podmanOptions, " "), err)) } @@ -125,7 +125,7 @@ func (p *PodmanTest) NumberOfContainersRunning() int { var containers []string ps := p.PodmanBase([]string{"ps", "-q"}, false, true) ps.WaitWithDefaultTimeout() - Expect(ps.ExitCode()).To(Equal(0)) + Expect(ps).Should(Exit(0)) for _, i := range ps.OutputToStringArray() { if i != "" { containers = append(containers, i) @@ -302,12 +302,7 @@ func (s *PodmanSession) LineInOutputContains(term string) bool { // by podman-images(1). func (s *PodmanSession) LineInOutputContainsTag(repo, tag string) bool { tagMap := tagOutputToMap(s.OutputToStringArray()) - for r, t := range tagMap { - if repo == r && tag == t { - return true - } - } - return false + return tagMap[repo][tag] } // IsJSONOutputValid attempts to unmarshal the session buffer @@ -323,7 +318,7 @@ func (s *PodmanSession) IsJSONOutputValid() bool { // WaitWithDefaultTimeout waits for process finished with defaultWaitTimeout func (s *PodmanSession) WaitWithDefaultTimeout() { - Eventually(s, defaultWaitTimeout).Should(gexec.Exit()) + Eventually(s, defaultWaitTimeout).Should(Exit()) os.Stdout.Sync() os.Stderr.Sync() fmt.Println("output:", s.OutputToString()) @@ -337,7 +332,7 @@ func CreateTempDirInTempDir() (string, error) { // SystemExec is used to exec a system command to check its exit code or output func SystemExec(command string, args []string) *PodmanSession { c := exec.Command(command, args...) - session, err := gexec.Start(c, GinkgoWriter, GinkgoWriter) + session, err := Start(c, GinkgoWriter, GinkgoWriter) if err != nil { Fail(fmt.Sprintf("unable to run command: %s %s", command, strings.Join(args, " "))) } @@ -348,7 +343,7 @@ func SystemExec(command string, args []string) *PodmanSession { // StartSystemExec is used to start exec a system command func StartSystemExec(command string, args []string) *PodmanSession { c := exec.Command(command, args...) - session, err := gexec.Start(c, GinkgoWriter, GinkgoWriter) + session, err := Start(c, GinkgoWriter, GinkgoWriter) if err != nil { Fail(fmt.Sprintf("unable to run command: %s %s", command, strings.Join(args, " "))) } @@ -366,10 +361,11 @@ func StringInSlice(s string, sl []string) bool { } // tagOutPutToMap parses each string in imagesOutput and returns -// a map of repo:tag pairs. Notice, the first array item will +// a map whose key is a repo, and value is another map whose keys +// are the tags found for that repo. Notice, the first array item will // be skipped as it's considered to be the header. -func tagOutputToMap(imagesOutput []string) map[string]string { - m := make(map[string]string) +func tagOutputToMap(imagesOutput []string) map[string]map[string]bool { + m := make(map[string]map[string]bool) // iterate over output but skip the header for _, i := range imagesOutput[1:] { tmp := []string{} @@ -383,7 +379,10 @@ func tagOutputToMap(imagesOutput []string) map[string]string { if len(tmp) < 2 { continue } - m[tmp[0]] = tmp[1] + if m[tmp[0]] == nil { + m[tmp[0]] = map[string]bool{} + } + m[tmp[0]][tmp[1]] = true } return m } |