summaryrefslogtreecommitdiff
path: root/test/e2e/ps_test.go
diff options
context:
space:
mode:
authorSascha Grunert <sgrunert@suse.com>2020-10-07 17:00:15 +0200
committerSascha Grunert <sgrunert@suse.com>2020-10-20 17:00:23 +0200
commitf63bbca4dabbedbd7a808600b38f4e2ae55a6c4a (patch)
tree1ec86f947e1917726ab2c9a9103ddaa670fc2d76 /test/e2e/ps_test.go
parent35b4cb196545eee3b072083e716ad4588e0bb486 (diff)
downloadpodman-f63bbca4dabbedbd7a808600b38f4e2ae55a6c4a.tar.gz
podman-f63bbca4dabbedbd7a808600b38f4e2ae55a6c4a.tar.bz2
podman-f63bbca4dabbedbd7a808600b38f4e2ae55a6c4a.zip
Fix ps port output
When defining multiple ports (same src/dst) like `-p 80:80 -p 443:443` then podman will not show the complete output on `podman ps` (only `0.0.0.0:80->80/tcp` in the example). This also applies to port ranges. This patch refactors the port loop by pre-checking for ranges and displaying them correctly to the end user. Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Diffstat (limited to 'test/e2e/ps_test.go')
-rw-r--r--test/e2e/ps_test.go33
1 files changed, 29 insertions, 4 deletions
diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go
index 48ef566ce..c65738993 100644
--- a/test/e2e/ps_test.go
+++ b/test/e2e/ps_test.go
@@ -411,18 +411,43 @@ var _ = Describe("Podman ps", func() {
Expect(output).To(ContainSubstring(podName))
})
- It("podman ps test with port range", func() {
- session := podmanTest.RunTopContainer("")
+ It("podman ps test with single port range", func() {
+ session := podmanTest.Podman([]string{"run", "-dt", "-p", "2000-2006:2000-2006", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- session = podmanTest.Podman([]string{"run", "-dt", "-p", "2000-2006:2000-2006", ALPINE, "top"})
+ session = podmanTest.Podman([]string{"ps", "--format", "{{.Ports}}"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.OutputToString()).To(ContainSubstring("0.0.0.0:2000-2006"))
+ })
+
+ It("podman ps test with invalid port range", func() {
+ session := podmanTest.Podman([]string{
+ "run", "-p", "1000-2000:2000-3000", "-p", "1999-2999:3001-4001", ALPINE,
+ })
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(125))
+ Expect(session.ErrorToString()).To(ContainSubstring("conflicting port mappings for host port 1999"))
+ })
+
+ It("podman ps test with multiple port range", func() {
+ session := podmanTest.Podman([]string{
+ "run", "-dt",
+ "-p", "3000-3001:3000-3001",
+ "-p", "3100-3102:4000-4002",
+ "-p", "30080:30080",
+ "-p", "30443:30443",
+ "-p", "8000:8080",
+ ALPINE, "top"},
+ )
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
session = podmanTest.Podman([]string{"ps", "--format", "{{.Ports}}"})
session.WaitWithDefaultTimeout()
- Expect(session.OutputToString()).To(ContainSubstring("0.0.0.0:2000-2006"))
+ Expect(session.OutputToString()).To(ContainSubstring(
+ "0.0.0.0:3000-3001->3000-3001/tcp, 0.0.0.0:3100-3102->4000-4002/tcp, 0.0.0.0:8000->8080/tcp, 0.0.0.0:30080->30080/tcp, 0.0.0.0:30443->30443/tcp",
+ ))
})
It("podman ps sync flag", func() {