diff options
Diffstat (limited to 'test')
149 files changed, 1475 insertions, 588 deletions
diff --git a/test/apiv2/10-images.at b/test/apiv2/10-images.at index a650cf958..f866422e2 100644 --- a/test/apiv2/10-images.at +++ b/test/apiv2/10-images.at @@ -41,7 +41,7 @@ t GET images/$iid/json 200 \ .Id=sha256:$iid \ .RepoTags[0]=$IMAGE -t POST "images/create?fromImage=alpine" '' 200 .error=null .status~".*Download complete.*" +t POST "images/create?fromImage=alpine" '' 200 .error~null .status~".*Download complete.*" t POST "images/create?fromImage=alpine&tag=latest" '' 200 @@ -49,7 +49,7 @@ t POST "images/create?fromImage=alpine&tag=latest" '' 200 old_iid=$(podman image inspect --format "{{.ID}}" docker.io/library/alpine:latest) podman rmi -f docker.io/library/alpine:latest podman tag $IMAGE docker.io/library/alpine:latest -t POST "images/create?fromImage=alpine" '' 200 .error=null .status~".*$old_iid.*" +t POST "images/create?fromImage=alpine" '' 200 .error~null .status~".*$old_iid.*" podman untag $IMAGE docker.io/library/alpine:latest t POST "images/create?fromImage=quay.io/libpod/alpine&tag=sha256:fa93b01658e3a5a1686dc3ae55f170d8de487006fb53a28efcd12ab0710a2e5f" '' 200 diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at index a99e9a184..4b40fde80 100644 --- a/test/apiv2/20-containers.at +++ b/test/apiv2/20-containers.at @@ -206,9 +206,9 @@ t GET 'containers/json?limit=0&all=1' 200 \ t GET containers/json?limit=2 200 length=2 # Filter with two ids should return both container -t GET "containers/json?filters=%7B%22id%22%3A%5B%22${cid}%22%2C%22${cid_top}%22%5D%7D&all=1" 200 length=2 +t GET containers/json?filters='{"id":["'${cid}'","'${cid_top}'"]}&all=1' 200 length=2 # Filter with two ids and status running should return only 1 container -t GET "containers/json?filters=%7B%22id%22%3A%5B%22${cid}%22%2C%22${cid_top}%22%5D%2C%22status%22%3A%5B%22running%22%5D%7D&all=1" 200 \ +t GET containers/json?filters='{"id":["'${cid}'","'${cid_top}'"],"status":["running"]}&all=1' 200 \ length=1 \ .[0].Id=${cid_top} @@ -246,3 +246,13 @@ t GET containers/$cid/json 200 \ .Mounts[0].Destination="/test" t DELETE containers/$cid?v=true 204 + +# test port mapping +podman run -d --rm --name bar -p 8080:9090 $IMAGE top + +t GET containers/json 200 \ + .[0].Ports[0].PrivatePort=9090 \ + .[0].Ports[0].PublicPort=8080 \ + .[0].Ports[0].Type="tcp" + +podman stop bar diff --git a/test/apiv2/30-volumes.at b/test/apiv2/30-volumes.at index b38810039..cf4b3d3ea 100644 --- a/test/apiv2/30-volumes.at +++ b/test/apiv2/30-volumes.at @@ -45,18 +45,17 @@ 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":["nonexistent"]}' -t GET libpod/volumes/json?filters=%7B%22name%22%3A%5B%22nonexistent%22%5D%7D 200 length=0 -# -G --data-urlencode 'filters={"label":["testlabel"]}' -t GET libpod/volumes/json?filters=%7B%22label%22:%5B%22testlabel%22%5D%7D 200 length=2 -# -G --data-urlencode 'filters={"label":["testlabel=testonly"]}' -t GET libpod/volumes/json?filters=%7B%22label%22:%5B%22testlabel=testonly%22%5D%7D 200 length=1 -# -G --data-urlencode 'filters={"label":["testlabel1=testonly"]}' -t GET libpod/volumes/json?filters=%7B%22label%22:%5B%22testlabel1=testonly%22%5D%7D 200 length=1 +t GET libpod/volumes/json?filters='{"name":["foo1"]}' 200 \ + length=1 \ + .[0].Name=foo1 +t GET libpod/volumes/json?filters='{"name":%20["foo1",%20"foo2"]}' 200 \ + length=2 \ + .[0].Name=foo1 \ + .[1].Name=foo2 +t GET libpod/volumes/json?filters='{"name":["nonexistent"]}' 200 length=0 +t GET libpod/volumes/json?filters='{"label":["testlabel"]}' 200 length=2 +t GET libpod/volumes/json?filters='{"label":["testlabel=testonly"]}' 200 length=1 +t GET libpod/volumes/json?filters='{"label":["testlabel1=testonly"]}' 200 length=1 ## inspect volume t GET libpod/volumes/foo1/json 200 \ @@ -79,16 +78,12 @@ t DELETE libpod/volumes/foo1 404 \ .response=404 ## Prune volumes with label matching 'testlabel1=testonly' -# -G --data-urlencode 'filters={"label":["testlabel1=testonly"]}' -t POST libpod/volumes/prune?filters=%7B%22label%22:%5B%22testlabel1=testonly%22%5D%7D "" 200 -# -G --data-urlencode 'filters={"label":["testlabel1=testonly"]}' -t GET libpod/volumes/json?filters=%7B%22label%22:%5B%22testlabel1=testonly%22%5D%7D 200 length=0 +t POST libpod/volumes/prune?filters='{"label":["testlabel1=testonly"]}' "" 200 +t GET libpod/volumes/json?filters='{"label":["testlabel1=testonly"]}' 200 length=0 ## Prune volumes with label matching 'testlabel' -# -G --data-urlencode 'filters={"label":["testlabel"]}' -t POST libpod/volumes/prune?filters=%7B%22label%22:%5B%22testlabel%22%5D%7D "" 200 -# -G --data-urlencode 'filters={"label":["testlabel"]}' -t GET libpod/volumes/json?filters=%7B%22label%22:%5B%22testlabel%22%5D%7D 200 length=0 +t POST libpod/volumes/prune?filters='{"label":["testlabel"]}' "" 200 +t GET libpod/volumes/json?filters='{"label":["testlabel"]}' 200 length=0 ## Prune volumes t POST libpod/volumes/prune "" 200 diff --git a/test/apiv2/35-networks.at b/test/apiv2/35-networks.at index 7ce109913..d3bbaf32b 100644 --- a/test/apiv2/35-networks.at +++ b/test/apiv2/35-networks.at @@ -7,54 +7,52 @@ t GET networks/non-existing-network 404 \ .cause='network not found' t POST libpod/networks/create?name=network1 '' 200 \ -.Filename~.*/network1\\.conflist + .Filename~.*/network1\\.conflist # --data '{"Subnet":{"IP":"10.10.254.0","Mask":[255,255,255,0]},"Labels":{"abc":"val"}}' t POST libpod/networks/create?name=network2 '"Subnet":{"IP":"10.10.254.0","Mask":[255,255,255,0]},"Labels":{"abc":"val"}' 200 \ -.Filename~.*/network2\\.conflist + .Filename~.*/network2\\.conflist # test for empty mask t POST libpod/networks/create '"Subnet":{"IP":"10.10.1.0","Mask":[]}' 500 \ -.cause~'.*cannot be empty' + .cause~'.*cannot be empty' # test for invalid mask t POST libpod/networks/create '"Subnet":{"IP":"10.10.1.0","Mask":[0,255,255,0]}' 500 \ -.cause~'.*mask is invalid' + .cause~'.*mask is invalid' # network list t GET libpod/networks/json 200 -# filters={"name":["network1"]} -t GET libpod/networks/json?filters=%7B%22name%22%3A%5B%22network1%22%5D%7D 200 \ -length=1 \ -.[0].Name=network1 +t GET libpod/networks/json?filters='{"name":["network1"]}' 200 \ + length=1 \ + .[0].Name=network1 t GET networks 200 #network list docker endpoint -#filters={"name":["network1","network2"]} -t GET networks?filters=%7B%22name%22%3A%5B%22network1%22%2C%22network2%22%5D%7D 200 \ -length=2 -#filters={"name":["network"]} -t GET networks?filters=%7B%22name%22%3A%5B%22network%22%5D%7D 200 \ -length=2 -# filters={"label":["abc"]} -t GET networks?filters=%7B%22label%22%3A%5B%22abc%22%5D%7D 200 \ -length=1 -# id filter filters={"id":["a7662f44d65029fd4635c91feea3d720a57cef52e2a9fcc7772b69072cc1ccd1"]} -t GET networks?filters=%7B%22id%22%3A%5B%22a7662f44d65029fd4635c91feea3d720a57cef52e2a9fcc7772b69072cc1ccd1%22%5D%7D 200 \ -length=1 \ -.[0].Name=network1 \ -.[0].Id=a7662f44d65029fd4635c91feea3d720a57cef52e2a9fcc7772b69072cc1ccd1 -# invalid filter filters={"dangling":["1"]} -t GET networks?filters=%7B%22dangling%22%3A%5B%221%22%5D%7D 500 \ -.cause='invalid filter "dangling"' +t GET networks?filters='{"name":["network1","network2"]}' 200 \ + length=2 +t GET networks?filters='{"name":["network"]}' 200 \ + length=2 +t GET networks?filters='{"label":["abc"]}' 200 \ + length=1 +# old docker filter type see #9526 +t GET networks?filters='{"label":{"abc":true}}' 200 \ + length=1 +t GET networks?filters='{"id":["a7662f44d65029fd4635c91feea3d720a57cef52e2a9fcc7772b69072cc1ccd1"]}' 200 \ + length=1 \ + .[0].Name=network1 \ + .[0].Id=a7662f44d65029fd4635c91feea3d720a57cef52e2a9fcc7772b69072cc1ccd1 +# invalid filter +t GET networks?filters='{"dangling":["1"]}' 500 \ + .cause='invalid filter "dangling"' # (#9293 with no networks the endpoint should return empty array instead of null) -t GET networks?filters=%7B%22name%22%3A%5B%22doesnotexists%22%5D%7D 200 \ -"[]" +t GET networks?filters='{"name":["doesnotexists"]}' 200 \ + "[]" # network inspect docker t GET networks/a7662f44d65029fd4635c91feea3d720a57cef52e2a9fcc7772b69072cc1ccd1 200 \ -.Name=network1 \ -.Id=a7662f44d65029fd4635c91feea3d720a57cef52e2a9fcc7772b69072cc1ccd1 \ -.Scope=local + .Name=network1 \ + .Id=a7662f44d65029fd4635c91feea3d720a57cef52e2a9fcc7772b69072cc1ccd1 \ + .Scope=local # network create docker t POST networks/create '"Name":"net3","IPAM":{"Config":[]}' 201 @@ -63,11 +61,11 @@ t DELETE networks/net3 204 # clean the network t DELETE libpod/networks/network1 200 \ -.[0].Name~network1 \ -.[0].Err=null + .[0].Name~network1 \ + .[0].Err=null t DELETE libpod/networks/network2 200 \ -.[0].Name~network2 \ -.[0].Err=null + .[0].Name~network2 \ + .[0].Err=null # vim: filetype=sh diff --git a/test/apiv2/45-system.at b/test/apiv2/45-system.at index 985d86e56..ad4bdf4f7 100644 --- a/test/apiv2/45-system.at +++ b/test/apiv2/45-system.at @@ -49,18 +49,16 @@ t GET libpod/system/df 200 '.Volumes | length=3' # Prune volumes -# -G --data-urlencode 'volumes=true&filters={"label":["testlabel1=idontmatch"]}' -t POST 'libpod/system/prune?volumes=true&filters=%7B%22label%22:%5B%22testlabel1=idontmatch%22%5D%7D' params='' 200 +t POST 'libpod/system/prune?volumes=true&filters={"label":["testlabel1=idontmatch"]}' params='' 200 # nothing should have been pruned t GET system/df 200 '.Volumes | length=3' t GET libpod/system/df 200 '.Volumes | length=3' -# -G --data-urlencode 'volumes=true&filters={"label":["testlabel1=testonly"]}' # only foo3 should be pruned because of filter -t POST 'libpod/system/prune?volumes=true&filters=%7B%22label%22:%5B%22testlabel1=testonly%22%5D%7D' params='' 200 .VolumePruneReports[0].Id=foo3 +t POST 'libpod/system/prune?volumes=true&filters={"label":["testlabel1=testonly"]}' params='' 200 .VolumePruneReports[0].Id=foo3 # only foo2 should be pruned because of filter -t POST 'libpod/system/prune?volumes=true&filters=%7B%22label%22:%5B%22testlabel1%22%5D%7D' params='' 200 .VolumePruneReports[0].Id=foo2 +t POST 'libpod/system/prune?volumes=true&filters={"label":["testlabel1"]}' params='' 200 .VolumePruneReports[0].Id=foo2 # foo1, the last remaining volume should be pruned without any filters applied t POST 'libpod/system/prune?volumes=true' params='' 200 .VolumePruneReports[0].Id=foo1 diff --git a/test/apiv2/50-secrets.at b/test/apiv2/50-secrets.at index 1ef43381a..69e1f3ae9 100644 --- a/test/apiv2/50-secrets.at +++ b/test/apiv2/50-secrets.at @@ -25,7 +25,7 @@ t GET secrets 200\ length=1 # secret list unsupported filters -t GET secrets?filters=%7B%22name%22%3A%5B%22foo1%22%5D%7D 400 +t GET secrets?filters='{"name":["foo1"]}' 400 # secret rm t DELETE secrets/mysecret 204 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 05c24f2ea..8a78f5185 100644 --- a/test/apiv2/rest_api/test_rest_v2_0_0.py +++ b/test/apiv2/rest_api/test_rest_v2_0_0.py @@ -64,7 +64,9 @@ class TestApi(unittest.TestCase): super().setUpClass() TestApi.podman = Podman() - TestApi.service = TestApi.podman.open("system", "service", "tcp:localhost:8080", "--time=0") + TestApi.service = TestApi.podman.open( + "system", "service", "tcp:localhost:8080", "--time=0" + ) # give the service some time to be ready... time.sleep(2) @@ -241,7 +243,9 @@ class TestApi(unittest.TestCase): def test_post_create_compat(self): """Create network and connect container during create""" - net = requests.post(PODMAN_URL + "/v1.40/networks/create", json={"Name": "TestNetwork"}) + net = requests.post( + PODMAN_URL + "/v1.40/networks/create", json={"Name": "TestNetwork"} + ) self.assertEqual(net.status_code, 201, net.text) create = requests.post( @@ -450,11 +454,15 @@ class TestApi(unittest.TestCase): self.assertIn(k, o) def test_network_compat(self): - name = "Network_" + "".join(random.choice(string.ascii_letters) for i in range(10)) + name = "Network_" + "".join( + random.choice(string.ascii_letters) for i in range(10) + ) # Cannot test for 0 existing networks because default "podman" network always exists - create = requests.post(PODMAN_URL + "/v1.40/networks/create", json={"Name": name}) + create = requests.post( + PODMAN_URL + "/v1.40/networks/create", json={"Name": name} + ) self.assertEqual(create.status_code, 201, create.content) obj = json.loads(create.content) self.assertIn(type(obj), (dict,)) @@ -484,8 +492,12 @@ class TestApi(unittest.TestCase): self.assertEqual(inspect.status_code, 404, inspect.content) # network prune - prune_name = "Network_" + "".join(random.choice(string.ascii_letters) for i in range(10)) - prune_create = requests.post(PODMAN_URL + "/v1.40/networks/create", json={"Name": prune_name}) + prune_name = "Network_" + "".join( + random.choice(string.ascii_letters) for i in range(10) + ) + prune_create = requests.post( + PODMAN_URL + "/v1.40/networks/create", json={"Name": prune_name} + ) self.assertEqual(create.status_code, 201, prune_create.content) prune = requests.post(PODMAN_URL + "/v1.40/networks/prune") @@ -493,9 +505,10 @@ class TestApi(unittest.TestCase): obj = json.loads(prune.content) self.assertTrue(prune_name in obj["NetworksDeleted"]) - def test_volumes_compat(self): - name = "Volume_" + "".join(random.choice(string.ascii_letters) for i in range(10)) + name = "Volume_" + "".join( + random.choice(string.ascii_letters) for i in range(10) + ) ls = requests.get(PODMAN_URL + "/v1.40/volumes") self.assertEqual(ls.status_code, 200, ls.content) @@ -511,7 +524,9 @@ class TestApi(unittest.TestCase): for k in required_keys: self.assertIn(k, obj) - create = requests.post(PODMAN_URL + "/v1.40/volumes/create", json={"Name": name}) + create = requests.post( + PODMAN_URL + "/v1.40/volumes/create", json={"Name": name} + ) self.assertEqual(create.status_code, 201, create.content) # See https://docs.docker.com/engine/api/v1.40/#operation/VolumeCreate @@ -688,15 +703,21 @@ class TestApi(unittest.TestCase): """Verify issue #8865""" pod_name = list() - pod_name.append("Pod_" + "".join(random.choice(string.ascii_letters) for i in range(10))) - pod_name.append("Pod_" + "".join(random.choice(string.ascii_letters) for i in range(10))) + pod_name.append( + "Pod_" + "".join(random.choice(string.ascii_letters) for i in range(10)) + ) + pod_name.append( + "Pod_" + "".join(random.choice(string.ascii_letters) for i in range(10)) + ) r = requests.post( _url("/pods/create"), json={ "name": pod_name[0], "no_infra": False, - "portmappings": [{"host_ip": "127.0.0.1", "host_port": 8889, "container_port": 89}], + "portmappings": [ + {"host_ip": "127.0.0.1", "host_port": 8889, "container_port": 89} + ], }, ) self.assertEqual(r.status_code, 201, r.text) @@ -715,7 +736,9 @@ class TestApi(unittest.TestCase): json={ "name": pod_name[1], "no_infra": False, - "portmappings": [{"host_ip": "127.0.0.1", "host_port": 8889, "container_port": 89}], + "portmappings": [ + {"host_ip": "127.0.0.1", "host_port": 8889, "container_port": 89} + ], }, ) self.assertEqual(r.status_code, 201, r.text) diff --git a/test/apiv2/test-apiv2 b/test/apiv2/test-apiv2 index 5b1e2ef80..d545df245 100755 --- a/test/apiv2/test-apiv2 +++ b/test/apiv2/test-apiv2 @@ -188,6 +188,13 @@ function t() { # entrypoint path can include a descriptive comment; strip it off path=${path%% *} + # path may include JSONish params that curl will barf on; url-encode them + path="${path//'['/%5B}" + path="${path//']'/%5D}" + path="${path//'{'/%7B}" + path="${path//'}'/%7D}" + path="${path//':'/%3A}" + # curl -X HEAD but without --head seems to wait for output anyway if [[ $method == "HEAD" ]]; then curl_args="--head" diff --git a/test/e2e/attach_test.go b/test/e2e/attach_test.go index 0c27e05c7..146ff27a5 100644 --- a/test/e2e/attach_test.go +++ b/test/e2e/attach_test.go @@ -5,7 +5,7 @@ import ( "syscall" "time" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index 9bab4c926..c733db61c 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -8,7 +8,7 @@ import ( "strings" "github.com/containers/buildah" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -489,7 +489,7 @@ RUN grep CapEff /proc/self/status` To(ContainElement("0000000000000400")) }) - It("podman build --arch", func() { + It("podman build --isolation && --arch", func() { targetPath, err := CreateTempDirInTempDir() Expect(err).To(BeNil()) @@ -502,11 +502,34 @@ RUN grep CapEff /proc/self/status` // When session := podmanTest.Podman([]string{ - "build", "--arch", "arm64", targetPath, + "build", "--isolation", "oci", "--arch", "arm64", targetPath, }) session.WaitWithDefaultTimeout() + // Then + Expect(session.ExitCode()).To(Equal(0)) + // When + session = podmanTest.Podman([]string{ + "build", "--isolation", "chroot", "--arch", "arm64", targetPath, + }) + session.WaitWithDefaultTimeout() // Then Expect(session.ExitCode()).To(Equal(0)) + + // When + session = podmanTest.Podman([]string{ + "build", "--isolation", "rootless", "--arch", "arm64", targetPath, + }) + session.WaitWithDefaultTimeout() + // Then + Expect(session.ExitCode()).To(Equal(0)) + + // When + session = podmanTest.Podman([]string{ + "build", "--isolation", "bogus", "--arch", "arm64", targetPath, + }) + session.WaitWithDefaultTimeout() + // Then + Expect(session.ExitCode()).To(Equal(125)) }) }) diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go index 3270ce685..9d0049910 100644 --- a/test/e2e/checkpoint_test.go +++ b/test/e2e/checkpoint_test.go @@ -6,8 +6,8 @@ import ( "os/exec" "strings" - "github.com/containers/podman/v2/pkg/criu" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/pkg/criu" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/commit_test.go b/test/e2e/commit_test.go index 8760978fd..0d3f2bed7 100644 --- a/test/e2e/commit_test.go +++ b/test/e2e/commit_test.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 12b30b2c5..70ffdebea 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -15,11 +15,11 @@ import ( "testing" "time" - "github.com/containers/podman/v2/libpod/define" - "github.com/containers/podman/v2/pkg/cgroups" - "github.com/containers/podman/v2/pkg/inspect" - "github.com/containers/podman/v2/pkg/rootless" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/libpod/define" + "github.com/containers/podman/v3/pkg/cgroups" + "github.com/containers/podman/v3/pkg/inspect" + "github.com/containers/podman/v3/pkg/rootless" + . "github.com/containers/podman/v3/test/utils" "github.com/containers/storage" "github.com/containers/storage/pkg/reexec" "github.com/containers/storage/pkg/stringid" diff --git a/test/e2e/config/containers.conf b/test/e2e/config/containers.conf index fdf679664..bbd712254 100644 --- a/test/e2e/config/containers.conf +++ b/test/e2e/config/containers.conf @@ -55,6 +55,7 @@ umask = "0002" annotations=["run.oci.keep_original_groups=1",] +no_hosts=true [engine] network_cmd_options=["allow_host_loopback=true"] diff --git a/test/e2e/container_inspect_test.go b/test/e2e/container_inspect_test.go index e84fd9f2e..840f13e3d 100644 --- a/test/e2e/container_inspect_test.go +++ b/test/e2e/container_inspect_test.go @@ -3,8 +3,8 @@ package integration import ( "os" - "github.com/containers/podman/v2/pkg/annotations" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/pkg/annotations" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/containers_conf_test.go b/test/e2e/containers_conf_test.go index c78c93b8c..6b1a0d16e 100644 --- a/test/e2e/containers_conf_test.go +++ b/test/e2e/containers_conf_test.go @@ -8,7 +8,7 @@ import ( "path/filepath" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -331,4 +331,26 @@ var _ = Describe("Podman run", func() { Expect(inspect.OutputToString()).To(ContainSubstring("run.oci.keep_original_groups:1")) }) + It("podman run with --add-host and no-hosts=true fails", func() { + session := podmanTest.Podman([]string{"run", "-dt", "--add-host", "test1:127.0.0.1", ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session).To(ExitWithError()) + Expect(session.ErrorToString()).To(ContainSubstring("--no-hosts and --add-host cannot be set together")) + + session = podmanTest.Podman([]string{"run", "-dt", "--add-host", "test1:127.0.0.1", "--no-hosts=false", ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + + It("podman run with no-hosts=true /etc/hosts does not include hostname", func() { + session := podmanTest.Podman([]string{"run", "--rm", "--name", "test", ALPINE, "cat", "/etc/hosts"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Not(ContainSubstring("test"))) + + session = podmanTest.Podman([]string{"run", "--rm", "--name", "test", "--no-hosts=false", ALPINE, "cat", "/etc/hosts"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("test")) + }) }) diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go index f81323847..c0fb3f887 100644 --- a/test/e2e/cp_test.go +++ b/test/e2e/cp_test.go @@ -7,7 +7,7 @@ import ( "os/user" "path/filepath" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/create_staticip_test.go b/test/e2e/create_staticip_test.go index 698bbf976..340ea31f3 100644 --- a/test/e2e/create_staticip_test.go +++ b/test/e2e/create_staticip_test.go @@ -4,8 +4,8 @@ import ( "os" "time" - "github.com/containers/podman/v2/pkg/rootless" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/pkg/rootless" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/create_staticmac_test.go b/test/e2e/create_staticmac_test.go index 4c8f371a4..1df93553d 100644 --- a/test/e2e/create_staticmac_test.go +++ b/test/e2e/create_staticmac_test.go @@ -3,8 +3,8 @@ package integration import ( "os" - "github.com/containers/podman/v2/pkg/rootless" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/pkg/rootless" + . "github.com/containers/podman/v3/test/utils" "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index 67c08ac09..1f1786dbe 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -8,7 +8,8 @@ import ( "runtime" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" + "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -576,15 +577,20 @@ var _ = Describe("Podman create", func() { Expect(session.ExitCode()).ToNot(BeZero()) }) - It("create container in pod with network should fail", func() { + It("create container in pod with network should not fail", func() { name := "createwithnetwork" pod := podmanTest.RunTopContainerInPod("", "new:"+name) pod.WaitWithDefaultTimeout() Expect(pod.ExitCode()).To(BeZero()) - session := podmanTest.Podman([]string{"create", "--pod", name, "--network", "foobar", ALPINE, "top"}) + netName := "pod" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + session = podmanTest.Podman([]string{"create", "--pod", name, "--network", netName, ALPINE, "top"}) session.WaitWithDefaultTimeout() - //Expect(session.ExitCode()).ToNot(BeZero()) Expect(session.ExitCode()).To(BeZero()) }) diff --git a/test/e2e/diff_test.go b/test/e2e/diff_test.go index 6a71f4d70..4370a2127 100644 --- a/test/e2e/diff_test.go +++ b/test/e2e/diff_test.go @@ -4,7 +4,7 @@ import ( "os" "sort" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/events_test.go b/test/e2e/events_test.go index 0c7a1bd66..4dbbe9dd8 100644 --- a/test/e2e/events_test.go +++ b/test/e2e/events_test.go @@ -8,7 +8,7 @@ import ( "sync" "time" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index b180d881a..2ffb5cd2e 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -5,7 +5,7 @@ import ( "os" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/exists_test.go b/test/e2e/exists_test.go index 306e8c250..f0a55dd94 100644 --- a/test/e2e/exists_test.go +++ b/test/e2e/exists_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" diff --git a/test/e2e/export_test.go b/test/e2e/export_test.go index 4faacd626..61aebb5f2 100644 --- a/test/e2e/export_test.go +++ b/test/e2e/export_test.go @@ -4,7 +4,7 @@ import ( "os" "path/filepath" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go index cd949c666..d7c697f28 100644 --- a/test/e2e/generate_kube_test.go +++ b/test/e2e/generate_kube_test.go @@ -6,7 +6,7 @@ import ( "path/filepath" "strconv" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" "github.com/ghodss/yaml" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go index 606d756b0..3a1da5d8c 100644 --- a/test/e2e/generate_systemd_test.go +++ b/test/e2e/generate_systemd_test.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -62,6 +62,42 @@ var _ = Describe("Podman generate systemd", func() { Expect(session.ErrorToString()).To(ContainSubstring("bogus is not a valid restart policy")) }) + It("podman generate systemd with --no-header=true", func() { + session := podmanTest.Podman([]string{"create", "--name", "foobar", "alpine", "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"generate", "systemd", "foobar", "--no-header=true"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + Expect(session.OutputToString()).NotTo(ContainSubstring("autogenerated by")) + }) + + It("podman generate systemd with --no-header", func() { + session := podmanTest.Podman([]string{"create", "--name", "foobar", "alpine", "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"generate", "systemd", "foobar", "--no-header"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + Expect(session.OutputToString()).NotTo(ContainSubstring("autogenerated by")) + }) + + It("podman generate systemd with --no-header=false", func() { + session := podmanTest.Podman([]string{"create", "--name", "foobar", "alpine", "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"generate", "systemd", "foobar", "--no-header=false"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + Expect(session.OutputToString()).To(ContainSubstring("autogenerated by")) + }) + It("podman generate systemd good timeout value", func() { session := podmanTest.Podman([]string{"create", "--name", "foobar", "alpine", "top"}) session.WaitWithDefaultTimeout() @@ -235,6 +271,29 @@ var _ = Describe("Podman generate systemd", func() { session := podmanTest.Podman([]string{"generate", "systemd", "--time", "42", "--name", "--new", "foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring(" pod create ")) + }) + + It("podman generate systemd --new=false pod", func() { + n := podmanTest.Podman([]string{"pod", "create", "--name", "foo"}) + n.WaitWithDefaultTimeout() + Expect(n.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"generate", "systemd", "--time", "42", "--name", "--new=false", "foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).NotTo(ContainSubstring(" pod create ")) + }) + + It("podman generate systemd --new=true pod", func() { + n := podmanTest.Podman([]string{"pod", "create", "--name", "foo"}) + n.WaitWithDefaultTimeout() + Expect(n.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"generate", "systemd", "--time", "42", "--name", "--new=true", "foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring(" pod create ")) }) It("podman generate systemd --container-prefix con", func() { diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go index 403f15fa7..ed7958323 100644 --- a/test/e2e/healthcheck_run_test.go +++ b/test/e2e/healthcheck_run_test.go @@ -5,7 +5,7 @@ import ( "os" "time" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/history_test.go b/test/e2e/history_test.go index 1c57c60de..e2cf62d9a 100644 --- a/test/e2e/history_test.go +++ b/test/e2e/history_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/image_sign_test.go b/test/e2e/image_sign_test.go index 57739419c..704a78685 100644 --- a/test/e2e/image_sign_test.go +++ b/test/e2e/image_sign_test.go @@ -6,7 +6,7 @@ import ( "os/exec" "path/filepath" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index 64d2ee3f3..29be505b7 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -6,7 +6,7 @@ import ( "sort" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" "github.com/docker/go-units" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/test/e2e/import_test.go b/test/e2e/import_test.go index bd465bf38..1f1b23bd0 100644 --- a/test/e2e/import_test.go +++ b/test/e2e/import_test.go @@ -4,7 +4,7 @@ import ( "os" "path/filepath" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/info_test.go b/test/e2e/info_test.go index bc4e6212b..3ce294b30 100644 --- a/test/e2e/info_test.go +++ b/test/e2e/info_test.go @@ -8,7 +8,7 @@ import ( "os/user" "path/filepath" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" diff --git a/test/e2e/init_test.go b/test/e2e/init_test.go index 3e64cfda2..d283e1f9a 100644 --- a/test/e2e/init_test.go +++ b/test/e2e/init_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go index 12bc886a8..772ebed05 100644 --- a/test/e2e/inspect_test.go +++ b/test/e2e/inspect_test.go @@ -4,7 +4,7 @@ import ( "os" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" @@ -490,4 +490,22 @@ var _ = Describe("Podman inspect", func() { } Expect(found).To(BeTrue()) }) + + It("Dropped capabilities are sorted", func() { + ctrName := "testCtr" + session := podmanTest.Podman([]string{"run", "-d", "--cap-drop", "CAP_AUDIT_WRITE", "--cap-drop", "CAP_MKNOD", "--cap-drop", "CAP_NET_RAW", "--name", ctrName, ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + + inspect := podmanTest.Podman([]string{"inspect", ctrName}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(BeZero()) + + data := inspect.InspectContainerToJSON() + Expect(len(data)).To(Equal(1)) + Expect(len(data[0].HostConfig.CapDrop)).To(Equal(3)) + Expect(data[0].HostConfig.CapDrop[0]).To(Equal("CAP_AUDIT_WRITE")) + Expect(data[0].HostConfig.CapDrop[1]).To(Equal("CAP_MKNOD")) + Expect(data[0].HostConfig.CapDrop[2]).To(Equal("CAP_NET_RAW")) + }) }) diff --git a/test/e2e/kill_test.go b/test/e2e/kill_test.go index 6d6fe788b..a9f21fa70 100644 --- a/test/e2e/kill_test.go +++ b/test/e2e/kill_test.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/libpod_suite_remote_test.go b/test/e2e/libpod_suite_remote_test.go index da57bb4c0..a26765ee9 100644 --- a/test/e2e/libpod_suite_remote_test.go +++ b/test/e2e/libpod_suite_remote_test.go @@ -15,7 +15,7 @@ import ( "syscall" "time" - "github.com/containers/podman/v2/pkg/rootless" + "github.com/containers/podman/v3/pkg/rootless" "github.com/onsi/ginkgo" ) diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go index ffbb9b44f..267f18b0a 100644 --- a/test/e2e/load_test.go +++ b/test/e2e/load_test.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/login_logout_test.go b/test/e2e/login_logout_test.go index a2e88ecd2..99876de29 100644 --- a/test/e2e/login_logout_test.go +++ b/test/e2e/login_logout_test.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" "github.com/onsi/ginkgo/config" . "github.com/onsi/gomega" diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index b370aeec1..8f695279a 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -6,7 +6,7 @@ import ( "os/exec" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" @@ -36,345 +36,341 @@ var _ = Describe("Podman logs", func() { }) - It("all lines", func() { - logc := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - - cid := logc.OutputToString() - results := podmanTest.Podman([]string{"logs", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(len(results.OutputToStringArray())).To(Equal(3)) - }) - - It("tail two lines", func() { - logc := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - cid := logc.OutputToString() - - results := podmanTest.Podman([]string{"logs", "--tail", "2", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(len(results.OutputToStringArray())).To(Equal(2)) - }) - - It("tail zero lines", func() { - logc := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - cid := logc.OutputToString() - - results := podmanTest.Podman([]string{"logs", "--tail", "0", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(len(results.OutputToStringArray())).To(Equal(0)) - }) - - It("tail 800 lines", func() { - logc := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "i=1; while [ \"$i\" -ne 1000 ]; do echo \"line $i\"; i=$((i + 1)); done"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - cid := logc.OutputToString() - - results := podmanTest.Podman([]string{"logs", "--tail", "800", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(len(results.OutputToStringArray())).To(Equal(800)) - }) - - It("tail 2 lines with timestamps", func() { - logc := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - cid := logc.OutputToString() - - results := podmanTest.Podman([]string{"logs", "--tail", "2", "-t", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(len(results.OutputToStringArray())).To(Equal(2)) - }) - - It("since time 2017-08-07", func() { - logc := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - cid := logc.OutputToString() - - results := podmanTest.Podman([]string{"logs", "--since", "2017-08-07T10:10:09.056611202-04:00", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(len(results.OutputToStringArray())).To(Equal(3)) - }) - - It("since duration 10m", func() { - logc := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - cid := logc.OutputToString() - - results := podmanTest.Podman([]string{"logs", "--since", "10m", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(len(results.OutputToStringArray())).To(Equal(3)) - }) - - It("latest and container name should fail", func() { - results := podmanTest.Podman([]string{"logs", "-l", "foobar"}) - results.WaitWithDefaultTimeout() - Expect(results).To(ExitWithError()) - }) - - It("two containers showing short container IDs", func() { - SkipIfRemote("FIXME: podman-remote logs does not support showing two containers at the same time") - log1 := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - log1.WaitWithDefaultTimeout() - Expect(log1.ExitCode()).To(Equal(0)) - cid1 := log1.OutputToString() - - log2 := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - log2.WaitWithDefaultTimeout() - Expect(log2.ExitCode()).To(Equal(0)) - cid2 := log2.OutputToString() - - results := podmanTest.Podman([]string{"logs", cid1, cid2}) - results.WaitWithDefaultTimeout() - Expect(results).Should(Exit(0)) - - output := results.OutputToStringArray() - Expect(len(output)).To(Equal(6)) - Expect(strings.Contains(output[0], cid1[:12]) || strings.Contains(output[0], cid2[:12])).To(BeTrue()) - }) - - It("podman logs on a created container should result in 0 exit code", func() { - session := podmanTest.Podman([]string{"create", "-t", "--name", "log", ALPINE}) - session.WaitWithDefaultTimeout() - Expect(session).To(Exit(0)) - - results := podmanTest.Podman([]string{"logs", "log"}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - }) + for _, log := range []string{"k8s-file", "journald", "json-file"} { + It("all lines: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + + cid := logc.OutputToString() + results := podmanTest.Podman([]string{"logs", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(len(results.OutputToStringArray())).To(Equal(3)) + }) + + It("tail two lines: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", "--tail", "2", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(len(results.OutputToStringArray())).To(Equal(2)) + }) + + It("tail zero lines: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", "--tail", "0", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(len(results.OutputToStringArray())).To(Equal(0)) + }) + + It("tail 800 lines: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "i=1; while [ \"$i\" -ne 1000 ]; do echo \"line $i\"; i=$((i + 1)); done"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", "--tail", "800", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(len(results.OutputToStringArray())).To(Equal(800)) + }) + + It("tail 2 lines with timestamps: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", "--tail", "2", "-t", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(len(results.OutputToStringArray())).To(Equal(2)) + }) + + It("since time 2017-08-07: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", "--since", "2017-08-07T10:10:09.056611202-04:00", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(len(results.OutputToStringArray())).To(Equal(3)) + }) + + It("since duration 10m: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", "--since", "10m", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(len(results.OutputToStringArray())).To(Equal(3)) + }) + + It("latest and container name should fail: "+log, func() { + results := podmanTest.Podman([]string{"logs", "-l", "foobar"}) + results.WaitWithDefaultTimeout() + Expect(results).To(ExitWithError()) + }) + + It("two containers showing short container IDs: "+log, func() { + SkipIfRemote("FIXME: podman-remote logs does not support showing two containers at the same time") + log1 := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + log1.WaitWithDefaultTimeout() + Expect(log1.ExitCode()).To(Equal(0)) + cid1 := log1.OutputToString() + + log2 := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + log2.WaitWithDefaultTimeout() + Expect(log2.ExitCode()).To(Equal(0)) + cid2 := log2.OutputToString() + + results := podmanTest.Podman([]string{"logs", cid1, cid2}) + results.WaitWithDefaultTimeout() + Expect(results).Should(Exit(0)) + + output := results.OutputToStringArray() + Expect(len(output)).To(Equal(6)) + Expect(strings.Contains(output[0], cid1[:12]) || strings.Contains(output[0], cid2[:12])).To(BeTrue()) + }) + + It("podman logs on a created container should result in 0 exit code: "+log, func() { + session := podmanTest.Podman([]string{"create", "-t", "--name", "log", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session).To(Exit(0)) + + results := podmanTest.Podman([]string{"logs", "log"}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + }) + + It("for container: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(len(results.OutputToStringArray())).To(Equal(3)) + Expect(results.OutputToString()).To(Equal("podman podman podman")) + }) + + It("tail two lines: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + cid := logc.OutputToString() + results := podmanTest.Podman([]string{"logs", "--tail", "2", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(len(results.OutputToStringArray())).To(Equal(2)) + }) + + It("tail 99 lines: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", "--tail", "99", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(len(results.OutputToStringArray())).To(Equal(3)) + }) + + It("tail 2 lines with timestamps: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", "--tail", "2", "-t", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(len(results.OutputToStringArray())).To(Equal(2)) + }) + + It("since time 2017-08-07: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", "--since", "2017-08-07T10:10:09.056611202-04:00", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(len(results.OutputToStringArray())).To(Equal(3)) + }) + + It("with duration 10m: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", "--since", "10m", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(len(results.OutputToStringArray())).To(Equal(3)) + }) + + It("streaming output: "+log, func() { + containerName := "logs-f-rm" + + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "--rm", "--name", containerName, "-dt", ALPINE, "sh", "-c", "echo podman; sleep 1; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + + results := podmanTest.Podman([]string{"logs", "-f", containerName}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + + // TODO: we should actually check for two podman lines, + // but as of 2020-06-17 there's a race condition in which + // 'logs -f' may not catch all output from a container + Expect(results.OutputToString()).To(ContainSubstring("podman")) + + // Container should now be terminatING or terminatED, but we + // have no guarantee of which: 'logs -f' does not necessarily + // wait for cleanup. Run 'inspect' and accept either state. + inspect := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.State.Status}}", containerName}) + inspect.WaitWithDefaultTimeout() + if inspect.ExitCode() == 0 { + Expect(inspect.OutputToString()).To(Equal("exited")) + // TODO: add 2-second wait loop to confirm cleanup + } else { + Expect(inspect.ErrorToString()).To(ContainSubstring("no such container")) + } + }) + + It("podman logs with log-driver=none errors: "+log, func() { + ctrName := "logsctr" + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "--name", ctrName, "-d", "--log-driver", "none", ALPINE, "top"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + + logs := podmanTest.Podman([]string{"logs", "-f", ctrName}) + logs.WaitWithDefaultTimeout() + Expect(logs).To(Not(Exit(0))) + }) + + It("follow output stopped container: "+log, func() { + containerName := "logs-f" + + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "--name", containerName, "-d", ALPINE, "true"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + + results := podmanTest.Podman([]string{"logs", "-f", containerName}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + }) + + It("using container with container log-size: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "--log-opt=max-size=10k", "-d", ALPINE, "sh", "-c", "echo podman podman podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + cid := logc.OutputToString() + + wait := podmanTest.Podman([]string{"wait", cid}) + wait.WaitWithDefaultTimeout() + Expect(wait).To(Exit(0)) + + inspect := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.HostConfig.LogConfig.Size}}", cid}) + inspect.WaitWithDefaultTimeout() + Expect(inspect).To(Exit(0)) + Expect(inspect.OutputToString()).To(Equal("10kB")) + + results := podmanTest.Podman([]string{"logs", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(results.OutputToString()).To(Equal("podman podman podman")) + }) + + It("Make sure logs match expected length: "+log, func() { + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "-t", "--name", "test", ALPINE, "sh", "-c", "echo 1; echo 2"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + + wait := podmanTest.Podman([]string{"wait", "test"}) + wait.WaitWithDefaultTimeout() + Expect(wait).To(Exit(0)) + + results := podmanTest.Podman([]string{"logs", "test"}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + outlines := results.OutputToStringArray() + Expect(len(outlines)).To(Equal(2)) + Expect(outlines[0]).To(Equal("1\r")) + Expect(outlines[1]).To(Equal("2\r")) + }) + + It("podman logs test stdout and stderr: "+log, func() { + cname := "log-test" + logc := podmanTest.Podman([]string{"run", "--log-driver", log, "--name", cname, ALPINE, "sh", "-c", "echo stdout; echo stderr >&2"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + + wait := podmanTest.Podman([]string{"wait", cname}) + wait.WaitWithDefaultTimeout() + Expect(wait).To(Exit(0)) + + results := podmanTest.Podman([]string{"logs", cname}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + Expect(results.OutputToString()).To(Equal("stdout")) + Expect(results.ErrorToString()).To(Equal("stderr")) + }) + } It("using journald for container with container tag", func() { - Skip("need to verify images have correct packages for journald") + SkipIfInContainer("journalctl inside a container doesn't work correctly") logc := podmanTest.Podman([]string{"run", "--log-driver", "journald", "--log-opt=tag={{.ImageName}}", "-d", ALPINE, "sh", "-c", "echo podman; sleep 0.1; echo podman; sleep 0.1; echo podman"}) logc.WaitWithDefaultTimeout() Expect(logc).To(Exit(0)) cid := logc.OutputToString() - wait := podmanTest.Podman([]string{"wait", "-l"}) + wait := podmanTest.Podman([]string{"wait", cid}) wait.WaitWithDefaultTimeout() Expect(wait).To(Exit(0)) - cmd := exec.Command("journalctl", "--no-pager", "-o", "json", "--output-fields=CONTAINER_TAG", "-u", fmt.Sprintf("libpod-conmon-%s.scope", cid)) + cmd := exec.Command("journalctl", "--no-pager", "-o", "json", "--output-fields=CONTAINER_TAG", fmt.Sprintf("CONTAINER_ID_FULL=%s", cid)) out, err := cmd.CombinedOutput() Expect(err).To(BeNil()) Expect(string(out)).To(ContainSubstring("alpine")) }) - It("using journald for container name", func() { - Skip("need to verify images have correct packages for journald") + It("using journald container name", func() { + SkipIfInContainer("journalctl inside a container doesn't work correctly") containerName := "inside-journal" logc := podmanTest.Podman([]string{"run", "--log-driver", "journald", "-d", "--name", containerName, ALPINE, "sh", "-c", "echo podman; sleep 0.1; echo podman; sleep 0.1; echo podman"}) logc.WaitWithDefaultTimeout() Expect(logc).To(Exit(0)) cid := logc.OutputToString() - wait := podmanTest.Podman([]string{"wait", "-l"}) + wait := podmanTest.Podman([]string{"wait", cid}) wait.WaitWithDefaultTimeout() Expect(wait).To(Exit(0)) - cmd := exec.Command("journalctl", "--no-pager", "-o", "json", "--output-fields=CONTAINER_NAME", "-u", fmt.Sprintf("libpod-conmon-%s.scope", cid)) + cmd := exec.Command("journalctl", "--no-pager", "-o", "json", "--output-fields=CONTAINER_NAME", fmt.Sprintf("CONTAINER_ID_FULL=%s", cid)) out, err := cmd.CombinedOutput() Expect(err).To(BeNil()) Expect(string(out)).To(ContainSubstring(containerName)) }) - - It("using journald for container", func() { - Skip("need to verify images have correct packages for journald") - logc := podmanTest.Podman([]string{"run", "--log-driver", "journald", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - cid := logc.OutputToString() - - results := podmanTest.Podman([]string{"logs", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(len(results.OutputToStringArray())).To(Equal(3)) - Expect(results.OutputToString()).To(Equal("podman podman podman")) - }) - - It("using journald tail two lines", func() { - Skip("need to verify images have correct packages for journald") - logc := podmanTest.Podman([]string{"run", "--log-driver", "journald", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - cid := logc.OutputToString() - results := podmanTest.Podman([]string{"logs", "--tail", "2", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(len(results.OutputToStringArray())).To(Equal(2)) - }) - - It("using journald tail 99 lines", func() { - Skip("need to verify images have correct packages for journald") - logc := podmanTest.Podman([]string{"run", "--log-driver", "journald", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - cid := logc.OutputToString() - - results := podmanTest.Podman([]string{"logs", "--tail", "99", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(len(results.OutputToStringArray())).To(Equal(3)) - }) - - It("using journald tail 2 lines with timestamps", func() { - Skip("need to verify images have correct packages for journald") - logc := podmanTest.Podman([]string{"run", "--log-driver", "journald", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - cid := logc.OutputToString() - - results := podmanTest.Podman([]string{"logs", "--tail", "2", "-t", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(len(results.OutputToStringArray())).To(Equal(2)) - }) - - It("using journald since time 2017-08-07", func() { - Skip("need to verify images have correct packages for journald") - logc := podmanTest.Podman([]string{"run", "--log-driver", "journald", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - cid := logc.OutputToString() - - results := podmanTest.Podman([]string{"logs", "--since", "2017-08-07T10:10:09.056611202-04:00", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(len(results.OutputToStringArray())).To(Equal(3)) - }) - - It("using journald with duration 10m", func() { - Skip("need to verify images have correct packages for journald") - logc := podmanTest.Podman([]string{"run", "--log-driver", "journald", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - cid := logc.OutputToString() - - results := podmanTest.Podman([]string{"logs", "--since", "10m", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(len(results.OutputToStringArray())).To(Equal(3)) - }) - - It("streaming output", func() { - containerName := "logs-f-rm" - - logc := podmanTest.Podman([]string{"run", "--rm", "--name", containerName, "-dt", ALPINE, "sh", "-c", "echo podman; sleep 1; echo podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - - results := podmanTest.Podman([]string{"logs", "-f", containerName}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - - // TODO: we should actually check for two podman lines, - // but as of 2020-06-17 there's a race condition in which - // 'logs -f' may not catch all output from a container - Expect(results.OutputToString()).To(ContainSubstring("podman")) - - // Container should now be terminatING or terminatED, but we - // have no guarantee of which: 'logs -f' does not necessarily - // wait for cleanup. Run 'inspect' and accept either state. - inspect := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.State.Status}}", containerName}) - inspect.WaitWithDefaultTimeout() - if inspect.ExitCode() == 0 { - Expect(inspect.OutputToString()).To(Equal("exited")) - // TODO: add 2-second wait loop to confirm cleanup - } else { - Expect(inspect.ErrorToString()).To(ContainSubstring("no such container")) - } - }) - - It("podman logs with log-driver=none errors", func() { - ctrName := "logsctr" - logc := podmanTest.Podman([]string{"run", "--name", ctrName, "-d", "--log-driver", "none", ALPINE, "top"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - - logs := podmanTest.Podman([]string{"logs", "-f", ctrName}) - logs.WaitWithDefaultTimeout() - Expect(logs).To(Not(Exit(0))) - }) - - It("follow output stopped container", func() { - containerName := "logs-f" - - logc := podmanTest.Podman([]string{"run", "--name", containerName, "-d", ALPINE, "true"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - - results := podmanTest.Podman([]string{"logs", "-f", containerName}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - }) - - It("using container with container log-size", func() { - logc := podmanTest.Podman([]string{"run", "--log-opt=max-size=10k", "-d", ALPINE, "sh", "-c", "echo podman podman podman"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - cid := logc.OutputToString() - - wait := podmanTest.Podman([]string{"wait", cid}) - wait.WaitWithDefaultTimeout() - Expect(wait).To(Exit(0)) - - inspect := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.HostConfig.LogConfig.Size}}", cid}) - inspect.WaitWithDefaultTimeout() - Expect(inspect).To(Exit(0)) - Expect(inspect.OutputToString()).To(Equal("10kB")) - - results := podmanTest.Podman([]string{"logs", cid}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(results.OutputToString()).To(Equal("podman podman podman")) - }) - - It("Make sure logs match expected length", func() { - logc := podmanTest.Podman([]string{"run", "-t", "--name", "test", ALPINE, "sh", "-c", "echo 1; echo 2"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - - wait := podmanTest.Podman([]string{"wait", "test"}) - wait.WaitWithDefaultTimeout() - Expect(wait).To(Exit(0)) - - results := podmanTest.Podman([]string{"logs", "test"}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - outlines := results.OutputToStringArray() - Expect(len(outlines)).To(Equal(2)) - Expect(outlines[0]).To(Equal("1\r")) - Expect(outlines[1]).To(Equal("2\r")) - }) - - It("podman logs test stdout and stderr", func() { - cname := "log-test" - logc := podmanTest.Podman([]string{"run", "--name", cname, ALPINE, "sh", "-c", "echo stdout; echo stderr >&2"}) - logc.WaitWithDefaultTimeout() - Expect(logc).To(Exit(0)) - - wait := podmanTest.Podman([]string{"wait", cname}) - wait.WaitWithDefaultTimeout() - Expect(wait).To(Exit(0)) - - results := podmanTest.Podman([]string{"logs", cname}) - results.WaitWithDefaultTimeout() - Expect(results).To(Exit(0)) - Expect(results.OutputToString()).To(Equal("stdout")) - Expect(results.ErrorToString()).To(Equal("stderr")) - }) }) diff --git a/test/e2e/manifest_test.go b/test/e2e/manifest_test.go index e6ac83aea..18be97a89 100644 --- a/test/e2e/manifest_test.go +++ b/test/e2e/manifest_test.go @@ -5,7 +5,7 @@ import ( "path/filepath" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" diff --git a/test/e2e/mount_rootless_test.go b/test/e2e/mount_rootless_test.go index c410a2507..502bdef4e 100644 --- a/test/e2e/mount_rootless_test.go +++ b/test/e2e/mount_rootless_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/mount_test.go b/test/e2e/mount_test.go index c9274553b..ee77f2984 100644 --- a/test/e2e/mount_test.go +++ b/test/e2e/mount_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/namespace_test.go b/test/e2e/namespace_test.go index 951e98dfc..0c451d6cd 100644 --- a/test/e2e/namespace_test.go +++ b/test/e2e/namespace_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/negative_test.go b/test/e2e/negative_test.go index 9c879fb8b..c3cef2e8e 100644 --- a/test/e2e/negative_test.go +++ b/test/e2e/negative_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/network_connect_disconnect_test.go b/test/e2e/network_connect_disconnect_test.go index cc23b10c1..eb8ad7181 100644 --- a/test/e2e/network_connect_disconnect_test.go +++ b/test/e2e/network_connect_disconnect_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -37,7 +37,6 @@ var _ = Describe("Podman network connect and disconnect", func() { dis := podmanTest.Podman([]string{"network", "disconnect", "foobar", "test"}) dis.WaitWithDefaultTimeout() Expect(dis.ExitCode()).ToNot(BeZero()) - }) It("bad container name in network disconnect should result in error", func() { @@ -51,7 +50,25 @@ var _ = Describe("Podman network connect and disconnect", func() { dis := podmanTest.Podman([]string{"network", "disconnect", netName, "foobar"}) dis.WaitWithDefaultTimeout() Expect(dis.ExitCode()).ToNot(BeZero()) + }) + + It("network disconnect with net mode slirp4netns should result in error", func() { + SkipIfRootless("network connect and disconnect are only rootful") + netName := "slirp" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + session = podmanTest.Podman([]string{"create", "--name", "test", "--network", "slirp4netns", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + con := podmanTest.Podman([]string{"network", "disconnect", netName, "test"}) + con.WaitWithDefaultTimeout() + Expect(con.ExitCode()).ToNot(BeZero()) + Expect(con.ErrorToString()).To(ContainSubstring(`network mode "slirp4netns" is not supported`)) }) It("podman network disconnect", func() { @@ -89,7 +106,6 @@ var _ = Describe("Podman network connect and disconnect", func() { dis := podmanTest.Podman([]string{"network", "connect", "foobar", "test"}) dis.WaitWithDefaultTimeout() Expect(dis.ExitCode()).ToNot(BeZero()) - }) It("bad container name in network connect should result in error", func() { @@ -103,7 +119,25 @@ var _ = Describe("Podman network connect and disconnect", func() { dis := podmanTest.Podman([]string{"network", "connect", netName, "foobar"}) dis.WaitWithDefaultTimeout() Expect(dis.ExitCode()).ToNot(BeZero()) + }) + + It("network connect with net mode slirp4netns should result in error", func() { + SkipIfRootless("network connect and disconnect are only rootful") + netName := "slirp" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + session = podmanTest.Podman([]string{"create", "--name", "test", "--network", "slirp4netns", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + con := podmanTest.Podman([]string{"network", "connect", netName, "test"}) + con.WaitWithDefaultTimeout() + Expect(con.ExitCode()).ToNot(BeZero()) + Expect(con.ErrorToString()).To(ContainSubstring(`network mode "slirp4netns" is not supported`)) }) It("podman connect on a container that already is connected to the network should error", func() { @@ -195,6 +229,55 @@ var _ = Describe("Podman network connect and disconnect", func() { Expect(exec.ExitCode()).To(BeZero()) }) + It("podman network connect and run with network ID", func() { + SkipIfRemote("remote flakes to much I will fix this in another PR") + SkipIfRootless("network connect and disconnect are only rootful") + netName := "ID" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + session = podmanTest.Podman([]string{"network", "ls", "--format", "{{.ID}}", "--filter", "name=" + netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + netID := session.OutputToString() + + ctr := podmanTest.Podman([]string{"run", "-dt", "--name", "test", "--network", netID, ALPINE, "top"}) + ctr.WaitWithDefaultTimeout() + Expect(ctr.ExitCode()).To(BeZero()) + + exec := podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"}) + exec.WaitWithDefaultTimeout() + Expect(exec.ExitCode()).To(BeZero()) + + // Create a second network + newNetName := "ID2" + stringid.GenerateNonCryptoID() + session = podmanTest.Podman([]string{"network", "create", newNetName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(newNetName) + + session = podmanTest.Podman([]string{"network", "ls", "--format", "{{.ID}}", "--filter", "name=" + newNetName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + newNetID := session.OutputToString() + + connect := podmanTest.Podman([]string{"network", "connect", newNetID, "test"}) + connect.WaitWithDefaultTimeout() + Expect(connect.ExitCode()).To(BeZero()) + + inspect := podmanTest.Podman([]string{"container", "inspect", "test", "--format", "{{.NetworkSettings.Networks}}"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(BeZero()) + Expect(inspect.OutputToString()).To(ContainSubstring(netName)) + Expect(inspect.OutputToString()).To(ContainSubstring(newNetName)) + + exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth1"}) + exec.WaitWithDefaultTimeout() + Expect(exec.ExitCode()).To(BeZero()) + }) + It("podman network disconnect when not running", func() { SkipIfRootless("network connect and disconnect are only rootful") netName1 := "aliasTest" + stringid.GenerateNonCryptoID() @@ -234,4 +317,40 @@ var _ = Describe("Podman network connect and disconnect", func() { exec.WaitWithDefaultTimeout() Expect(exec.ExitCode()).ToNot(BeZero()) }) + + It("podman network disconnect and run with network ID", func() { + SkipIfRemote("remote flakes to much I will fix this in another PR") + SkipIfRootless("network connect and disconnect are only rootful") + netName := "aliasTest" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + session = podmanTest.Podman([]string{"network", "ls", "--format", "{{.ID}}", "--filter", "name=" + netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + netID := session.OutputToString() + + ctr := podmanTest.Podman([]string{"run", "-dt", "--name", "test", "--network", netID, ALPINE, "top"}) + ctr.WaitWithDefaultTimeout() + Expect(ctr.ExitCode()).To(BeZero()) + + exec := podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"}) + exec.WaitWithDefaultTimeout() + Expect(exec.ExitCode()).To(BeZero()) + + dis := podmanTest.Podman([]string{"network", "disconnect", netID, "test"}) + dis.WaitWithDefaultTimeout() + Expect(dis.ExitCode()).To(BeZero()) + + inspect := podmanTest.Podman([]string{"container", "inspect", "test", "--format", "{{len .NetworkSettings.Networks}}"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(BeZero()) + Expect(inspect.OutputToString()).To(Equal("0")) + + exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"}) + exec.WaitWithDefaultTimeout() + Expect(exec.ExitCode()).ToNot(BeZero()) + }) }) diff --git a/test/e2e/network_create_test.go b/test/e2e/network_create_test.go index 1bf2a2691..ef3be8e22 100644 --- a/test/e2e/network_create_test.go +++ b/test/e2e/network_create_test.go @@ -8,8 +8,8 @@ import ( "strings" cniversion "github.com/containernetworking/cni/pkg/version" - "github.com/containers/podman/v2/libpod/network" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/libpod/network" + . "github.com/containers/podman/v3/test/utils" "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go index 083d2a49a..53521cdc4 100644 --- a/test/e2e/network_test.go +++ b/test/e2e/network_test.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/containers/podman/v2/pkg/rootless" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/pkg/rootless" + . "github.com/containers/podman/v3/test/utils" "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -150,6 +150,13 @@ var _ = Describe("Podman network", func() { defer podmanTest.removeCNINetwork(net) Expect(session.ExitCode()).To(BeZero()) + // Tests Default Table Output + session = podmanTest.Podman([]string{"network", "ls", "--filter", "id=" + netID}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + expectedTable := "NETWORK ID NAME VERSION PLUGINS" + Expect(session.OutputToString()).To(ContainSubstring(expectedTable)) + session = podmanTest.Podman([]string{"network", "ls", "--format", "{{.Name}} {{.ID}}", "--filter", "id=" + netID}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(BeZero()) diff --git a/test/e2e/pause_test.go b/test/e2e/pause_test.go index a90ffcc87..01ad7c071 100644 --- a/test/e2e/pause_test.go +++ b/test/e2e/pause_test.go @@ -7,7 +7,7 @@ import ( "path/filepath" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 2e5c72b0e..9260d6cd2 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -10,7 +10,7 @@ import ( "strings" "text/template" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/opencontainers/selinux/go-selinux" diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index 0a7a5101e..a70d9f13f 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -7,8 +7,8 @@ import ( "path/filepath" "strings" - "github.com/containers/podman/v2/pkg/rootless" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/pkg/rootless" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/pod_infra_container_test.go b/test/e2e/pod_infra_container_test.go index 452a3de21..09f0d4e33 100644 --- a/test/e2e/pod_infra_container_test.go +++ b/test/e2e/pod_infra_container_test.go @@ -4,7 +4,7 @@ import ( "os" "strconv" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/pod_inspect_test.go b/test/e2e/pod_inspect_test.go index d9c4a393a..036b08570 100644 --- a/test/e2e/pod_inspect_test.go +++ b/test/e2e/pod_inspect_test.go @@ -4,8 +4,8 @@ import ( "encoding/json" "os" - "github.com/containers/podman/v2/libpod/define" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/libpod/define" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/pod_kill_test.go b/test/e2e/pod_kill_test.go index 06d244f99..92dcad292 100644 --- a/test/e2e/pod_kill_test.go +++ b/test/e2e/pod_kill_test.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/pod_pause_test.go b/test/e2e/pod_pause_test.go index 0c1b39f38..da3b106fa 100644 --- a/test/e2e/pod_pause_test.go +++ b/test/e2e/pod_pause_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/pod_pod_namespaces_test.go b/test/e2e/pod_pod_namespaces_test.go index 20b8bdb39..ce93db63c 100644 --- a/test/e2e/pod_pod_namespaces_test.go +++ b/test/e2e/pod_pod_namespaces_test.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/pod_prune_test.go b/test/e2e/pod_prune_test.go index d1ebf7249..2def95308 100644 --- a/test/e2e/pod_prune_test.go +++ b/test/e2e/pod_prune_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/pod_ps_test.go b/test/e2e/pod_ps_test.go index c20cb44e7..c5c0827bc 100644 --- a/test/e2e/pod_ps_test.go +++ b/test/e2e/pod_ps_test.go @@ -5,7 +5,7 @@ import ( "os" "sort" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/test/e2e/pod_restart_test.go b/test/e2e/pod_restart_test.go index c6b1a0d46..006421b93 100644 --- a/test/e2e/pod_restart_test.go +++ b/test/e2e/pod_restart_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/pod_rm_test.go b/test/e2e/pod_rm_test.go index 40a903cd0..6d710f020 100644 --- a/test/e2e/pod_rm_test.go +++ b/test/e2e/pod_rm_test.go @@ -7,7 +7,7 @@ import ( "path/filepath" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/pod_start_test.go b/test/e2e/pod_start_test.go index e14796ab3..5838f3310 100644 --- a/test/e2e/pod_start_test.go +++ b/test/e2e/pod_start_test.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" diff --git a/test/e2e/pod_stats_test.go b/test/e2e/pod_stats_test.go index 073d4752b..2064cdc9f 100644 --- a/test/e2e/pod_stats_test.go +++ b/test/e2e/pod_stats_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" diff --git a/test/e2e/pod_stop_test.go b/test/e2e/pod_stop_test.go index 30a5632d0..45e2f86a6 100644 --- a/test/e2e/pod_stop_test.go +++ b/test/e2e/pod_stop_test.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/pod_top_test.go b/test/e2e/pod_top_test.go index e191b44fc..9d9c138c4 100644 --- a/test/e2e/pod_top_test.go +++ b/test/e2e/pod_top_test.go @@ -5,7 +5,7 @@ import ( "os" "time" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/port_test.go b/test/e2e/port_test.go index 4aaf2cbc1..e9bbc2adc 100644 --- a/test/e2e/port_test.go +++ b/test/e2e/port_test.go @@ -5,7 +5,7 @@ import ( "os" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/prune_test.go b/test/e2e/prune_test.go index f84312103..73da77417 100644 --- a/test/e2e/prune_test.go +++ b/test/e2e/prune_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -111,7 +111,6 @@ var _ = Describe("Podman prune", func() { It("podman image prune dangling images", func() { podmanTest.BuildImage(pruneImage, "alpine_bash:latest", "true") podmanTest.BuildImage(pruneImage, "alpine_bash:latest", "true") - none := podmanTest.Podman([]string{"images", "-a"}) none.WaitWithDefaultTimeout() Expect(none.ExitCode()).To(Equal(0)) diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index 016b4c8cd..ac0910a83 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" "github.com/containers/storage/pkg/stringid" "github.com/docker/go-units" . "github.com/onsi/ginkgo" diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index d47a3e47a..5308548f1 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -7,7 +7,7 @@ import ( "runtime" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go index 00b5802a3..cc7c67941 100644 --- a/test/e2e/push_test.go +++ b/test/e2e/push_test.go @@ -6,8 +6,8 @@ import ( "path/filepath" "strings" - "github.com/containers/podman/v2/pkg/rootless" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/pkg/rootless" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/rename_test.go b/test/e2e/rename_test.go index 7affbaf56..f19413221 100644 --- a/test/e2e/rename_test.go +++ b/test/e2e/rename_test.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/restart_test.go b/test/e2e/restart_test.go index bfe9563ea..dc8e64e63 100644 --- a/test/e2e/restart_test.go +++ b/test/e2e/restart_test.go @@ -4,7 +4,7 @@ import ( "os" "time" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go index 4c50a61ef..788d14141 100644 --- a/test/e2e/rm_test.go +++ b/test/e2e/rm_test.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go index 257570ea7..d8367d636 100644 --- a/test/e2e/rmi_test.go +++ b/test/e2e/rmi_test.go @@ -5,7 +5,7 @@ import ( "os" "sync" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" diff --git a/test/e2e/run_apparmor_test.go b/test/e2e/run_apparmor_test.go index 0faf0b496..63c52451f 100644 --- a/test/e2e/run_apparmor_test.go +++ b/test/e2e/run_apparmor_test.go @@ -9,7 +9,7 @@ import ( "path/filepath" "github.com/containers/common/pkg/apparmor" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_cgroup_parent_test.go b/test/e2e/run_cgroup_parent_test.go index 35628d44b..d68b1bb5f 100644 --- a/test/e2e/run_cgroup_parent_test.go +++ b/test/e2e/run_cgroup_parent_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_cleanup_test.go b/test/e2e/run_cleanup_test.go index 5f6c9007a..2dfaf1329 100644 --- a/test/e2e/run_cleanup_test.go +++ b/test/e2e/run_cleanup_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_cpu_test.go b/test/e2e/run_cpu_test.go index d8b57c230..2f4452ba4 100644 --- a/test/e2e/run_cpu_test.go +++ b/test/e2e/run_cpu_test.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_device_test.go b/test/e2e/run_device_test.go index 1c2602631..5a32ed827 100644 --- a/test/e2e/run_device_test.go +++ b/test/e2e/run_device_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_dns_test.go b/test/e2e/run_dns_test.go index c8996c5e8..05f8c3f99 100644 --- a/test/e2e/run_dns_test.go +++ b/test/e2e/run_dns_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_entrypoint_test.go b/test/e2e/run_entrypoint_test.go index 389f142b1..ddad89c85 100644 --- a/test/e2e/run_entrypoint_test.go +++ b/test/e2e/run_entrypoint_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_env_test.go b/test/e2e/run_env_test.go index 9882b936a..83d8e8da6 100644 --- a/test/e2e/run_env_test.go +++ b/test/e2e/run_env_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_exit_test.go b/test/e2e/run_exit_test.go index 0579e29fa..3d969cbc2 100644 --- a/test/e2e/run_exit_test.go +++ b/test/e2e/run_exit_test.go @@ -3,8 +3,8 @@ package integration import ( "os" - "github.com/containers/podman/v2/libpod/define" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/libpod/define" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_memory_test.go b/test/e2e/run_memory_test.go index 8371d3cae..cb13993f4 100644 --- a/test/e2e/run_memory_test.go +++ b/test/e2e/run_memory_test.go @@ -4,7 +4,7 @@ import ( "os" "strconv" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 676f24e5d..0e6e636bc 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -5,7 +5,7 @@ import ( "os" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -766,4 +766,18 @@ var _ = Describe("Podman run networking", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(BeZero()) }) + + It("podman run check dnsname adds dns search domain", func() { + Skip("needs dnsname#57") + net := "dnsname" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", net}) + session.WaitWithDefaultTimeout() + defer podmanTest.removeCNINetwork(net) + Expect(session.ExitCode()).To(BeZero()) + + session = podmanTest.Podman([]string{"run", "--network", net, ALPINE, "cat", "/etc/resolv.conf"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + Expect(session.OutputToString()).To(ContainSubstring("search dns.podman")) + }) }) diff --git a/test/e2e/run_ns_test.go b/test/e2e/run_ns_test.go index 29d2d4395..c72891107 100644 --- a/test/e2e/run_ns_test.go +++ b/test/e2e/run_ns_test.go @@ -5,7 +5,7 @@ import ( "os/exec" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_passwd_test.go b/test/e2e/run_passwd_test.go index e7b86c68b..12b6c64df 100644 --- a/test/e2e/run_passwd_test.go +++ b/test/e2e/run_passwd_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_privileged_test.go b/test/e2e/run_privileged_test.go index 48f9ea76e..33b3b85c5 100644 --- a/test/e2e/run_privileged_test.go +++ b/test/e2e/run_privileged_test.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/syndtr/gocapability/capability" diff --git a/test/e2e/run_restart_test.go b/test/e2e/run_restart_test.go index 85621a762..c996bdb25 100644 --- a/test/e2e/run_restart_test.go +++ b/test/e2e/run_restart_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_seccomp_test.go b/test/e2e/run_seccomp_test.go index 7d04cc60a..ed1cdeecd 100644 --- a/test/e2e/run_seccomp_test.go +++ b/test/e2e/run_seccomp_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_security_labels_test.go b/test/e2e/run_security_labels_test.go index 0c5621e3f..a2e0b2aab 100644 --- a/test/e2e/run_security_labels_test.go +++ b/test/e2e/run_security_labels_test.go @@ -4,7 +4,7 @@ import ( "os" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_selinux_test.go b/test/e2e/run_selinux_test.go index 2e9d38e2d..8c712b1be 100644 --- a/test/e2e/run_selinux_test.go +++ b/test/e2e/run_selinux_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/opencontainers/selinux/go-selinux" diff --git a/test/e2e/run_signal_test.go b/test/e2e/run_signal_test.go index 58b8d04e5..f601bee72 100644 --- a/test/e2e/run_signal_test.go +++ b/test/e2e/run_signal_test.go @@ -9,8 +9,8 @@ import ( "syscall" "time" - "github.com/containers/podman/v2/pkg/rootless" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/pkg/rootless" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "golang.org/x/sys/unix" diff --git a/test/e2e/run_staticip_test.go b/test/e2e/run_staticip_test.go index aeb462ae9..bff142b12 100644 --- a/test/e2e/run_staticip_test.go +++ b/test/e2e/run_staticip_test.go @@ -6,7 +6,7 @@ import ( "os" "time" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index f333b8afd..f0ba9d1d9 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -11,7 +11,7 @@ import ( "syscall" "time" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" "github.com/containers/storage/pkg/stringid" "github.com/mrunalp/fileutils" . "github.com/onsi/ginkgo" @@ -1228,9 +1228,10 @@ USER mail` for _, line := range lines { parts := strings.SplitN(line, ":", 3) if !CGROUPSV2 { - // ignore unified on cgroup v1 + // ignore unified on cgroup v1. // both runc and crun do not set it. - if parts[1] == "" { + // crun does not set named hierarchies. + if parts[1] == "" || strings.Contains(parts[1], "name=") { continue } } diff --git a/test/e2e/run_userns_test.go b/test/e2e/run_userns_test.go index 8d860cfc3..79ef707a2 100644 --- a/test/e2e/run_userns_test.go +++ b/test/e2e/run_userns_test.go @@ -7,7 +7,7 @@ import ( "os/user" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index d81fb769d..454dfdc83 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -2,13 +2,15 @@ package integration import ( "fmt" + "io/ioutil" "os" "os/exec" + "os/user" "path/filepath" "strings" - "github.com/containers/podman/v2/pkg/rootless" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/pkg/rootless" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" @@ -590,4 +592,55 @@ VOLUME /test/` Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) }) + + It("podman run with U volume flag", func() { + SkipIfRemote("Overlay volumes only work locally") + + u, err := user.Current() + Expect(err).To(BeNil()) + name := u.Username + if name == "root" { + name = "containers" + } + + content, err := ioutil.ReadFile("/etc/subuid") + if err != nil { + Skip("cannot read /etc/subuid") + } + if !strings.Contains(string(content), name) { + Skip("cannot find mappings for the current user") + } + + if os.Getenv("container") != "" { + Skip("Overlay mounts not supported when running in a container") + } + if rootless.IsRootless() { + if _, err := exec.LookPath("fuse_overlay"); err != nil { + Skip("Fuse-Overlayfs required for rootless overlay mount test") + } + } + + mountPath := filepath.Join(podmanTest.TempDir, "secrets") + os.Mkdir(mountPath, 0755) + vol := mountPath + ":" + dest + ":U" + + session := podmanTest.Podman([]string{"run", "--rm", "--user", "888:888", "-v", vol, ALPINE, "stat", "-c", "%u:%g", dest}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + found, _ := session.GrepString("888:888") + Expect(found).Should(BeTrue()) + + session = podmanTest.Podman([]string{"run", "--rm", "--user", "888:888", "--userns", "auto", "-v", vol, ALPINE, "stat", "-c", "%u:%g", dest}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + found, _ = session.GrepString("888:888") + Expect(found).Should(BeTrue()) + + vol = vol + ",O" + session = podmanTest.Podman([]string{"run", "--rm", "--user", "888:888", "--userns", "keep-id", "-v", vol, ALPINE, "stat", "-c", "%u:%g", dest}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + found, _ = session.GrepString("888:888") + Expect(found).Should(BeTrue()) + }) }) diff --git a/test/e2e/run_working_dir_test.go b/test/e2e/run_working_dir_test.go index 948ed05e7..2d16cdc18 100644 --- a/test/e2e/run_working_dir_test.go +++ b/test/e2e/run_working_dir_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/runlabel_test.go b/test/e2e/runlabel_test.go index 10e16ea23..2eec15c62 100644 --- a/test/e2e/runlabel_test.go +++ b/test/e2e/runlabel_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index a5737c110..5ddd5efc8 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -8,8 +8,8 @@ import ( "strconv" "strings" - "github.com/containers/podman/v2/pkg/rootless" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/pkg/rootless" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index 4a11802c3..8c388d0ee 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -9,7 +9,7 @@ import ( "strconv" "text/template" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/secret_test.go b/test/e2e/secret_test.go index 6dad605c5..fbee18442 100644 --- a/test/e2e/secret_test.go +++ b/test/e2e/secret_test.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/start_test.go b/test/e2e/start_test.go index 74be105d8..f527b67f6 100644 --- a/test/e2e/start_test.go +++ b/test/e2e/start_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" diff --git a/test/e2e/stats_test.go b/test/e2e/stats_test.go index 53aa230e9..2218d72b5 100644 --- a/test/e2e/stats_test.go +++ b/test/e2e/stats_test.go @@ -8,7 +8,7 @@ import ( "strconv" "time" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/stop_test.go b/test/e2e/stop_test.go index 337fd651d..dd264eb0d 100644 --- a/test/e2e/stop_test.go +++ b/test/e2e/stop_test.go @@ -5,7 +5,7 @@ import ( "os" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/system_connection_test.go b/test/e2e/system_connection_test.go index a23d50f29..4697cf860 100644 --- a/test/e2e/system_connection_test.go +++ b/test/e2e/system_connection_test.go @@ -6,7 +6,7 @@ import ( "os" "github.com/containers/common/pkg/config" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gbytes" diff --git a/test/e2e/system_df_test.go b/test/e2e/system_df_test.go index 050a01805..9daf3f8f9 100644 --- a/test/e2e/system_df_test.go +++ b/test/e2e/system_df_test.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/system_reset_test.go b/test/e2e/system_reset_test.go index e716ce4f3..fcfcdaf85 100644 --- a/test/e2e/system_reset_test.go +++ b/test/e2e/system_reset_test.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go index 49ab3b8ed..b132750b0 100644 --- a/test/e2e/systemd_test.go +++ b/test/e2e/systemd_test.go @@ -6,7 +6,7 @@ import ( "strings" "time" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/tag_test.go b/test/e2e/tag_test.go index 8e8264e9d..83b6d023d 100644 --- a/test/e2e/tag_test.go +++ b/test/e2e/tag_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/toolbox_test.go b/test/e2e/toolbox_test.go index 6de775983..d605b59f9 100644 --- a/test/e2e/toolbox_test.go +++ b/test/e2e/toolbox_test.go @@ -35,8 +35,8 @@ import ( "strings" "syscall" - "github.com/containers/podman/v2/pkg/rootless" - . "github.com/containers/podman/v2/test/utils" + "github.com/containers/podman/v3/pkg/rootless" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/top_test.go b/test/e2e/top_test.go index c182b88e6..d7105b17a 100644 --- a/test/e2e/top_test.go +++ b/test/e2e/top_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/tree_test.go b/test/e2e/tree_test.go index 9bdc3af9d..184b99dfb 100644 --- a/test/e2e/tree_test.go +++ b/test/e2e/tree_test.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/trust_test.go b/test/e2e/trust_test.go index 19e576490..ae7b987ae 100644 --- a/test/e2e/trust_test.go +++ b/test/e2e/trust_test.go @@ -6,7 +6,7 @@ import ( "os" "path/filepath" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/unshare_test.go b/test/e2e/unshare_test.go index 182a65775..515b3a42e 100644 --- a/test/e2e/unshare_test.go +++ b/test/e2e/unshare_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/untag_test.go b/test/e2e/untag_test.go index 4d4f60f0c..d0d271715 100644 --- a/test/e2e/untag_test.go +++ b/test/e2e/untag_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/version_test.go b/test/e2e/version_test.go index 903748b58..75986e671 100644 --- a/test/e2e/version_test.go +++ b/test/e2e/version_test.go @@ -4,8 +4,8 @@ import ( "fmt" "os" - . "github.com/containers/podman/v2/test/utils" - "github.com/containers/podman/v2/version" + . "github.com/containers/podman/v3/test/utils" + "github.com/containers/podman/v3/version" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" diff --git a/test/e2e/volume_create_test.go b/test/e2e/volume_create_test.go index 544532ee0..ab65146eb 100644 --- a/test/e2e/volume_create_test.go +++ b/test/e2e/volume_create_test.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/volume_exists_test.go b/test/e2e/volume_exists_test.go index 6073c6d90..edbeb2c69 100644 --- a/test/e2e/volume_exists_test.go +++ b/test/e2e/volume_exists_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/test/e2e/volume_inspect_test.go b/test/e2e/volume_inspect_test.go index 7ff1d63b4..05aaf1025 100644 --- a/test/e2e/volume_inspect_test.go +++ b/test/e2e/volume_inspect_test.go @@ -4,7 +4,7 @@ import ( "os" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/volume_ls_test.go b/test/e2e/volume_ls_test.go index 5c466124d..cb5ecbcc3 100644 --- a/test/e2e/volume_ls_test.go +++ b/test/e2e/volume_ls_test.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" diff --git a/test/e2e/volume_plugin_test.go b/test/e2e/volume_plugin_test.go index 16edab27c..183050e8c 100644 --- a/test/e2e/volume_plugin_test.go +++ b/test/e2e/volume_plugin_test.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/volume_prune_test.go b/test/e2e/volume_prune_test.go index a910c47a7..1d4e64ec7 100644 --- a/test/e2e/volume_prune_test.go +++ b/test/e2e/volume_prune_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/volume_rm_test.go b/test/e2e/volume_rm_test.go index cdced1f13..883a503c4 100644 --- a/test/e2e/volume_rm_test.go +++ b/test/e2e/volume_rm_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/e2e/wait_test.go b/test/e2e/wait_test.go index 4f1e74977..71df28ca8 100644 --- a/test/e2e/wait_test.go +++ b/test/e2e/wait_test.go @@ -3,7 +3,7 @@ package integration import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/python/__init__.py b/test/python/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/test/python/__init__.py diff --git a/test/python/docker/__init__.py b/test/python/docker/__init__.py index 351834316..da5630eac 100644 --- a/test/python/docker/__init__.py +++ b/test/python/docker/__init__.py @@ -8,7 +8,7 @@ import tempfile from docker import DockerClient -from test.python.docker import constant +from .compat import constant class Podman(object): @@ -39,7 +39,9 @@ class Podman(object): 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") + os.environ["REGISTRIES_CONFIG_PATH"] = os.path.join( + self.anchor_directory, "registry.conf" + ) p = configparser.ConfigParser() p.read_dict( { @@ -51,10 +53,14 @@ class Podman(object): 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.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") + 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( """ diff --git a/test/python/docker/README.md b/test/python/docker/compat/README.md index c10fd636d..50796d66b 100644 --- a/test/python/docker/README.md +++ b/test/python/docker/compat/README.md @@ -13,26 +13,26 @@ To run the tests locally in your sandbox (Fedora 32,33): ### Run the entire test suite +All commands are run from the root of the repository. + ```shell -# python3 -m unittest discover test/python/docker +# python3 -m unittest discover -s test/python/docker ``` Passing the -v option to your test script will instruct unittest.main() to enable a higher level of verbosity, and produce detailed output: ```shell -# python3 -m unittest -v discover test/python/docker +# python3 -m unittest -v discover -s test/python/docker ``` ### Run a specific test class ```shell -# cd test/python/docker -# python3 -m unittest -v tests.test_images +# python3 -m unittest -v test.python.docker.compat.test_images.TestImages ``` ### Run a specific test within the test class ```shell -# cd test/python/docker -# python3 -m unittest tests.test_images.TestImages.test_import_image +# python3 -m unittest test.python.docker.compat.test_images.TestImages.test_tag_valid_image ``` diff --git a/test/python/docker/compat/__init__.py b/test/python/docker/compat/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/test/python/docker/compat/__init__.py diff --git a/test/python/docker/common.py b/test/python/docker/compat/common.py index 11f512495..bdc67c287 100644 --- a/test/python/docker/common.py +++ b/test/python/docker/compat/common.py @@ -1,10 +1,12 @@ from docker import DockerClient -from test.python.docker import constant +from test.python.docker.compat import constant def run_top_container(client: DockerClient): - c = client.containers.create(constant.ALPINE, command="top", detach=True, tty=True, name="top") + c = client.containers.create( + constant.ALPINE, command="top", detach=True, tty=True, name="top" + ) c.start() return c.id diff --git a/test/python/docker/constant.py b/test/python/docker/compat/constant.py index 892293c97..892293c97 100644 --- a/test/python/docker/constant.py +++ b/test/python/docker/compat/constant.py diff --git a/test/python/docker/test_containers.py b/test/python/docker/compat/test_containers.py index 337cacd5c..be70efa67 100644 --- a/test/python/docker/test_containers.py +++ b/test/python/docker/compat/test_containers.py @@ -5,7 +5,8 @@ import unittest from docker import DockerClient, errors -from test.python.docker import Podman, common, constant +from test.python.docker import Podman +from test.python.docker.compat import common, constant class TestContainers(unittest.TestCase): @@ -87,9 +88,11 @@ class TestContainers(unittest.TestCase): self.assertEqual(len(containers), 2) def test_start_container_with_random_port_bind(self): - container = self.client.containers.create(image=constant.ALPINE, - name="containerWithRandomBind", - ports={'1234/tcp': None}) + container = self.client.containers.create( + image=constant.ALPINE, + name="containerWithRandomBind", + ports={"1234/tcp": None}, + ) containers = self.client.containers.list(all=True) self.assertTrue(container in containers) diff --git a/test/python/docker/test_images.py b/test/python/docker/compat/test_images.py index f2b6a5190..842e38f31 100644 --- a/test/python/docker/test_images.py +++ b/test/python/docker/compat/test_images.py @@ -7,7 +7,8 @@ import unittest from docker import DockerClient, errors -from test.python.docker import Podman, common, constant +from test.python.docker import Podman +from test.python.docker.compat import common, constant class TestImages(unittest.TestCase): @@ -78,7 +79,9 @@ class TestImages(unittest.TestCase): self.assertEqual(len(self.client.images.list()), 2) # List images with filter - self.assertEqual(len(self.client.images.list(filters={"reference": "alpine"})), 1) + self.assertEqual( + len(self.client.images.list(filters={"reference": "alpine"})), 1 + ) def test_search_image(self): """Search for image""" @@ -91,7 +94,7 @@ class TestImages(unittest.TestCase): r = self.client.images.search("bogus/bogus") except: return - self.assertTrue(len(r)==0) + self.assertTrue(len(r) == 0) def test_remove_image(self): """Remove image""" diff --git a/test/python/docker/test_system.py b/test/python/docker/compat/test_system.py index 46b90e5f6..131b18991 100644 --- a/test/python/docker/test_system.py +++ b/test/python/docker/compat/test_system.py @@ -5,7 +5,8 @@ import unittest from docker import DockerClient -from test.python.docker import Podman, common, constant +from test.python.docker import Podman, constant +from test.python.docker.compat import common class TestSystem(unittest.TestCase): diff --git a/test/python/requirements.txt b/test/python/requirements.txt new file mode 100644 index 000000000..ee85bf1d1 --- /dev/null +++ b/test/python/requirements.txt @@ -0,0 +1,6 @@ +docker~=4.4.3 + +requests~=2.20.0 +setuptools~=50.3.2 +python-dateutil~=2.8.1 +PyYAML~=5.4.1 diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 93449ece9..b2999a9e7 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -139,7 +139,7 @@ echo $rand | 0 | $rand is "$output" "" "--pull=never [present]: no output" # Now test with a remote image which we don't have present (the 00 tag) - NONLOCAL_IMAGE="$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:00000000" + NONLOCAL_IMAGE="$PODMAN_NONLOCAL_IMAGE_FQN" run_podman 125 run --pull=never $NONLOCAL_IMAGE true is "$output" "Error: unable to find a name and tag match for $NONLOCAL_IMAGE in repotags: no such image" "--pull=never [with image not present]: error" @@ -175,7 +175,7 @@ echo $rand | 0 | $rand # 'run --rmi' deletes the image in the end unless it's used by another container @test "podman run --rmi" { # Name of a nonlocal image. It should be pulled in by the first 'run' - NONLOCAL_IMAGE="$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:00000000" + NONLOCAL_IMAGE="$PODMAN_NONLOCAL_IMAGE_FQN" run_podman 1 image exists $NONLOCAL_IMAGE # Run a container, without --rm; this should block subsequent --rmi diff --git a/test/system/055-rm.bats b/test/system/055-rm.bats index 0107114b5..a5770f20f 100644 --- a/test/system/055-rm.bats +++ b/test/system/055-rm.bats @@ -51,6 +51,13 @@ load helpers run_podman rm $rand $external_cid } +@test "podman rm <-> run --rm race" { + # A container's lock is released before attempting to stop it. This opens + # the window for race conditions that led to #9479. + run_podman run --rm -d $IMAGE sleep infinity + run_podman rm -af +} + # I'm sorry! This test takes 13 seconds. There's not much I can do about it, # please know that I think it's justified: podman 1.5.0 had a strange bug # in with exit status was not preserved on some code paths with 'rm -f' diff --git a/test/system/065-cp.bats b/test/system/065-cp.bats index 0fcc437d4..312106b36 100644 --- a/test/system/065-cp.bats +++ b/test/system/065-cp.bats @@ -475,9 +475,9 @@ load helpers run_podman exec cpcontainer rm -rf /tmp/$srcdir # Now for "/dev/stdin". + # Note: while this works, the content ends up in Nirvana. + # Same for Docker. run_podman cp /dev/stdin cpcontainer:/tmp < $tar_file - run_podman exec cpcontainer cat /tmp/$srcdir/$rand_filename - is "$output" "$rand_content" # Error checks below ... @@ -487,11 +487,11 @@ load helpers # Destination must be a directory (on an existing file). run_podman exec cpcontainer touch /tmp/file.txt - run_podman 125 cp /dev/stdin cpcontainer:/tmp/file.txt < $tar_file + run_podman 125 cp - cpcontainer:/tmp/file.txt < $tar_file is "$output" 'Error: destination must be a directory when copying from stdin' # Destination must be a directory (on an absent path). - run_podman 125 cp /dev/stdin cpcontainer:/tmp/IdoNotExist < $tar_file + run_podman 125 cp - cpcontainer:/tmp/IdoNotExist < $tar_file is "$output" 'Error: destination must be a directory when copying from stdin' run_podman rm -f cpcontainer @@ -508,6 +508,10 @@ load helpers run_podman exec cpcontainer sh -c "echo '$rand_content' > /tmp/file.txt" run_podman exec cpcontainer touch /tmp/empty.txt + # Make sure that only "-" gets special treatment. "/dev/stdout" + run_podman 125 cp cpcontainer:/tmp/file.txt /dev/stdout + is "$output" 'Error: invalid destination: "/dev/stdout" must be a directory or a regular file' + # Copying from stdout will always compress. So let's copy the previously # created file from the container via stdout, untar the archive and make # sure the file exists with the expected content. diff --git a/test/system/070-build.bats b/test/system/070-build.bats index c18f3f7a7..1e7d366a1 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -305,8 +305,10 @@ Cmd[0] | /bin/mydefaultcmd Cmd[1] | $s_echo WorkingDir | $workdir Labels.$label_name | $label_value -Labels.\"io.buildah.version\" | $buildah_version " + # FIXME: 2021-02-24: Fixed in buildah #3036; reenable this once podman + # vendors in a newer buildah! + # Labels.\"io.buildah.version\" | $buildah_version parse_table "$tests" | while read field expect; do actual=$(jq -r ".[0].Config.$field" <<<"$output") @@ -478,6 +480,45 @@ EOF run_podman rmi -a --force } +@test "build with copy-from referencing the base image" { + skip_if_rootless "cannot mount as rootless" + target=busybox-derived + target_mt=busybox-mt-derived + tmpdir=$PODMAN_TMPDIR/build-test + mkdir -p $tmpdir + containerfile1=$tmpdir/Containerfile1 + cat >$containerfile1 <<EOF +FROM quay.io/libpod/busybox AS build +RUN rm -f /bin/paste +USER 1001 +COPY --from=quay.io/libpod/busybox /bin/paste /test/ +EOF + containerfile2=$tmpdir/Containerfile2 + cat >$containerfile2 <<EOF +FROM quay.io/libpod/busybox AS test +RUN rm -f /bin/nl +FROM quay.io/libpod/alpine AS final +COPY --from=quay.io/libpod/busybox /bin/nl /test/ +EOF + run_podman build -t ${target} -f ${containerfile1} ${tmpdir} + run_podman build --jobs 4 -t ${target} -f ${containerfile1} ${tmpdir} + + run_podman build -t ${target} -f ${containerfile2} ${tmpdir} + run_podman build --no-cache --jobs 4 -t ${target_mt} -f ${containerfile2} ${tmpdir} + + # (can only test locally; podman-remote has no image mount command) + if ! is_remote; then + run_podman image mount ${target} + root_single_job=$output + + run_podman image mount ${target_mt} + root_multi_job=$output + + # Check that both the version with --jobs 1 and --jobs=N have the same number of files + test $(find $root_single_job -type f | wc -l) = $(find $root_multi_job -type f | wc -l) + fi +} + @test "podman build --logfile test" { tmpdir=$PODMAN_TMPDIR/build-test mkdir -p $tmpdir diff --git a/test/e2e/test.yaml b/test/system/700-play.bats index 98d2c91df..e7904f59f 100644 --- a/test/e2e/test.yaml +++ b/test/system/700-play.bats @@ -1,13 +1,17 @@ -# Save the output of this file and use kubectl create -f to import -# it into Kubernetes. +#!/usr/bin/env bats -*- bats -*- # -# Created with podman-1.6.2 +# Test podman play +# + +load helpers + +testYaml=" apiVersion: v1 kind: Pod metadata: labels: app: test - name: test + name: test_pod spec: containers: - command: @@ -20,7 +24,7 @@ spec: value: xterm - name: container value: podman - image: docker.io/library/fedora:latest + image: quay.io/libpod/alpine:latest name: test resources: {} securityContext: @@ -31,7 +35,20 @@ spec: capabilities: {} privileged: false seLinuxOptions: - level: "s0:c1,c2" + level: "s0:c1,c2" readOnlyRootFilesystem: false workingDir: / status: {} +" + +@test "podman play with stdin" { + echo "$testYaml" > $PODMAN_TMPDIR/test.yaml + run_podman play kube - < $PODMAN_TMPDIR/test.yaml + run_podman pod rm -f test_pod +} + +@test "podman play" { + echo "$testYaml" > $PODMAN_TMPDIR/test.yaml + run_podman play kube $PODMAN_TMPDIR/test.yaml + run_podman pod rm -f test_pod +} diff --git a/test/system/build-testimage b/test/system/build-testimage index 53ade57f0..aac08e307 100755 --- a/test/system/build-testimage +++ b/test/system/build-testimage @@ -12,6 +12,9 @@ # still need a fedora image for that. # +# Buildah binary +BUILDAH=${BUILDAH:-buildah} + # Tag for this new image YMD=$(date +%Y%m%d) @@ -58,7 +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 -FROM docker.io/library/alpine:3.12.0 +ARG ARCH=please-override-arch +FROM docker.io/\${ARCH}/alpine:3.12.0 RUN apk add busybox-extras ADD testimage-id pause /home/podman/ LABEL created_by=$create_script @@ -69,26 +73,44 @@ EOF # --squash-all : needed by 'tree' test in 070-build.bats podman rmi -f testimage &> /dev/null || true -podman build --squash-all -t testimage . + +# 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 ppc64le s390x;do + ${BUILDAH} bud \ + --arch=$arch \ + --build-arg ARCH=$arch \ + --manifest=testimage \ + --squash \ + . +done # Clean up cd /tmp rm -rf $tmpdir -# Tag and push to quay. -podman tag testimage quay.io/libpod/testimage:$YMD -podman push quay.io/libpod/testimage:$YMD +# 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} -# Side note: there should always be a testimage tagged ':00000000' -# (eight zeroes) 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'. +# 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 2020-09-02 it is simply busybox, because it is super small: +# As of 2021-02-24 it is simply busybox, because it is super small, +# but it's complicated because of multiarch: # -# podman pull docker.io/library/busybox:1.32.0 -# podman tag docker.io/library/busybox:1.32.0 \ -# quay.io/libpod/testimage:00000000 -# podman push quay.io/libpod/testimage:00000000 +# img=quay.io/libpod/testimage:00000001 +# buildah manifest create $img +# for arch in amd64 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 # diff --git a/test/system/helpers.bash b/test/system/helpers.bash index 0572c6866..38e317709 100644 --- a/test/system/helpers.bash +++ b/test/system/helpers.bash @@ -7,9 +7,14 @@ 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:-"20200929"} +PODMAN_TEST_IMAGE_TAG=${PODMAN_TEST_IMAGE_TAG:-"20210223"} PODMAN_TEST_IMAGE_FQN="$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:$PODMAN_TEST_IMAGE_TAG" +# 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:00000001" + # Because who wants to spell that out each time? IMAGE=$PODMAN_TEST_IMAGE_FQN @@ -149,7 +154,7 @@ function run_podman() { echo "$_LOG_PROMPT $PODMAN $*" # BATS hangs if a subprocess remains and keeps FD 3 open; this happens # if podman crashes unexpectedly without cleaning up subprocesses. - run timeout --foreground -v --kill=10 $PODMAN_TIMEOUT $PODMAN "$@" 3>/dev/null + run timeout --foreground -v --kill=10 $PODMAN_TIMEOUT $PODMAN $_PODMAN_TEST_OPTS "$@" 3>/dev/null # without "quotes", multiple lines are glommed together into one if [ -n "$output" ]; then echo "$output" diff --git a/test/upgrade/README.md b/test/upgrade/README.md new file mode 100644 index 000000000..2979a66d7 --- /dev/null +++ b/test/upgrade/README.md @@ -0,0 +1,87 @@ +Background +========== + +For years we've been needing a way to test podman upgrades; this +became much more critical on December 7, 2020, when Matt disclosed +a bug he had found over the weekend +([#8613](https://github.com/containers/podman/issues/8613)) +in which reuse of a previously-defined field name would +result in fatal JSON decode failures if current-podman were +to try reading containers created with podman <= 1.8 (FIXME: confirm) + +Upgrade testing is a daunting problem; but in the December 12 +Cabal meeting Dan suggested using podman-in-podman. This PR +is the result of fleshing out that idea. + +Overview +======== + +The BATS script in this directory fetches and runs an old-podman +container image from quay.io/podman, uses it to create and run +a number of containers, then uses new-podman to interact with +those containers. + +As of 2021-02-23 the available old-podman versions are: + +```console +$ ./bin/podman search --list-tags quay.io/podman/stable | awk '$2 ~ /^v/ { print $2}' | sort | column -c 75 +v1.4.2 v1.5.0 v1.6 v1.9.0 v2.0.2 v2.1.1 +v1.4.4 v1.5.1 v1.6.2 v1.9.1 v2.0.6 v2.2.1 +``` + +Test invocation is: +```console +$ sudo env PODMAN=bin/podman PODMAN_UPGRADE_FROM=v1.9.0 PODMAN_UPGRADE_TEST_DEBUG= bats test/upgrade +``` +(Path assumes you're cd'ed to top-level podman repo). `PODMAN_UPGRADE_FROM` +can be any of the versions above. `PODMAN_UPGRADE_TEST_DEBUG` is empty +here, but listed so you can set it `=1` and leave the podman_parent +container running. Interacting with this container is left as an +exercise for the reader. + +The script will pull the given podman image, invoke it with a scratch +root directory, and have it do a small set of podman stuff (pull an +image, create/run some containers). This podman process stays running +because if it exits, it kills containers running inside the container. + +We then invoke the current (host-installed) podman, using the same +scratch root directory, and perform operations on those images and +containers. Most of those operations are done in individual @tests. + +The goal is to have this upgrade test run in CI, iterating over a +loop of known old versions. This list would need to be hand-maintained +and updated on new releases. There might also need to be extra +configuration defined, such as per-version commands (see below). + +Findings +======== + +Well, first, `v1.6.2` won't work on default f32/f33: the image +does not include `crun`, so it can't work at all: + + ERRO[0000] oci runtime "runc" does not support CGroups V2: use system migrate to mitigate + +I realize that it's kind of stupid not to test 1.6, since that's +precisely the test that would've caught #8613 early, but I just +don't think it's worth the hassle of setting up cgroupsv1 VMs. + +For posterity, in an earlier incantation of this script I tried +booting f32 into cgroupsv1 and ran into the following warnings +when running new-podman on old-containers: +``` +ERRO[0000] error joining network namespace for container 322b66d94640e31b2e6921565445cf0dade4ec13cabc16ee5f29292bdc038341: error retrieving network namespace at /var/run/netns/cni-577e2289-2c05-2e28-3c3d-002a5596e7da: failed to Statfs "/var/run/netns/cni-577e2289 +``` + +Where To Go From Here +===================== + +* Tests are still (2021-02-23) incomplete, with several failing outright. + See FIXMEs in the code. + +* Figuring out how/if to run rootless. I think this is possible, perhaps + even necessary, but will be tricky to get right because of home-directory + mounting. + +* Figuring out how/if to run variations with different config files + (e.g. running OLD-PODMAN that creates a user libpod.conf, tweaking + that in the test, then running NEW-PODMAN upgrate tests) diff --git a/test/upgrade/helpers.bash b/test/upgrade/helpers.bash new file mode 100644 index 000000000..41d9279e6 --- /dev/null +++ b/test/upgrade/helpers.bash @@ -0,0 +1,11 @@ +# -*- bash -*- + +load "../system/helpers" + +setup() { + : +} + +teardown() { + : +} diff --git a/test/upgrade/test-upgrade.bats b/test/upgrade/test-upgrade.bats new file mode 100644 index 000000000..dd827b398 --- /dev/null +++ b/test/upgrade/test-upgrade.bats @@ -0,0 +1,313 @@ +# -*- bats -*- + +load helpers + +# Create a var-lib-containers dir for this podman. We need to bind-mount +# this into the container, and use --root and --runroot and --tmpdir +# options both in the container podman and out here: that's the only +# way to share image and container storage. +if [ -z "${PODMAN_UPGRADE_WORKDIR}" ]; then + # Much as I'd love a descriptive name like "podman-upgrade-tests.XXXXX", + # keep it short ("pu") because of the 100-character path length limit + # for UNIX sockets (needed by conmon) + export PODMAN_UPGRADE_WORKDIR=$(mktemp -d --tmpdir=${BATS_TMPDIR:-${TMPDIR:-/tmp}} pu.XXXXXX) + + touch $PODMAN_UPGRADE_WORKDIR/status +fi + +# Generate a set of random strings used for content verification +if [ -z "${RANDOM_STRING_1}" ]; then + export RANDOM_STRING_1=$(random_string 15) + export LABEL_CREATED=$(random_string 16) + export LABEL_FAILED=$(random_string 17) + export LABEL_RUNNING=$(random_string 18) + + # FIXME: randomize this + HOST_PORT=34567 +fi + +# Version string of the podman we're actually testing, e.g. '3.0.0-dev-d1a26013' +PODMAN_VERSION=$($PODMAN version |awk '/^Version:/ { V=$2 } /^Git Commit:/ { G=$3 } END { print V "-" substr(G,0,8) }') + +setup() { + skip_if_rootless + + # The podman-in-podman image (old podman) + if [[ -z "$PODMAN_UPGRADE_FROM" ]]; then + echo "# \$PODMAN_UPGRADE_FROM is undefined (should be e.g. v1.9.0)" >&3 + false + fi + + if [ "$(< $PODMAN_UPGRADE_WORKDIR/status)" = "failed" ]; then + # FIXME: exit instead? + echo "*** setup failed - no point in running tests" + false + fi + + export _PODMAN_TEST_OPTS="--root=$PODMAN_UPGRADE_WORKDIR/root --runroot=$PODMAN_UPGRADE_WORKDIR/runroot --tmpdir=$PODMAN_UPGRADE_WORKDIR/tmp" +} + +############################################################################### +# BEGIN setup + +@test "initial setup: start $PODMAN_UPGRADE_FROM containers" { + echo failed >| $PODMAN_UPGRADE_WORKDIR/status + + OLD_PODMAN=quay.io/podman/stable:$PODMAN_UPGRADE_FROM + $PODMAN pull $OLD_PODMAN + + # Shortcut name, because we're referencing it a lot + pmroot=$PODMAN_UPGRADE_WORKDIR + + # WWW content to share + mkdir -p $pmroot/var/www + echo $RANDOM_STRING_1 >$pmroot/var/www/index.txt + + # podman tmpdir + mkdir -p $pmroot/tmp + + # + # Script to run >>OLD<< podman commands. + # + # These commands will be run inside a podman container. The "podman" + # command in this script will be the desired old-podman version. + # + pmscript=$pmroot/setup + cat >| $pmscript <<EOF +#!/bin/bash + +# cgroup-manager=systemd does not work inside a container +opts="--cgroup-manager=cgroupfs --events-backend=file $_PODMAN_TEST_OPTS" + +set -ex + +# Try try again, because network flakiness makes this a point of failure +podman \$opts pull $IMAGE \ + || (sleep 10; podman \$opts pull $IMAGE) \ + || (sleep 30; podman \$opts pull $IMAGE) + + +podman \$opts create --name mycreatedcontainer --label mylabel=$LABEL_CREATED \ + $IMAGE false + +podman \$opts run --name mydonecontainer $IMAGE echo ++$RANDOM_STRING_1++ + +podman \$opts run --name myfailedcontainer --label mylabel=$LABEL_FAILED \ + $IMAGE sh -c 'exit 17' || true + +# FIXME: add "-p $HOST_PORT:80" +# ...I tried and tried, and could not get this to work. I could never +# connect to the port from the host, nor even from the podman_parent +# container; I could never see the port listed in 'ps' nor 'inspect'. +# And, finally, I ended up in a state where the container wouldn't +# even start, and via complicated 'podman logs' found out: +# httpd: bind: Address in use +# So I just give up for now. +# +podman \$opts run -d --name myrunningcontainer --label mylabel=$LABEL_RUNNING \ + -v $pmroot/var/www:/var/www \ + -w /var/www \ + $IMAGE /bin/busybox-extras httpd -f -p 80 + +echo READY +while :;do + if [ -e /stop ]; then + echo STOPPING + podman \$opts stop -t 0 myrunningcontainer || true + podman \$opts rm -f myrunningcontainer || true + exit 0 + fi + sleep 0.5 +done +EOF + chmod 555 $pmscript + + # Clean up vestiges of previous run + $PODMAN rm -f podman_parent || true + + # Not entirely a NOP! This is just so we get /run/crun created on a CI VM + $PODMAN run --rm $OLD_PODMAN true + + # + # Use new-podman to run the above script under old-podman. + # + # DO NOT USE run_podman HERE! That would use $_PODMAN_TEST_OPTS + # and would write into our shared test dir, which would then + # pollute it for use by old-podman. We must keep that pristine + # so old-podman is the first to write to it. + # + $PODMAN run -d --name podman_parent --pid=host \ + --privileged \ + --net=host \ + --cgroupns=host \ + -v /dev/fuse:/dev/fuse \ + -v /run/crun:/run/crun \ + -v $pmroot:$pmroot \ + $OLD_PODMAN $pmroot/setup + + _PODMAN_TEST_OPTS= wait_for_ready podman_parent + + echo OK >| $PODMAN_UPGRADE_WORKDIR/status +} + +# END setup +############################################################################### +# BEGIN actual tests + +# This is a NOP; used only so the version string will show up in logs +@test "upgrade: $PODMAN_UPGRADE_FROM -> $PODMAN_VERSION" { + : +} + +@test "images" { + run_podman images -a --format '{{.Names}}' + is "$output" "\[$IMAGE\]" "podman images" +} + +@test "ps : one container running" { + run_podman ps --format '{{.Image}}--{{.Names}}' + is "$output" "$IMAGE--myrunningcontainer" "ps: one container running" +} + +@test "ps -a : shows all containers" { + # IMPORTANT: we can't use --sort=created, because that requires #8427 + # on the *creating* podman end. + run_podman ps -a \ + --format '{{.Names}}--{{.Status}}--{{.Ports}}--{{.Labels.mylabel}}' \ + --sort=names + is "${lines[0]}" "mycreatedcontainer--Created----$LABEL_CREATED" "created" + is "${lines[1]}" "mydonecontainer--Exited (0).*----<no value>" "done" + is "${lines[2]}" "myfailedcontainer--Exited (17) .*----$LABEL_FAILED" "fail" + is "${lines[3]}" "myrunningcontainer--Up .*----$LABEL_RUNNING" "running" + + # For debugging: dump containers and IDs + if [[ -n "$PODMAN_UPGRADE_TEST_DEBUG" ]]; then + run_podman ps -a + for l in "${lines[@]}"; do + echo "# $l" >&3 + done + fi +} + + +@test "inspect - all container status" { + tests=" +running | running | 0 +created | configured | 0 +done | exited | 0 +failed | exited | 17 +" + while read cname state exitstatus; do + run_podman inspect --format '{{.State.Status}}--{{.State.ExitCode}}' my${cname}container + is "$output" "$state--$exitstatus" "status of my${cname}container" + done < <(parse_table "$tests") +} + +@test "logs" { + run_podman logs mydonecontainer + is "$output" "++$RANDOM_STRING_1++" "podman logs on stopped container" + +# run_podman logs myrunningcontainer +# is "$output" "READY" "podman logs on running container" +} + +@test "exec" { + run_podman exec myrunningcontainer cat /var/www/index.txt + is "$output" "$RANDOM_STRING_1" "exec into myrunningcontainer" +} + +@test "load" { + # FIXME, is this really necessary? + skip "TBI. Not sure if there's any point to this." +} + +@test "mount" { + skip "TBI" +} + +@test "pods" { + skip "TBI" +} + +# FIXME: commit? kill? network? pause? restart? top? volumes? What else? + + +@test "start" { + skip "FIXME: this leaves a mount behind: root/overlay/sha/merged" + run_podman --cgroup-manager=cgroupfs start -a mydonecontainer + is "$output" "++$RANDOM_STRING_1++" "start on already-run container" +} + +@test "rm a stopped container" { + # FIXME FIXME FIXME! + # + # I have no idea what's going on here. For most of my testing in this + # section, the code here was simply 'podman rm myfailedcontainer', and + # it would succeed, but then way down, in 'cleanup' below, the 'rm -f' + # step would fail: + # + # # podman rm -f podman_parent + # error freeing lock for container <sha>: no such file or directory + # ...where <sha> is the ID of the podman_parent container. + # + # I started playing with this section, by adding 'rm mydonecontainer', + # and now it always fails, the same way, but with the container we're + # removing right here: + # + # error freeing lock for container <sha>: no such file or directory + # ...where <sha> is the ID of mydonecontainer. + # + # I don't know. I give up for now, and am skip'ing the whole thing. + # If you want to play with it, try commenting out the 'myfailed' lines, + # or just the 'mydone' ones, or, I don't know. + skip "FIXME: error freeing lock for container <sha>: no such file or dir" + + # For debugging, so we can see what 'error freeing lock' refers to + run_podman ps -a + + run_podman rm myfailedcontainer + is "$output" "[0-9a-f]\\{64\\}" "podman rm myfailedcontainer" + + run_podman rm mydonecontainer + is "$output" "[0-9a-f]\\{64\\}" "podman rm mydonecontainer" +} + + +@test "stop and rm" { + # About a ten-second pause, then: + # Error: timed out waiting for file /tmp/pu.nf747w/tmp/exits/<sha>: internal libpod error + # It doesn't seem to be a socket-length issue: the paths are ~80-88 chars. + # Leaving podman_parent running, and exec'ing into it, it doesn't look + # like the file is being written to the wrong place. + skip "FIXME: this doesn't work: timed out waiting for file tmpdir/exits/sha" + run_podman stop myrunningcontainer + run_podman rm myrunningcontainer +} + +@test "clean up parent" { + if [[ -n "$PODMAN_UPGRADE_TEST_DEBUG" ]]; then + skip "workdir is $PODMAN_UPGRADE_WORKDIR" + fi + + # We're done with shared environment. By clearing this, we can now + # use run_podman for actions on the podman_parent container + unset _PODMAN_TEST_OPTS + + # (Useful for debugging the 'rm -f' step below, which, when it fails, only + # gives a container ID. This 'ps' confirms that the CID is podman_parent) + run_podman ps -a + + # Stop the container gracefully + run_podman exec podman_parent touch /stop + run_podman wait podman_parent + + run_podman logs podman_parent + run_podman rm -f podman_parent + + # FIXME: why does this remain mounted? + umount $PODMAN_UPGRADE_WORKDIR/root/overlay || true + + rm -rf $PODMAN_UPGRADE_WORKDIR +} + +# FIXME: now clean up diff --git a/test/utils/common_function_test.go b/test/utils/common_function_test.go index 2f9e6f2c7..003d490ce 100644 --- a/test/utils/common_function_test.go +++ b/test/utils/common_function_test.go @@ -8,7 +8,7 @@ import ( "reflect" "strings" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/extensions/table" . "github.com/onsi/gomega" diff --git a/test/utils/podmansession_test.go b/test/utils/podmansession_test.go index 763cb4f26..d85f27bbb 100644 --- a/test/utils/podmansession_test.go +++ b/test/utils/podmansession_test.go @@ -1,7 +1,7 @@ package utils_test import ( - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/utils/podmantest_test.go b/test/utils/podmantest_test.go index 538d55d8d..9bd1c4a66 100644 --- a/test/utils/podmantest_test.go +++ b/test/utils/podmantest_test.go @@ -3,7 +3,7 @@ package utils_test import ( "os" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/test/utils/utils.go b/test/utils/utils.go index 6790f31cd..80af7fb7c 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -482,3 +482,13 @@ func RandomString(n int) string { } return string(b) } + +//SkipIfInContainer skips a test if the test is run inside a container +func SkipIfInContainer(reason string) { + if len(reason) < 5 { + panic("SkipIfInContainer must specify a reason to skip") + } + if os.Getenv("TEST_ENVIRON") == "container" { + Skip("[container]: " + reason) + } +} diff --git a/test/utils/utils_suite_test.go b/test/utils/utils_suite_test.go index 01549f06e..d5f9cbce4 100644 --- a/test/utils/utils_suite_test.go +++ b/test/utils/utils_suite_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - . "github.com/containers/podman/v2/test/utils" + . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" |