summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/apiv2/10-images.at4
-rw-r--r--test/apiv2/20-containers.at21
-rw-r--r--test/apiv2/30-volumes.at35
-rw-r--r--test/apiv2/35-networks.at66
-rw-r--r--test/apiv2/44-mounts.at21
-rw-r--r--test/apiv2/45-system.at8
-rw-r--r--test/apiv2/50-secrets.at13
-rw-r--r--test/apiv2/rest_api/test_rest_v2_0_0.py49
-rwxr-xr-xtest/apiv2/test-apiv27
-rw-r--r--test/e2e/build_test.go16
-rw-r--r--test/e2e/config/containers.conf1
-rw-r--r--test/e2e/containers_conf_test.go22
-rw-r--r--test/e2e/logs_test.go110
-rw-r--r--test/e2e/rename_test.go21
-rw-r--r--test/python/__init__.py0
-rw-r--r--test/python/docker/__init__.py14
-rw-r--r--test/python/docker/compat/README.md (renamed from test/python/docker/README.md)12
-rw-r--r--test/python/docker/compat/__init__.py0
-rw-r--r--test/python/docker/compat/common.py (renamed from test/python/docker/common.py)6
-rw-r--r--test/python/docker/compat/constant.py (renamed from test/python/docker/constant.py)0
-rw-r--r--test/python/docker/compat/test_containers.py (renamed from test/python/docker/test_containers.py)11
-rw-r--r--test/python/docker/compat/test_images.py (renamed from test/python/docker/test_images.py)9
-rw-r--r--test/python/docker/compat/test_system.py (renamed from test/python/docker/test_system.py)3
-rw-r--r--test/python/requirements.txt6
24 files changed, 270 insertions, 185 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..18364a47d 100644
--- a/test/apiv2/20-containers.at
+++ b/test/apiv2/20-containers.at
@@ -31,6 +31,13 @@ t GET libpod/containers/json?all=true 200 \
.[0].ExitCode=0 \
.[0].IsInfra=false
+# Test compat API for Network Settings
+t GET /containers/json?all=true 200 \
+ length=1 \
+ .[0].Id~[0-9a-f]\\{64\\} \
+ .[0].Image=$IMAGE \
+ .[0].NetworkSettings.Networks.podman.NetworkID=podman
+
# Make sure `limit` works.
t GET libpod/containers/json?limit=1 200 \
length=1 \
@@ -206,9 +213,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 +253,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/44-mounts.at b/test/apiv2/44-mounts.at
new file mode 100644
index 000000000..fe202576d
--- /dev/null
+++ b/test/apiv2/44-mounts.at
@@ -0,0 +1,21 @@
+# -*- sh -*-
+
+podman pull $IMAGE &>/dev/null
+
+# Test various HostConfig options
+tmpfs_name="/mytmpfs"
+t POST containers/create?name=hostconfig_test '"Image":"'$IMAGE'","Cmd":["df"],"HostConfig":{"TmpFs":{"'$tmpfs_name'":"rw"}}' 201 \
+ .Id~[0-9a-f]\\{64\\}
+cid=$(jq -r '.Id' <<<"$output")
+
+# Prior to #9512, the tmpfs would be called '/mytmpfs=rw', with the '=rw'
+t GET containers/${cid}/json 200 \
+ .HostConfig.Tmpfs[\"${tmpfs_name}\"]~rw,
+
+# Run the container, verify output
+t POST containers/${cid}/start '' 204
+t POST containers/${cid}/wait '' 200
+t GET containers/${cid}/logs?stdout=true 200
+
+like "$(<$WORKDIR/curl.result.out)" ".* ${tmpfs_name}" \
+ "'df' output includes tmpfs name"
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..c4ffb5883 100644
--- a/test/apiv2/50-secrets.at
+++ b/test/apiv2/50-secrets.at
@@ -14,18 +14,21 @@ t POST secrets/create '"Name":"mysecret","Data":"c2VjcmV0","Labels":{"fail":"fai
t POST secrets/create '"Name":"mysecret","Data":"c2VjcmV0"' 409
# secret inspect
-t GET secrets/mysecret 200\
- .Spec.Name=mysecret
+t GET secrets/mysecret 200 \
+ .Spec.Name=mysecret \
+ .Version.Index=1
# secret inspect non-existent secret
t GET secrets/bogus 404
# secret list
-t GET secrets 200\
- length=1
+t GET secrets 200 \
+ length=1 \
+ .[0].Spec.Name=mysecret \
+ .[0].Version.Index=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/build_test.go b/test/e2e/build_test.go
index c733db61c..4839d66ec 100644
--- a/test/e2e/build_test.go
+++ b/test/e2e/build_test.go
@@ -532,4 +532,20 @@ RUN grep CapEff /proc/self/status`
// Then
Expect(session.ExitCode()).To(Equal(125))
})
+
+ It("podman build --timestamp flag", func() {
+ containerfile := `FROM quay.io/libpod/alpine:latest
+RUN echo hello`
+
+ containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile")
+ err := ioutil.WriteFile(containerfilePath, []byte(containerfile), 0755)
+ Expect(err).To(BeNil())
+ session := podmanTest.Podman([]string{"build", "-t", "test", "--timestamp", "0", "--file", containerfilePath, podmanTest.TempDir})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ inspect := podmanTest.Podman([]string{"image", "inspect", "--format", "{{ .Created }}", "test"})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.OutputToString()).To(Equal("1970-01-01 00:00:00 +0000 UTC"))
+ })
})
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/containers_conf_test.go b/test/e2e/containers_conf_test.go
index 9c2260c5f..6b1a0d16e 100644
--- a/test/e2e/containers_conf_test.go
+++ b/test/e2e/containers_conf_test.go
@@ -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/logs_test.go b/test/e2e/logs_test.go
index 8f695279a..3051031a5 100644
--- a/test/e2e/logs_test.go
+++ b/test/e2e/logs_test.go
@@ -37,16 +37,18 @@ var _ = Describe("Podman logs", func() {
})
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))
+ Expect(results.OutputToString()).To(Equal("podman podman podman"))
})
It("tail two lines: "+log, func() {
@@ -73,6 +75,18 @@ var _ = Describe("Podman logs", func() {
Expect(len(results.OutputToStringArray())).To(Equal(0))
})
+ 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 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()
@@ -158,78 +172,6 @@ var _ = Describe("Podman logs", func() {
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"
@@ -259,17 +201,6 @@ var _ = Describe("Podman logs", func() {
}
})
- 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"
@@ -373,4 +304,15 @@ var _ = Describe("Podman logs", func() {
Expect(err).To(BeNil())
Expect(string(out)).To(ContainSubstring(containerName))
})
+
+ 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)))
+ })
})
diff --git a/test/e2e/rename_test.go b/test/e2e/rename_test.go
index f19413221..14696c0f6 100644
--- a/test/e2e/rename_test.go
+++ b/test/e2e/rename_test.go
@@ -89,4 +89,25 @@ var _ = Describe("podman rename", func() {
Expect(ps.ExitCode()).To(Equal(0))
Expect(ps.OutputToString()).To(ContainSubstring(newName))
})
+
+ It("Rename a running container with exec sessions", func() {
+ ctrName := "testCtr"
+ ctr := podmanTest.Podman([]string{"run", "-d", "--name", ctrName, ALPINE, "top"})
+ ctr.WaitWithDefaultTimeout()
+ Expect(ctr.ExitCode()).To(Equal(0))
+
+ exec := podmanTest.Podman([]string{"exec", "-d", ctrName, "top"})
+ exec.WaitWithDefaultTimeout()
+ Expect(exec.ExitCode()).To(Equal(0))
+
+ newName := "aNewName"
+ rename := podmanTest.Podman([]string{"rename", ctrName, newName})
+ rename.WaitWithDefaultTimeout()
+ Expect(rename.ExitCode()).To(Equal(0))
+
+ ps := podmanTest.Podman([]string{"ps", "-aq", "--filter", fmt.Sprintf("name=%s", newName), "--format", "{{ .Names }}"})
+ ps.WaitWithDefaultTimeout()
+ Expect(ps.ExitCode()).To(Equal(0))
+ Expect(ps.OutputToString()).To(ContainSubstring(newName))
+ })
})
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