github.com/containers/podman/v5@v5.1.0-rc1/test/e2e/pod_inspect_test.go (about) 1 package integration 2 3 import ( 4 . "github.com/containers/podman/v5/test/utils" 5 . "github.com/onsi/ginkgo/v2" 6 . "github.com/onsi/gomega" 7 ) 8 9 var _ = Describe("Podman pod inspect", func() { 10 11 It("podman inspect bogus pod", func() { 12 session := podmanTest.Podman([]string{"pod", "inspect", "foobar"}) 13 session.WaitWithDefaultTimeout() 14 expect := "no such pod foobar" 15 if IsRemote() { 16 expect = `no such pod "foobar"` 17 } 18 Expect(session).Should(ExitWithError(125, expect)) 19 }) 20 21 It("podman inspect a pod", func() { 22 _, ec, podid := podmanTest.CreatePod(nil) 23 Expect(ec).To(Equal(0)) 24 25 session := podmanTest.RunTopContainerInPod("", podid) 26 session.WaitWithDefaultTimeout() 27 Expect(session).Should(ExitCleanly()) 28 29 session = podmanTest.RunTopContainerInPod("", podid) 30 session.WaitWithDefaultTimeout() 31 Expect(session).Should(ExitCleanly()) 32 33 inspect := podmanTest.Podman([]string{"pod", "inspect", podid}) 34 inspect.WaitWithDefaultTimeout() 35 Expect(inspect).Should(ExitCleanly()) 36 Expect(inspect.OutputToString()).To(BeValidJSON()) 37 podData := inspect.InspectPodToJSON() 38 Expect(podData).To(HaveField("ID", podid)) 39 }) 40 41 It("podman pod inspect (CreateCommand)", func() { 42 podName := "myTestPod" 43 createCommand := []string{"pod", "create", "--name", podName, "--hostname", "rudolph", "--share", "net"} 44 45 // Create the pod. 46 session := podmanTest.Podman(createCommand) 47 session.WaitWithDefaultTimeout() 48 Expect(session).Should(ExitCleanly()) 49 50 // Inspect the pod and make sure that the create command is 51 // exactly how we created the pod. 52 inspect := podmanTest.Podman([]string{"pod", "inspect", podName}) 53 inspect.WaitWithDefaultTimeout() 54 Expect(inspect).Should(ExitCleanly()) 55 Expect(inspect.OutputToString()).To(BeValidJSON()) 56 podData := inspect.InspectPodToJSON() 57 // Let's get the last len(createCommand) items in the command. 58 inspectCreateCommand := podData.CreateCommand 59 index := len(inspectCreateCommand) - len(createCommand) 60 Expect(inspectCreateCommand[index:]).To(Equal(createCommand)) 61 }) 62 63 It("podman pod inspect outputs port bindings", func() { 64 podName := "testPod" 65 create := podmanTest.Podman([]string{"pod", "create", "--name", podName, "-p", "8383:80"}) 66 create.WaitWithDefaultTimeout() 67 Expect(create).Should(ExitCleanly()) 68 69 inspectOut := podmanTest.Podman([]string{"pod", "inspect", podName}) 70 inspectOut.WaitWithDefaultTimeout() 71 Expect(inspectOut).Should(ExitCleanly()) 72 73 inspectJSON := inspectOut.InspectPodToJSON() 74 Expect(inspectJSON.InfraConfig).To(Not(BeNil())) 75 Expect(inspectJSON.InfraConfig.PortBindings["80/tcp"]).To(HaveLen(1)) 76 Expect(inspectJSON.InfraConfig.PortBindings["80/tcp"][0]).To(HaveField("HostPort", "8383")) 77 }) 78 79 It("podman pod inspect outputs show correct MAC", func() { 80 SkipIfRootless("--mac-address is not supported in rootless mode without network") 81 podName := "testPod" 82 macAddr := "42:43:44:00:00:01" 83 create := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--mac-address", macAddr}) 84 create.WaitWithDefaultTimeout() 85 Expect(create).Should(ExitCleanly()) 86 87 create = podmanTest.Podman([]string{"run", "-d", "--pod", podName, ALPINE, "top"}) 88 create.WaitWithDefaultTimeout() 89 Expect(create).Should(ExitCleanly()) 90 91 inspectOut := podmanTest.Podman([]string{"pod", "inspect", podName}) 92 inspectOut.WaitWithDefaultTimeout() 93 Expect(inspectOut).Should(ExitCleanly()) 94 95 Expect(inspectOut.OutputToString()).To(ContainSubstring(macAddr)) 96 }) 97 98 It("podman inspect two pods", func() { 99 _, ec, podid1 := podmanTest.CreatePod(nil) 100 Expect(ec).To(Equal(0)) 101 102 _, ec, podid2 := podmanTest.CreatePod(nil) 103 Expect(ec).To(Equal(0)) 104 105 inspect := podmanTest.Podman([]string{"pod", "inspect", podid1, podid2}) 106 inspect.WaitWithDefaultTimeout() 107 Expect(inspect).Should(ExitCleanly()) 108 Expect(inspect.OutputToString()).To(BeValidJSON()) 109 podData := inspect.InspectPodArrToJSON() 110 Expect(podData).To(HaveLen(2)) 111 Expect(podData[0]).To(HaveField("ID", podid1)) 112 Expect(podData[1]).To(HaveField("ID", podid2)) 113 }) 114 })