summaryrefslogtreecommitdiff
path: root/test/apiv2/rest_api
diff options
context:
space:
mode:
authorMilivoje Legenovic <m.legenovic@gmail.com>2021-01-31 20:32:20 +0100
committerMilivoje Legenovic <m.legenovic@gmail.com>2021-01-31 21:06:39 +0100
commit51c11fea8bb83660d10834602ea758504d2d84b8 (patch)
tree9f4b5adff4beb1b33f55ba798fee5b62515ec768 /test/apiv2/rest_api
parent2686e406a650f8ceac4b3763e0cfba16090d1c1b (diff)
downloadpodman-51c11fea8bb83660d10834602ea758504d2d84b8.tar.gz
podman-51c11fea8bb83660d10834602ea758504d2d84b8.tar.bz2
podman-51c11fea8bb83660d10834602ea758504d2d84b8.zip
Endpoint that lists containers does not return correct Status value
Eclipse and Intellij Docker plugin determines the state of the container via the Status field, returned from /containers/json call. Podman always returns empty string, and because of that, both IDEs show the wrong state of the container. Signed-off-by: Milivoje Legenovic <m.legenovic@gmail.com>
Diffstat (limited to 'test/apiv2/rest_api')
-rw-r--r--test/apiv2/rest_api/test_rest_v2_0_0.py49
1 files changed, 48 insertions, 1 deletions
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 77674e81b..c4faa1548 100644
--- a/test/apiv2/rest_api/test_rest_v2_0_0.py
+++ b/test/apiv2/rest_api/test_rest_v2_0_0.py
@@ -1,7 +1,6 @@
import json
import os
import random
-import shutil
import string
import subprocess
import sys
@@ -357,6 +356,7 @@ class TestApi(unittest.TestCase):
def test_search_compat(self):
url = PODMAN_URL + "/v1.40/images/search"
+
# Had issues with this test hanging when repositories not happy
def do_search1():
payload = {'term': 'alpine'}
@@ -619,6 +619,53 @@ class TestApi(unittest.TestCase):
# self.assertIn(img["Id"], prune_payload["ImagesDeleted"][1]["Deleted"])
self.assertIsNotNone(prune_payload["ImagesDeleted"][1]["Deleted"])
+ def test_status_compat(self):
+ r = requests.post(PODMAN_URL + "/v1.40/containers/create?name=topcontainer",
+ json={"Cmd": ["top"], "Image": "alpine:latest"})
+ self.assertEqual(r.status_code, 201, r.text)
+ payload = json.loads(r.text)
+ container_id = payload["Id"]
+ self.assertIsNotNone(container_id)
+
+ r = requests.get(PODMAN_URL + "/v1.40/containers/json",
+ params={'all': 'true', 'filters': f'{{"id":["{container_id}"]}}'})
+ self.assertEqual(r.status_code, 200, r.text)
+ payload = json.loads(r.text)
+ self.assertEqual(payload[0]["Status"], "Created")
+
+ r = requests.post(PODMAN_URL + f"/v1.40/containers/{container_id}/start")
+ self.assertEqual(r.status_code, 204, r.text)
+
+ r = requests.get(PODMAN_URL + "/v1.40/containers/json",
+ params={'all': 'true', 'filters': f'{{"id":["{container_id}"]}}'})
+ self.assertEqual(r.status_code, 200, r.text)
+ payload = json.loads(r.text)
+ self.assertTrue(str(payload[0]["Status"]).startswith("Up"))
+
+ r = requests.post(PODMAN_URL + f"/v1.40/containers/{container_id}/pause")
+ self.assertEqual(r.status_code, 204, r.text)
+
+ r = requests.get(PODMAN_URL + "/v1.40/containers/json",
+ params={'all': 'true', 'filters': f'{{"id":["{container_id}"]}}'})
+ self.assertEqual(r.status_code, 200, r.text)
+ payload = json.loads(r.text)
+ self.assertTrue(str(payload[0]["Status"]).startswith("Up"))
+ self.assertTrue(str(payload[0]["Status"]).endswith("(Paused)"))
+
+ r = requests.post(PODMAN_URL + f"/v1.40/containers/{container_id}/unpause")
+ self.assertEqual(r.status_code, 204, r.text)
+ r = requests.post(PODMAN_URL + f"/v1.40/containers/{container_id}/stop")
+ self.assertEqual(r.status_code, 204, r.text)
+
+ r = requests.get(PODMAN_URL + "/v1.40/containers/json",
+ params={'all': 'true', 'filters': f'{{"id":["{container_id}"]}}'})
+ self.assertEqual(r.status_code, 200, r.text)
+ payload = json.loads(r.text)
+ self.assertTrue(str(payload[0]["Status"]).startswith("Exited"))
+
+ r = requests.delete(PODMAN_URL + f"/v1.40/containers/{container_id}")
+ self.assertEqual(r.status_code, 204, r.text)
+
if __name__ == "__main__":
unittest.main()