summaryrefslogtreecommitdiff
path: root/test/apiv2
diff options
context:
space:
mode:
Diffstat (limited to 'test/apiv2')
-rw-r--r--test/apiv2/30-volumes.at47
-rw-r--r--test/apiv2/python/rest_api/test_v2_0_0_container.py23
2 files changed, 65 insertions, 5 deletions
diff --git a/test/apiv2/30-volumes.at b/test/apiv2/30-volumes.at
index ed606134a..5feceea7b 100644
--- a/test/apiv2/30-volumes.at
+++ b/test/apiv2/30-volumes.at
@@ -125,11 +125,6 @@ t POST libpod/volumes/prune?filters='{"label":["tes' 500 \
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
-#After prune volumes, there should be no volume existing
-t GET libpod/volumes/json 200 length=0
-
# libpod api: do not use list filters for prune
t POST libpod/volumes/prune?filters='{"name":["anyname"]}' 500 \
.cause="\"name\" is an invalid volume filter"
@@ -146,4 +141,46 @@ t POST volumes/prune?filters='{"driver":["anydriver"]}' 500 \
t POST volumes/prune?filters='{"scope":["anyscope"]}' 500 \
.cause="\"scope\" is an invalid volume filter"
+## Prune volumes using until filter
+t POST libpod/volumes/create \
+ Name=foo5 \
+ Label='{"testuntil":""}' \
+ Options='{"type":"tmpfs","o":"nodev,noexec"}}' \
+ 201 \
+ .Name=foo5 \
+ .Labels.testuntil="" \
+ .Options.type=tmpfs \
+ .Options.o=nodev,noexec
+
+# with date way back in the past, volume should not be deleted
+t POST libpod/volumes/prune?filters='{"until":["500000"]}' 200
+t GET libpod/volumes/json?filters='{"label":["testuntil"]}' 200 length=1
+
+# with date far in the future, volume should be deleted
+t POST libpod/volumes/prune?filters='{"until":["5000000000"]}' 200
+t GET libpod/volumes/json?filters='{"label":["testuntil"]}' 200 length=0
+
+t POST libpod/volumes/create \
+ Name=foo6 \
+ Label='{"testuntilcompat":""}' \
+ Options='{"type":"tmpfs","o":"nodev,noexec"}}' \
+ 201 \
+ .Name=foo6 \
+ .Labels.testuntilcompat="" \
+ .Options.type=tmpfs \
+ .Options.o=nodev,noexec
+
+# with date way back in the past, volume should not be deleted (compat api)
+t POST volumes/prune?filters='{"until":["500000"]}' 200
+t GET libpod/volumes/json?filters='{"label":["testuntilcompat"]}' 200 length=1
+
+# with date far in the future, volume should be deleted (compat api)
+t POST volumes/prune?filters='{"until":["5000000000"]}' 200
+t GET libpod/volumes/json?filters='{"label":["testuntilcompat"]}' 200 length=0
+
+## Prune volumes
+t POST libpod/volumes/prune 200
+#After prune volumes, there should be no volume existing
+t GET libpod/volumes/json 200 length=0
+
# vim: filetype=sh
diff --git a/test/apiv2/python/rest_api/test_v2_0_0_container.py b/test/apiv2/python/rest_api/test_v2_0_0_container.py
index b4b3af2df..2fab4aeb9 100644
--- a/test/apiv2/python/rest_api/test_v2_0_0_container.py
+++ b/test/apiv2/python/rest_api/test_v2_0_0_container.py
@@ -14,6 +14,13 @@ class ContainerTestCase(APITestCase):
obj = r.json()
self.assertEqual(len(obj), 1)
+ def test_list_filters(self):
+ r = requests.get(self.podman_url + "/v1.40/containers/json?filters%3D%7B%22status%22%3A%5B%22running%22%5D%7D")
+ self.assertEqual(r.status_code, 200, r.text)
+ payload = r.json()
+ containerAmnt = len(payload)
+ self.assertGreater(containerAmnt, 0)
+
def test_list_all(self):
r = requests.get(self.uri("/containers/json?all=true"))
self.assertEqual(r.status_code, 200, r.text)
@@ -25,6 +32,22 @@ class ContainerTestCase(APITestCase):
self.assertId(r.content)
_ = parse(r.json()["Created"])
+ r = requests.post(
+ self.podman_url + "/v1.40/containers/create?name=topcontainer",
+ json={"Cmd": ["top"], "Image": "alpine:latest"},
+ )
+ self.assertEqual(r.status_code, 201, r.text)
+ payload = r.json()
+ container_id = payload["Id"]
+ self.assertIsNotNone(container_id)
+
+ r = requests.get(self.podman_url + f"/v1.40/containers/{payload['Id']}/json")
+ self.assertEqual(r.status_code, 200, r.text)
+ self.assertId(r.content)
+ out = r.json()
+ state = out["State"]["Health"]
+ self.assertIsInstance(state, dict)
+
def test_stats(self):
r = requests.get(self.uri(self.resolve_container("/containers/{}/stats?stream=false")))
self.assertIn(r.status_code, (200, 409), r.text)