aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-05-05 16:19:30 -0400
committerMatthew Heon <matthew.heon@pm.me>2020-05-05 20:21:01 -0400
commitf7c3cfde77a4bc8b241fb36c4d39cbe2fde0c45c (patch)
tree1955cdfcb7ef8705944bcb1b0f8b42286863224e /test
parentfb6eca50ba9e2dc652da0c33c72db70ab9da85e9 (diff)
downloadpodman-f7c3cfde77a4bc8b241fb36c4d39cbe2fde0c45c.tar.gz
podman-f7c3cfde77a4bc8b241fb36c4d39cbe2fde0c45c.tar.bz2
podman-f7c3cfde77a4bc8b241fb36c4d39cbe2fde0c45c.zip
Add small fixes for 'podman run' from diffing inspect
To try and identify differences between Podman v1.9 and master, I ran a series of `podman run` commands with various flags through each, then inspecting the resulting containers and diffed the inspect JSON between each. This identified a number of issues which are fixed in this PR. In order of discovery: - Podman v2 gave short names for images, where Podman v1 gave the fully-qualified name. Simple enough fix (get image tags and use the first one if they're available) - The --restart flag was not being parsed correctly when a number of retries was specified. Parsing has been corrected. - The -m flag was not setting the swap limit (simple fix to set swap in that case if it's not explicitly set by the user) - The --cpus flag was completely nonfunctional (wired in its logic) Tests have been added for all of these to catch future regressions. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/create_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go
index 10742a0e8..1041b30bb 100644
--- a/test/e2e/create_test.go
+++ b/test/e2e/create_test.go
@@ -342,4 +342,53 @@ var _ = Describe("Podman create", func() {
Expect(ok2).To(BeTrue())
Expect(val2).To(Equal("bar"))
})
+
+ It("podman create with --restart=on-failure:5 parses correctly", func() {
+ ctrName := "testctr"
+ session := podmanTest.Podman([]string{"create", "-t", "--restart", "on-failure:5", "--name", ctrName, ALPINE, "/bin/sh"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ inspect := podmanTest.Podman([]string{"inspect", ctrName})
+ inspect.WaitWithDefaultTimeout()
+ data := inspect.InspectContainerToJSON()
+ Expect(len(data)).To(Equal(1))
+ Expect(data[0].HostConfig.RestartPolicy.Name).To(Equal("on-failure"))
+ Expect(data[0].HostConfig.RestartPolicy.MaximumRetryCount).To(Equal(uint(5)))
+ })
+
+ It("podman create with --restart-policy=always:5 fails", func() {
+ session := podmanTest.Podman([]string{"create", "-t", "--restart", "always:5", ALPINE, "/bin/sh"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+ })
+
+ It("podman create with -m 1000000 sets swap to 2000000", func() {
+ numMem := 1000000
+ ctrName := "testCtr"
+ session := podmanTest.Podman([]string{"create", "-t", "-m", fmt.Sprintf("%db", numMem), "--name", ctrName, ALPINE, "/bin/sh"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ inspect := podmanTest.Podman([]string{"inspect", ctrName})
+ inspect.WaitWithDefaultTimeout()
+ data := inspect.InspectContainerToJSON()
+ Expect(len(data)).To(Equal(1))
+ Expect(data[0].HostConfig.MemorySwap).To(Equal(int64(2 * numMem)))
+ })
+
+ It("podman create --cpus 5 sets nanocpus", func() {
+ numCpus := 5
+ nanoCPUs := numCpus * 1000000000
+ ctrName := "testCtr"
+ session := podmanTest.Podman([]string{"create", "-t", "--cpus", fmt.Sprintf("%d", numCpus), "--name", ctrName, ALPINE, "/bin/sh"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ inspect := podmanTest.Podman([]string{"inspect", ctrName})
+ inspect.WaitWithDefaultTimeout()
+ data := inspect.InspectContainerToJSON()
+ Expect(len(data)).To(Equal(1))
+ Expect(data[0].HostConfig.NanoCpus).To(Equal(int64(nanoCPUs)))
+ })
})