diff options
author | cdoern <cbdoer23@g.holycross.edu> | 2022-04-11 22:54:08 -0400 |
---|---|---|
committer | cdoern <cdoern@redhat.com> | 2022-04-18 15:38:24 -0400 |
commit | be0da4a22265ade11c603fb847531a080d844a06 (patch) | |
tree | 3430ac7e1125e02ed6c3413e3f887ac017e874fe /test/apiv2 | |
parent | d6f47e692bc694d3ec4f3505acaccf7fa0b73231 (diff) | |
download | podman-be0da4a22265ade11c603fb847531a080d844a06.tar.gz podman-be0da4a22265ade11c603fb847531a080d844a06.tar.bz2 podman-be0da4a22265ade11c603fb847531a080d844a06.zip |
Translate Memory Limit to Swap in API
in specgen, CLI path uses the given memory limit to define the swap value (if not already specified)
add a route to this piece of code from within the api handlers
resolves #13145
Signed-off-by: cdoern <cdoern@redhat.com>
Diffstat (limited to 'test/apiv2')
-rw-r--r-- | test/apiv2/python/rest_api/test_v2_0_0_container.py | 29 |
1 files changed, 29 insertions, 0 deletions
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 0386116a8..a44786c0d 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 @@ -328,6 +328,35 @@ class ContainerTestCase(APITestCase): self.fail("Server failed to respond in 10s") top.join() + def test_memory(self): + r = requests.post( + self.podman_url + "/v1.4.0/libpod/containers/create", + json={ + "Name": "memory", + "Cmd": ["top"], + "Image": "alpine:latest", + "Resource_Limits": { + "Memory":{ + "Limit": 1000, + }, + "CPU":{ + "Shares": 200, + }, + }, + }, + ) + 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/{container_id}/json") + self.assertEqual(r.status_code, 200, r.text) + self.assertId(r.content) + out = r.json() + self.assertEqual(2000, out["HostConfig"]["MemorySwap"]) + self.assertEqual(1000, out["HostConfig"]["Memory"]) + if __name__ == "__main__": unittest.main() |