github.com/AbhinandanKurakure/podman/v3@v3.4.10/test/e2e/create_staticmac_test.go (about) 1 package integration 2 3 import ( 4 "os" 5 6 "github.com/containers/podman/v3/pkg/rootless" 7 . "github.com/containers/podman/v3/test/utils" 8 "github.com/containers/storage/pkg/stringid" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 . "github.com/onsi/gomega/gexec" 12 ) 13 14 var _ = Describe("Podman run with --mac-address flag", func() { 15 var ( 16 tempdir string 17 err error 18 podmanTest *PodmanTestIntegration 19 ) 20 21 BeforeEach(func() { 22 tempdir, err = CreateTempDirInTempDir() 23 if err != nil { 24 os.Exit(1) 25 } 26 podmanTest = PodmanTestCreate(tempdir) 27 podmanTest.Setup() 28 podmanTest.SeedImages() 29 // Cleanup the CNI networks used by the tests 30 os.RemoveAll("/var/lib/cni/networks/podman") 31 }) 32 33 AfterEach(func() { 34 podmanTest.Cleanup() 35 f := CurrentGinkgoTestDescription() 36 processTestResult(f) 37 38 }) 39 40 It("Podman run --mac-address", func() { 41 result := podmanTest.Podman([]string{"run", "--mac-address", "92:d0:c6:0a:29:34", ALPINE, "ip", "addr"}) 42 result.WaitWithDefaultTimeout() 43 if rootless.IsRootless() { 44 Expect(result).Should(Exit(125)) 45 } else { 46 Expect(result).Should(Exit(0)) 47 Expect(result.OutputToString()).To(ContainSubstring("92:d0:c6:0a:29:34")) 48 } 49 }) 50 51 It("Podman run --mac-address with custom network", func() { 52 net := "n1" + stringid.GenerateNonCryptoID() 53 session := podmanTest.Podman([]string{"network", "create", net}) 54 session.WaitWithDefaultTimeout() 55 defer podmanTest.removeCNINetwork(net) 56 Expect(session).Should(Exit(0)) 57 58 result := podmanTest.Podman([]string{"run", "--network", net, "--mac-address", "92:d0:c6:00:29:34", ALPINE, "ip", "addr"}) 59 result.WaitWithDefaultTimeout() 60 Expect(result).Should(Exit(0)) 61 Expect(result.OutputToString()).To(ContainSubstring("92:d0:c6:00:29:34")) 62 }) 63 })