github.com/containers/podman/v5@v5.1.0-rc1/test/e2e/generate_spec_test.go (about) 1 package integration 2 3 import ( 4 "path/filepath" 5 6 . "github.com/containers/podman/v5/test/utils" 7 . "github.com/onsi/ginkgo/v2" 8 . "github.com/onsi/gomega" 9 . "github.com/onsi/gomega/gexec" 10 ) 11 12 var _ = Describe("Podman generate spec", func() { 13 14 BeforeEach(func() { 15 SkipIfRemote("podman generate spec is not supported on the remote client") 16 }) 17 18 It("podman generate spec bogus should fail", func() { 19 session := podmanTest.Podman([]string{"generate", "spec", "foobar"}) 20 session.WaitWithDefaultTimeout() 21 Expect(session).Should(ExitWithError(125, "could not find a pod or container with the id foobar")) 22 }) 23 24 It("podman generate spec basic usage", func() { 25 SkipIfRootlessCgroupsV1("Not supported for rootless + CgroupsV1") 26 session := podmanTest.Podman([]string{"create", "--cpus", "5", "--name", "specgen", ALPINE}) 27 session.WaitWithDefaultTimeout() 28 Expect(session).Should(ExitCleanly()) 29 30 session = podmanTest.Podman([]string{"generate", "spec", "--compact", "specgen"}) 31 session.WaitWithDefaultTimeout() 32 Expect(session).Should(ExitCleanly()) 33 }) 34 35 It("podman generate spec file", func() { 36 SkipIfRootlessCgroupsV1("Not supported for rootless + CgroupsV1") 37 session := podmanTest.Podman([]string{"create", "--cpus", "5", "--name", "specgen", ALPINE}) 38 session.WaitWithDefaultTimeout() 39 Expect(session).Should(ExitCleanly()) 40 41 session = podmanTest.Podman([]string{"generate", "spec", "--filename", filepath.Join(tempdir, "out.json"), "specgen"}) 42 session.WaitWithDefaultTimeout() 43 Expect(session).Should(ExitCleanly()) 44 45 path := filepath.Join(tempdir, "out.json") 46 47 exec := SystemExec("cat", []string{path}) 48 exec.WaitWithDefaultTimeout() 49 Expect(exec.OutputToString()).Should(ContainSubstring("specgen-clone")) 50 Expect(exec.OutputToString()).Should(ContainSubstring("500000")) 51 52 }) 53 54 It("generate spec pod", func() { 55 session := podmanTest.Podman([]string{"pod", "create", "--cpus", "5", "--name", "podspecgen"}) 56 session.WaitWithDefaultTimeout() 57 Expect(session).Should(ExitCleanly()) 58 59 session = podmanTest.Podman([]string{"generate", "spec", "--compact", "podspecgen"}) 60 session.WaitWithDefaultTimeout() 61 62 if isRootless() && !CGROUPSV2 { 63 Expect(session).Should(Exit(0)) 64 Expect(session.ErrorToString()).Should(ContainSubstring("Resource limits are not supported and ignored on cgroups V1 rootless")) 65 } else { 66 Expect(session).Should(ExitCleanly()) 67 } 68 }) 69 })