diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-05-03 16:37:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 16:37:54 -0400 |
commit | 3210a3f4257d19744abd4ae2302018b16edb2507 (patch) | |
tree | 97f6f9e2c4bfd41191971c5658484012ce1b4826 /test | |
parent | 3af1396f269463aa7640e9cf1dcc84a413d99ee0 (diff) | |
parent | 3ab8fa679c57a653f7ea012f79fa453ae8133108 (diff) | |
download | podman-3210a3f4257d19744abd4ae2302018b16edb2507.tar.gz podman-3210a3f4257d19744abd4ae2302018b16edb2507.tar.bz2 podman-3210a3f4257d19744abd4ae2302018b16edb2507.zip |
Merge pull request #14100 from mheon/incremental_backports
[v4.1] Incremental backports
Diffstat (limited to 'test')
125 files changed, 468 insertions, 430 deletions
diff --git a/test/e2e/attach_test.go b/test/e2e/attach_test.go index 74e3a619a..b110f7c5b 100644 --- a/test/e2e/attach_test.go +++ b/test/e2e/attach_test.go @@ -22,8 +22,6 @@ var _ = Describe("Podman attach", func() { Expect(err).To(BeNil()) podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - err = podmanTest.SeedImages() - Expect(err).To(BeNil()) }) AfterEach(func() { diff --git a/test/e2e/benchmarks_test.go b/test/e2e/benchmarks_test.go index 9653cee3b..746dec0a6 100644 --- a/test/e2e/benchmarks_test.go +++ b/test/e2e/benchmarks_test.go @@ -66,7 +66,6 @@ var _ = Describe("Podman Benchmark Suite", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - timedir, err = CreateTempDirInTempDir() if err != nil { os.Exit(1) diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index 0c665687d..b5cec5fff 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -53,8 +53,8 @@ var _ = Describe("Podman build", func() { inspect := podmanTest.Podman([]string{"inspect", iid}) inspect.WaitWithDefaultTimeout() data := inspect.InspectImageJSON() - Expect(data[0].Os).To(Equal(runtime.GOOS)) - Expect(data[0].Architecture).To(Equal(runtime.GOARCH)) + Expect(data[0]).To(HaveField("Os", runtime.GOOS)) + Expect(data[0]).To(HaveField("Architecture", runtime.GOARCH)) session = podmanTest.Podman([]string{"rmi", ALPINE}) session.WaitWithDefaultTimeout() @@ -110,8 +110,8 @@ var _ = Describe("Podman build", func() { inspect := podmanTest.Podman([]string{"inspect", "test"}) inspect.WaitWithDefaultTimeout() data := inspect.InspectImageJSON() - Expect(data[0].Os).To(Equal(runtime.GOOS)) - Expect(data[0].Architecture).To(Equal(runtime.GOARCH)) + Expect(data[0]).To(HaveField("Os", runtime.GOOS)) + Expect(data[0]).To(HaveField("Architecture", runtime.GOARCH)) st, err := os.Stat(logfile) Expect(err).To(BeNil()) @@ -533,7 +533,10 @@ subdir**` // make cwd as context root path Expect(os.Chdir(contextDir)).ToNot(HaveOccurred()) - defer os.Chdir(cwd) + defer func() { + err := os.Chdir(cwd) + Expect(err).ToNot(HaveOccurred()) + }() By("Test .containerignore filtering subdirectory") err = ioutil.WriteFile(filepath.Join(contextDir, ".containerignore"), []byte(`subdir/`), 0644) diff --git a/test/e2e/checkpoint_image_test.go b/test/e2e/checkpoint_image_test.go index 8274dfc80..94320a70e 100644 --- a/test/e2e/checkpoint_image_test.go +++ b/test/e2e/checkpoint_image_test.go @@ -28,7 +28,6 @@ var _ = Describe("Podman checkpoint", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() // Check if the runtime implements checkpointing. Currently only // runc's checkpoint/restore implementation is supported. cmd := exec.Command(podmanTest.OCIRuntime, "checkpoint", "--help") @@ -91,9 +90,9 @@ var _ = Describe("Podman checkpoint", func() { inspectOut := inspect.InspectContainerToJSON() Expect(inspectOut[0].State.Checkpointed).To(BeFalse(), ".State.Checkpointed") Expect(inspectOut[0].State.Restored).To(BeFalse(), ".State.Restored") - Expect(inspectOut[0].State.CheckpointPath).To(Equal("")) - Expect(inspectOut[0].State.CheckpointLog).To(Equal("")) - Expect(inspectOut[0].State.RestoreLog).To(Equal("")) + Expect(inspectOut[0].State).To(HaveField("CheckpointPath", "")) + Expect(inspectOut[0].State).To(HaveField("CheckpointLog", "")) + Expect(inspectOut[0].State).To(HaveField("RestoreLog", "")) result := podmanTest.Podman([]string{"container", "checkpoint", "--create-image", checkpointImage, "--keep", containerID}) result.WaitWithDefaultTimeout() diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go index 2dc99bdc9..787178cd3 100644 --- a/test/e2e/checkpoint_test.go +++ b/test/e2e/checkpoint_test.go @@ -41,8 +41,6 @@ var _ = Describe("Podman checkpoint", func() { podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - err = podmanTest.SeedImages() - Expect(err).To(BeNil()) // Check if the runtime implements checkpointing. Currently only // runc's checkpoint/restore implementation is supported. cmd := exec.Command(podmanTest.OCIRuntime, "checkpoint", "--help") @@ -99,9 +97,9 @@ var _ = Describe("Podman checkpoint", func() { inspectOut := inspect.InspectContainerToJSON() Expect(inspectOut[0].State.Checkpointed).To(BeFalse(), ".State.Checkpointed") Expect(inspectOut[0].State.Restored).To(BeFalse(), ".State.Restored") - Expect(inspectOut[0].State.CheckpointPath).To(Equal("")) - Expect(inspectOut[0].State.CheckpointLog).To(Equal("")) - Expect(inspectOut[0].State.RestoreLog).To(Equal("")) + Expect(inspectOut[0].State).To(HaveField("CheckpointPath", "")) + Expect(inspectOut[0].State).To(HaveField("CheckpointLog", "")) + Expect(inspectOut[0].State).To(HaveField("RestoreLog", "")) result := podmanTest.Podman([]string{ "container", @@ -125,7 +123,7 @@ var _ = Describe("Podman checkpoint", func() { Expect(inspectOut[0].State.Restored).To(BeFalse(), ".State.Restored") Expect(inspectOut[0].State.CheckpointPath).To(ContainSubstring("userdata/checkpoint")) Expect(inspectOut[0].State.CheckpointLog).To(ContainSubstring("userdata/dump.log")) - Expect(inspectOut[0].State.RestoreLog).To(Equal("")) + Expect(inspectOut[0].State).To(HaveField("RestoreLog", "")) result = podmanTest.Podman([]string{ "container", @@ -179,9 +177,9 @@ var _ = Describe("Podman checkpoint", func() { inspectOut = inspect.InspectContainerToJSON() Expect(inspectOut[0].State.Checkpointed).To(BeFalse(), ".State.Checkpointed") Expect(inspectOut[0].State.Restored).To(BeFalse(), ".State.Restored") - Expect(inspectOut[0].State.CheckpointPath).To(Equal("")) - Expect(inspectOut[0].State.CheckpointLog).To(Equal("")) - Expect(inspectOut[0].State.RestoreLog).To(Equal("")) + Expect(inspectOut[0].State).To(HaveField("CheckpointPath", "")) + Expect(inspectOut[0].State).To(HaveField("CheckpointLog", "")) + Expect(inspectOut[0].State).To(HaveField("RestoreLog", "")) }) It("podman checkpoint a running container by name", func() { diff --git a/test/e2e/commit_test.go b/test/e2e/commit_test.go index 78b607f1e..c82e5e471 100644 --- a/test/e2e/commit_test.go +++ b/test/e2e/commit_test.go @@ -24,8 +24,6 @@ var _ = Describe("Podman commit", func() { Expect(err).To(BeNil()) podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - err = podmanTest.SeedImages() - Expect(err).To(BeNil()) }) AfterEach(func() { @@ -92,7 +90,7 @@ var _ = Describe("Podman commit", func() { check := podmanTest.Podman([]string{"inspect", "foobar.com/test1-image:latest"}) check.WaitWithDefaultTimeout() data := check.InspectImageJSON() - Expect(data[0].Comment).To(Equal("testing-commit")) + Expect(data[0]).To(HaveField("Comment", "testing-commit")) }) It("podman commit container with author", func() { @@ -107,7 +105,7 @@ var _ = Describe("Podman commit", func() { check := podmanTest.Podman([]string{"inspect", "foobar.com/test1-image:latest"}) check.WaitWithDefaultTimeout() data := check.InspectImageJSON() - Expect(data[0].Author).To(Equal("snoopy")) + Expect(data[0]).To(HaveField("Author", "snoopy")) }) It("podman commit container with change flag", func() { @@ -293,7 +291,7 @@ var _ = Describe("Podman commit", func() { check := podmanTest.Podman([]string{"inspect", "foobar.com/test1-image:latest"}) check.WaitWithDefaultTimeout() data := check.InspectImageJSON() - Expect(data[0].ID).To(Equal(string(id))) + Expect(data[0]).To(HaveField("ID", string(id))) }) It("podman commit should not commit secret", func() { diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 59252fcb0..a61ef8640 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -861,9 +861,6 @@ func (p *PodmanTestIntegration) makeOptions(args []string, noEvents, noCache boo podmanOptions := strings.Split(fmt.Sprintf("%s--root %s --runroot %s --runtime %s --conmon %s --network-config-dir %s --cgroup-manager %s --tmpdir %s --events-backend %s", debug, p.Root, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.NetworkConfigDir, p.CgroupManager, p.TmpDir, eventsType), " ") - if os.Getenv("HOOK_OPTION") != "" { - podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION")) - } if !p.RemoteTest { podmanOptions = append(podmanOptions, "--network-backend", p.NetworkBackend.ToString()) diff --git a/test/e2e/container_clone_test.go b/test/e2e/container_clone_test.go index 42b477da0..da9b511e0 100644 --- a/test/e2e/container_clone_test.go +++ b/test/e2e/container_clone_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman container clone", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -68,8 +67,8 @@ var _ = Describe("Podman container clone", func() { ctrInspect := podmanTest.Podman([]string{"inspect", clone.OutputToString()}) ctrInspect.WaitWithDefaultTimeout() Expect(ctrInspect).To(Exit(0)) - Expect(ctrInspect.InspectContainerToJSON()[0].ImageName).To(Equal(fedoraMinimal)) - Expect(ctrInspect.InspectContainerToJSON()[0].Name).To(Equal("new_name")) + Expect(ctrInspect.InspectContainerToJSON()[0]).To(HaveField("ImageName", fedoraMinimal)) + Expect(ctrInspect.InspectContainerToJSON()[0]).To(HaveField("Name", "new_name")) }) It("podman container clone name test", func() { @@ -84,7 +83,7 @@ var _ = Describe("Podman container clone", func() { cloneInspect.WaitWithDefaultTimeout() Expect(cloneInspect).To(Exit(0)) cloneData := cloneInspect.InspectContainerToJSON() - Expect(cloneData[0].Name).To(Equal("testing123")) + Expect(cloneData[0]).To(HaveField("Name", "testing123")) }) It("podman container clone resource limits override", func() { @@ -104,7 +103,7 @@ var _ = Describe("Podman container clone", func() { cloneInspect.WaitWithDefaultTimeout() Expect(cloneInspect).To(Exit(0)) cloneData := cloneInspect.InspectContainerToJSON() - Expect(createData[0].HostConfig.NanoCpus).To(Equal(cloneData[0].HostConfig.NanoCpus)) + Expect(createData[0].HostConfig).To(HaveField("NanoCpus", cloneData[0].HostConfig.NanoCpus)) create = podmanTest.Podman([]string{"create", "--memory=5", ALPINE}) create.WaitWithDefaultTimeout() @@ -122,7 +121,7 @@ var _ = Describe("Podman container clone", func() { cloneInspect.WaitWithDefaultTimeout() Expect(cloneInspect).To(Exit(0)) cloneData = cloneInspect.InspectContainerToJSON() - Expect(createData[0].HostConfig.MemorySwap).To(Equal(cloneData[0].HostConfig.MemorySwap)) + Expect(createData[0].HostConfig).To(HaveField("MemorySwap", cloneData[0].HostConfig.MemorySwap)) create = podmanTest.Podman([]string{"create", "--cpus=5", ALPINE}) create.WaitWithDefaultTimeout() @@ -145,7 +144,7 @@ var _ = Describe("Podman container clone", func() { Expect(cloneInspect).To(Exit(0)) cloneData = cloneInspect.InspectContainerToJSON() Expect(createData[0].HostConfig.NanoCpus).ToNot(Equal(cloneData[0].HostConfig.NanoCpus)) - Expect(cloneData[0].HostConfig.NanoCpus).To(Equal(nanoCPUs)) + Expect(cloneData[0].HostConfig).To(HaveField("NanoCpus", nanoCPUs)) create = podmanTest.Podman([]string{"create", ALPINE}) create.WaitWithDefaultTimeout() @@ -158,7 +157,7 @@ var _ = Describe("Podman container clone", func() { cloneInspect.WaitWithDefaultTimeout() Expect(cloneInspect).To(Exit(0)) cloneData = cloneInspect.InspectContainerToJSON() - Expect(cloneData[0].HostConfig.MemorySwappiness).To(Equal(int64(0))) + Expect(cloneData[0].HostConfig).To(HaveField("MemorySwappiness", int64(0))) }) diff --git a/test/e2e/container_create_volume_test.go b/test/e2e/container_create_volume_test.go index 62a2541b9..6d9f13694 100644 --- a/test/e2e/container_create_volume_test.go +++ b/test/e2e/container_create_volume_test.go @@ -47,7 +47,7 @@ func checkDataVolumeContainer(pTest *PodmanTestIntegration, image, cont, dest, d inspect := pTest.InspectContainer(cont) Expect(inspect).To(HaveLen(1)) Expect(inspect[0].Mounts).To(HaveLen(1)) - Expect(inspect[0].Mounts[0].Destination).To(Equal(dest)) + Expect(inspect[0].Mounts[0]).To(HaveField("Destination", dest)) mntName, mntSource := inspect[0].Mounts[0].Name, inspect[0].Mounts[0].Source @@ -83,7 +83,6 @@ var _ = Describe("Podman create data volume", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/container_inspect_test.go b/test/e2e/container_inspect_test.go index f58f2de29..5aed943da 100644 --- a/test/e2e/container_inspect_test.go +++ b/test/e2e/container_inspect_test.go @@ -25,7 +25,6 @@ var _ = Describe("Podman container inspect", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/containers_conf_test.go b/test/e2e/containers_conf_test.go index 09cd68042..b48e1ed62 100644 --- a/test/e2e/containers_conf_test.go +++ b/test/e2e/containers_conf_test.go @@ -29,7 +29,6 @@ var _ = Describe("Verify podman containers.conf usage", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() os.Setenv("CONTAINERS_CONF", "config/containers.conf") if IsRemote() { podmanTest.RestartRemoteService() diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go index ede6036b9..8a65b85d3 100644 --- a/test/e2e/cp_test.go +++ b/test/e2e/cp_test.go @@ -31,7 +31,6 @@ var _ = Describe("Podman cp", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/create_staticip_test.go b/test/e2e/create_staticip_test.go index 4a1d926e0..6fd88753b 100644 --- a/test/e2e/create_staticip_test.go +++ b/test/e2e/create_staticip_test.go @@ -25,7 +25,6 @@ var _ = Describe("Podman create with --ip flag", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() // Cleanup the CNI networks used by the tests os.RemoveAll("/var/lib/cni/networks/podman") }) diff --git a/test/e2e/create_staticmac_test.go b/test/e2e/create_staticmac_test.go index 5fd8e3bd6..f02d9c88b 100644 --- a/test/e2e/create_staticmac_test.go +++ b/test/e2e/create_staticmac_test.go @@ -25,7 +25,6 @@ var _ = Describe("Podman run with --mac-address flag", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() // Cleanup the CNI networks used by the tests os.RemoveAll("/var/lib/cni/networks/podman") }) diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index 4c3b5604a..63544d579 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -27,8 +27,6 @@ var _ = Describe("Podman create", func() { Expect(err).To(BeNil()) podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - err = podmanTest.SeedImages() - Expect(err).To(BeNil()) }) AfterEach(func() { @@ -176,7 +174,8 @@ var _ = Describe("Podman create", func() { // tests are passing inside a container. mountPath := filepath.Join(podmanTest.TempDir, "secrets") - os.Mkdir(mountPath, 0755) + err := os.Mkdir(mountPath, 0755) + Expect(err).ToNot(HaveOccurred()) session := podmanTest.Podman([]string{"create", "--log-driver", "k8s-file", "--name", "test", "--mount", fmt.Sprintf("type=bind,src=%s,target=/create/test", mountPath), ALPINE, "grep", "/create/test", "/proc/self/mountinfo"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) @@ -212,7 +211,8 @@ var _ = Describe("Podman create", func() { Expect(session.OutputToString()).To(ContainSubstring("shared")) mountPath = filepath.Join(podmanTest.TempDir, "scratchpad") - os.Mkdir(mountPath, 0755) + err = os.Mkdir(mountPath, 0755) + Expect(err).ToNot(HaveOccurred()) session = podmanTest.Podman([]string{"create", "--log-driver", "k8s-file", "--name", "test_tmpfs", "--mount", "type=tmpfs,target=/create/test", ALPINE, "grep", "/create/test", "/proc/self/mountinfo"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) @@ -268,7 +268,7 @@ var _ = Describe("Podman create", func() { Expect(session).Should(Exit(0)) ctrJSON := podmanTest.InspectContainer(ctrName) - Expect(podData.ID).To(Equal(ctrJSON[0].Pod)) // Make sure the container's pod matches the pod's ID + Expect(podData).To(HaveField("ID", ctrJSON[0].Pod)) // Make sure the container's pod matches the pod's ID }) It("podman run entrypoint and cmd test", func() { @@ -281,7 +281,7 @@ var _ = Describe("Podman create", func() { Expect(ctrJSON).To(HaveLen(1)) Expect(ctrJSON[0].Config.Cmd).To(HaveLen(1)) Expect(ctrJSON[0].Config.Cmd[0]).To(Equal("redis-server")) - Expect(ctrJSON[0].Config.Entrypoint).To(Equal("docker-entrypoint.sh")) + Expect(ctrJSON[0].Config).To(HaveField("Entrypoint", "docker-entrypoint.sh")) }) It("podman create --pull", func() { @@ -413,8 +413,8 @@ var _ = Describe("Podman create", func() { inspect.WaitWithDefaultTimeout() data := inspect.InspectContainerToJSON() Expect(data).To(HaveLen(1)) - Expect(data[0].HostConfig.RestartPolicy.Name).To(Equal("on-failure")) - Expect(data[0].HostConfig.RestartPolicy.MaximumRetryCount).To(Equal(uint(5))) + Expect(data[0].HostConfig.RestartPolicy).To(HaveField("Name", "on-failure")) + Expect(data[0].HostConfig.RestartPolicy).To(HaveField("MaximumRetryCount", uint(5))) }) It("podman create with --restart-policy=always:5 fails", func() { @@ -434,7 +434,7 @@ var _ = Describe("Podman create", func() { inspect.WaitWithDefaultTimeout() data := inspect.InspectContainerToJSON() Expect(data).To(HaveLen(1)) - Expect(data[0].HostConfig.RestartPolicy.Name).To(Equal(unlessStopped)) + Expect(data[0].HostConfig.RestartPolicy).To(HaveField("Name", unlessStopped)) }) It("podman create with -m 1000000 sets swap to 2000000", func() { @@ -448,7 +448,7 @@ var _ = Describe("Podman create", func() { inspect.WaitWithDefaultTimeout() data := inspect.InspectContainerToJSON() Expect(data).To(HaveLen(1)) - Expect(data[0].HostConfig.MemorySwap).To(Equal(int64(2 * numMem))) + Expect(data[0].HostConfig).To(HaveField("MemorySwap", int64(2*numMem))) }) It("podman create --cpus 5 sets nanocpus", func() { @@ -463,7 +463,7 @@ var _ = Describe("Podman create", func() { inspect.WaitWithDefaultTimeout() data := inspect.InspectContainerToJSON() Expect(data).To(HaveLen(1)) - Expect(data[0].HostConfig.NanoCpus).To(Equal(int64(nanoCPUs))) + Expect(data[0].HostConfig).To(HaveField("NanoCpus", int64(nanoCPUs))) }) It("podman create --replace", func() { @@ -491,7 +491,7 @@ var _ = Describe("Podman create", func() { inspect.WaitWithDefaultTimeout() data := inspect.InspectContainerToJSON() Expect(data).To(HaveLen(1)) - Expect(data[0].Config.StopSignal).To(Equal(uint(15))) + Expect(data[0].Config).To(HaveField("StopSignal", uint(15))) }) It("podman create --tz", func() { @@ -509,7 +509,7 @@ var _ = Describe("Podman create", func() { inspect.WaitWithDefaultTimeout() data := inspect.InspectContainerToJSON() Expect(data).To(HaveLen(1)) - Expect(data[0].Config.Timezone).To(Equal("Pacific/Honolulu")) + Expect(data[0].Config).To(HaveField("Timezone", "Pacific/Honolulu")) session = podmanTest.Podman([]string{"create", "--tz", "local", "--name", "lcl", ALPINE, "date"}) session.WaitWithDefaultTimeout() @@ -517,7 +517,7 @@ var _ = Describe("Podman create", func() { inspect.WaitWithDefaultTimeout() data = inspect.InspectContainerToJSON() Expect(data).To(HaveLen(1)) - Expect(data[0].Config.Timezone).To(Equal("local")) + Expect(data[0].Config).To(HaveField("Timezone", "local")) }) It("podman create --umask", func() { @@ -531,7 +531,7 @@ var _ = Describe("Podman create", func() { inspect.WaitWithDefaultTimeout() data := inspect.InspectContainerToJSON() Expect(data).To(HaveLen(1)) - Expect(data[0].Config.Umask).To(Equal("0022")) + Expect(data[0].Config).To(HaveField("Umask", "0022")) session = podmanTest.Podman([]string{"create", "--umask", "0002", "--name", "umask", ALPINE}) session.WaitWithDefaultTimeout() @@ -539,7 +539,7 @@ var _ = Describe("Podman create", func() { inspect.WaitWithDefaultTimeout() data = inspect.InspectContainerToJSON() Expect(data).To(HaveLen(1)) - Expect(data[0].Config.Umask).To(Equal("0002")) + Expect(data[0].Config).To(HaveField("Umask", "0002")) session = podmanTest.Podman([]string{"create", "--umask", "0077", "--name", "fedora", fedoraMinimal}) session.WaitWithDefaultTimeout() @@ -547,7 +547,7 @@ var _ = Describe("Podman create", func() { inspect.WaitWithDefaultTimeout() data = inspect.InspectContainerToJSON() Expect(data).To(HaveLen(1)) - Expect(data[0].Config.Umask).To(Equal("0077")) + Expect(data[0].Config).To(HaveField("Umask", "0077")) session = podmanTest.Podman([]string{"create", "--umask", "22", "--name", "umask-short", ALPINE}) session.WaitWithDefaultTimeout() @@ -555,7 +555,7 @@ var _ = Describe("Podman create", func() { inspect.WaitWithDefaultTimeout() data = inspect.InspectContainerToJSON() Expect(data).To(HaveLen(1)) - Expect(data[0].Config.Umask).To(Equal("0022")) + Expect(data[0].Config).To(HaveField("Umask", "0022")) session = podmanTest.Podman([]string{"create", "--umask", "9999", "--name", "bad", ALPINE}) session.WaitWithDefaultTimeout() @@ -689,8 +689,8 @@ var _ = Describe("Podman create", func() { idata := setup.InspectImageJSON() // returns []inspect.ImageData Expect(idata).To(HaveLen(1)) - Expect(idata[0].Os).To(Equal(runtime.GOOS)) - Expect(idata[0].Architecture).To(Equal("arm64")) + Expect(idata[0]).To(HaveField("Os", runtime.GOOS)) + Expect(idata[0]).To(HaveField("Architecture", "arm64")) }) It("podman create --uid/gidmap --pod conflict test", func() { diff --git a/test/e2e/diff_test.go b/test/e2e/diff_test.go index fb6df8f45..a1f57f41b 100644 --- a/test/e2e/diff_test.go +++ b/test/e2e/diff_test.go @@ -26,7 +26,6 @@ var _ = Describe("Podman diff", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/events_test.go b/test/e2e/events_test.go index 1d4560e8e..725118ab0 100644 --- a/test/e2e/events_test.go +++ b/test/e2e/events_test.go @@ -29,7 +29,6 @@ var _ = Describe("Podman events", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index 3987746d0..f4ee688b7 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -27,7 +27,6 @@ var _ = Describe("Podman exec", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/export_test.go b/test/e2e/export_test.go index 78811f1b5..59cbe06ef 100644 --- a/test/e2e/export_test.go +++ b/test/e2e/export_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman export", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go index 1e9d725b7..2ca774a03 100644 --- a/test/e2e/generate_kube_test.go +++ b/test/e2e/generate_kube_test.go @@ -32,7 +32,6 @@ var _ = Describe("Podman generate kube", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -66,12 +65,12 @@ var _ = Describe("Podman generate kube", func() { pod := new(v1.Pod) err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) - Expect(pod.Spec.HostNetwork).To(Equal(false)) + Expect(pod.Spec).To(HaveField("HostNetwork", false)) Expect(pod.Spec.SecurityContext).To(BeNil()) Expect(pod.Spec.DNSConfig).To(BeNil()) - Expect(pod.Spec.Containers[0].WorkingDir).To(Equal("")) + Expect(pod.Spec.Containers[0]).To(HaveField("WorkingDir", "")) Expect(pod.Spec.Containers[0].Env).To(BeNil()) - Expect(pod.Name).To(Equal("top-pod")) + Expect(pod).To(HaveField("Name", "top-pod")) numContainers := 0 for range pod.Spec.Containers { @@ -165,7 +164,7 @@ var _ = Describe("Podman generate kube", func() { pod := new(v1.Pod) err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) - Expect(pod.Spec.HostNetwork).To(Equal(false)) + Expect(pod.Spec).To(HaveField("HostNetwork", false)) numContainers := 0 for range pod.Spec.Containers { @@ -211,7 +210,7 @@ var _ = Describe("Podman generate kube", func() { pod := new(v1.Pod) err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) - Expect(pod.Spec.HostNetwork).To(Equal(false)) + Expect(pod.Spec).To(HaveField("HostNetwork", false)) numContainers := len(pod.Spec.Containers) + len(pod.Spec.InitContainers) Expect(numContainers).To(Equal(3)) @@ -232,7 +231,7 @@ var _ = Describe("Podman generate kube", func() { pod = new(v1.Pod) err = yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) - Expect(pod.Spec.HostNetwork).To(Equal(false)) + Expect(pod.Spec).To(HaveField("HostNetwork", false)) numContainers = len(pod.Spec.Containers) + len(pod.Spec.InitContainers) Expect(numContainers).To(Equal(2)) @@ -257,7 +256,7 @@ var _ = Describe("Podman generate kube", func() { pod = new(v1.Pod) err = yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) - Expect(pod.Spec.HostNetwork).To(Equal(false)) + Expect(pod.Spec).To(HaveField("HostNetwork", false)) numContainers = len(pod.Spec.Containers) + len(pod.Spec.InitContainers) Expect(numContainers).To(Equal(1)) @@ -279,7 +278,7 @@ var _ = Describe("Podman generate kube", func() { pod := new(v1.Pod) err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) - Expect(pod.Spec.HostNetwork).To(Equal(true)) + Expect(pod.Spec).To(HaveField("HostNetwork", true)) }) It("podman generate kube on container with host network", func() { @@ -294,7 +293,7 @@ var _ = Describe("Podman generate kube", func() { pod := new(v1.Pod) err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) - Expect(pod.Spec.HostNetwork).To(Equal(true)) + Expect(pod.Spec).To(HaveField("HostNetwork", true)) }) It("podman generate kube on pod with hostAliases", func() { @@ -325,8 +324,8 @@ var _ = Describe("Podman generate kube", func() { err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) Expect(pod.Spec.HostAliases).To(HaveLen(2)) - Expect(pod.Spec.HostAliases[0].IP).To(Equal(testIP)) - Expect(pod.Spec.HostAliases[1].IP).To(Equal(testIP)) + Expect(pod.Spec.HostAliases[0]).To(HaveField("IP", testIP)) + Expect(pod.Spec.HostAliases[1]).To(HaveField("IP", testIP)) }) It("podman generate service kube on pod", func() { @@ -347,7 +346,7 @@ var _ = Describe("Podman generate kube", func() { Expect(err).To(BeNil()) Expect(svc.Spec.Ports).To(HaveLen(1)) Expect(svc.Spec.Ports[0].TargetPort.IntValue()).To(Equal(4000)) - Expect(svc.Spec.Ports[0].Protocol).To(Equal(v1.ProtocolUDP)) + Expect(svc.Spec.Ports[0]).To(HaveField("Protocol", v1.ProtocolUDP)) pod := new(v1.Pod) err = yaml.Unmarshal([]byte(arr[1]), pod) @@ -506,7 +505,7 @@ var _ = Describe("Podman generate kube", func() { containers := pod.Spec.Containers Expect(containers).To(HaveLen(1)) Expect(containers[0].Ports).To(HaveLen(1)) - Expect(containers[0].Ports[0].Protocol).To(Equal(v1.ProtocolUDP)) + Expect(containers[0].Ports[0]).To(HaveField("Protocol", v1.ProtocolUDP)) }) It("podman generate and reimport kube on pod", func() { @@ -776,8 +775,9 @@ var _ = Describe("Podman generate kube", func() { Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.8.8.8")) Expect(pod.Spec.DNSConfig.Searches).To(ContainElement("foobar.com")) Expect(len(pod.Spec.DNSConfig.Options)).To(BeNumerically(">", 0)) - Expect(pod.Spec.DNSConfig.Options[0].Name).To(Equal("color")) - Expect(*pod.Spec.DNSConfig.Options[0].Value).To(Equal("blue")) + Expect(pod.Spec.DNSConfig.Options[0]).To(HaveField("Name", "color")) + s := "blue" + Expect(pod.Spec.DNSConfig.Options[0]).To(HaveField("Value", &s)) }) It("podman generate kube multiple container dns servers and options are cumulative", func() { @@ -819,8 +819,9 @@ var _ = Describe("Podman generate kube", func() { Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.8.8.8")) Expect(pod.Spec.DNSConfig.Searches).To(ContainElement("foobar.com")) Expect(len(pod.Spec.DNSConfig.Options)).To(BeNumerically(">", 0)) - Expect(pod.Spec.DNSConfig.Options[0].Name).To(Equal("color")) - Expect(*pod.Spec.DNSConfig.Options[0].Value).To(Equal("blue")) + Expect(pod.Spec.DNSConfig.Options[0]).To(HaveField("Name", "color")) + s := "blue" + Expect(pod.Spec.DNSConfig.Options[0]).To(HaveField("Value", &s)) }) It("podman generate kube - set entrypoint as command", func() { @@ -841,8 +842,8 @@ var _ = Describe("Podman generate kube", func() { containers := pod.Spec.Containers Expect(containers).To(HaveLen(1)) - Expect(containers[0].Command).To(Equal([]string{"/bin/sleep"})) - Expect(containers[0].Args).To(Equal([]string{"10s"})) + Expect(containers[0]).To(HaveField("Command", []string{"/bin/sleep"})) + Expect(containers[0]).To(HaveField("Args", []string{"10s"})) }) It("podman generate kube - use command from image unless explicitly set in the podman command", func() { @@ -881,7 +882,7 @@ var _ = Describe("Podman generate kube", func() { containers = pod.Spec.Containers Expect(containers).To(HaveLen(1)) - Expect(containers[0].Command).To(Equal(cmd)) + Expect(containers[0]).To(HaveField("Command", cmd)) }) It("podman generate kube - use entrypoint from image unless --entrypoint is set", func() { @@ -916,7 +917,7 @@ ENTRYPOINT ["sleep"]` containers := pod.Spec.Containers Expect(containers).To(HaveLen(1)) - Expect(containers[0].Args).To(Equal([]string{"10s"})) + Expect(containers[0]).To(HaveField("Args", []string{"10s"})) session = podmanTest.Podman([]string{"create", "--pod", "new:testpod-2", "--entrypoint", "echo", image, "hello"}) session.WaitWithDefaultTimeout() @@ -934,8 +935,8 @@ ENTRYPOINT ["sleep"]` containers = pod.Spec.Containers Expect(containers).To(HaveLen(1)) - Expect(containers[0].Command).To(Equal([]string{"echo"})) - Expect(containers[0].Args).To(Equal([]string{"hello"})) + Expect(containers[0]).To(HaveField("Command", []string{"echo"})) + Expect(containers[0]).To(HaveField("Args", []string{"hello"})) }) It("podman generate kube - --privileged container", func() { @@ -1018,7 +1019,7 @@ USER test1` pvc := new(v1.PersistentVolumeClaim) err := yaml.Unmarshal(kube.Out.Contents(), pvc) Expect(err).To(BeNil()) - Expect(pvc.Name).To(Equal(vol)) + Expect(pvc).To(HaveField("Name", vol)) Expect(pvc.Spec.AccessModes[0]).To(Equal(v1.ReadWriteOnce)) Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal("1Gi")) }) @@ -1040,7 +1041,7 @@ USER test1` pvc := new(v1.PersistentVolumeClaim) err := yaml.Unmarshal(kube.Out.Contents(), pvc) Expect(err).To(BeNil()) - Expect(pvc.Name).To(Equal(vol)) + Expect(pvc).To(HaveField("Name", vol)) Expect(pvc.Spec.AccessModes[0]).To(Equal(v1.ReadWriteOnce)) Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal("1Gi")) @@ -1092,8 +1093,8 @@ USER test1` pod := new(v1.Pod) err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) - Expect(pod.Spec.Containers[0].WorkingDir).To(Equal("")) - Expect(pod.Spec.Containers[1].WorkingDir).To(Equal("/root")) + Expect(pod.Spec.Containers[0]).To(HaveField("WorkingDir", "")) + Expect(pod.Spec.Containers[1]).To(HaveField("WorkingDir", "/root")) for _, ctr := range []string{"top1", "top2"} { Expect(pod.Annotations).To(HaveKeyWithValue("io.containers.autoupdate/"+ctr, "registry")) diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go index e4b854332..08e8fbc8c 100644 --- a/test/e2e/generate_systemd_test.go +++ b/test/e2e/generate_systemd_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman generate systemd", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -581,6 +580,7 @@ var _ = Describe("Podman generate systemd", func() { }) It("podman generate systemd --new create command with double curly braces", func() { + SkipIfInContainer("journald inside a container doesn't work") // Regression test for #9034 session := podmanTest.Podman([]string{"create", "--name", "foo", "--log-driver=journald", "--log-opt=tag={{.Name}}", ALPINE}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go index 23f1a1dbf..add739988 100644 --- a/test/e2e/healthcheck_run_test.go +++ b/test/e2e/healthcheck_run_test.go @@ -28,14 +28,13 @@ var _ = Describe("Podman healthcheck run", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { podmanTest.Cleanup() f := CurrentGinkgoTestDescription() timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds()) - GinkgoWriter.Write([]byte(timedResult)) + _, _ = GinkgoWriter.Write([]byte(timedResult)) }) @@ -168,7 +167,7 @@ var _ = Describe("Podman healthcheck run", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) inspect := podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Health.Status).To(Equal("starting")) + Expect(inspect[0].State.Health).To(HaveField("Status", "starting")) }) It("podman healthcheck failed checks in start-period should not change status", func() { @@ -189,9 +188,9 @@ var _ = Describe("Podman healthcheck run", func() { Expect(hc).Should(Exit(1)) inspect := podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Health.Status).To(Equal("starting")) + Expect(inspect[0].State.Health).To(HaveField("Status", "starting")) // test old podman compat (see #11645) - Expect(inspect[0].State.Healthcheck().Status).To(Equal("starting")) + Expect(inspect[0].State.Healthcheck()).To(HaveField("Status", "starting")) }) It("podman healthcheck failed checks must reach retries before unhealthy ", func() { @@ -204,16 +203,16 @@ var _ = Describe("Podman healthcheck run", func() { Expect(hc).Should(Exit(1)) inspect := podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Health.Status).To(Equal("starting")) + Expect(inspect[0].State.Health).To(HaveField("Status", "starting")) hc = podmanTest.Podman([]string{"healthcheck", "run", "hc"}) hc.WaitWithDefaultTimeout() Expect(hc).Should(Exit(1)) inspect = podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Health.Status).To(Equal(define.HealthCheckUnhealthy)) + Expect(inspect[0].State.Health).To(HaveField("Status", define.HealthCheckUnhealthy)) // test old podman compat (see #11645) - Expect(inspect[0].State.Healthcheck().Status).To(Equal(define.HealthCheckUnhealthy)) + Expect(inspect[0].State.Healthcheck()).To(HaveField("Status", define.HealthCheckUnhealthy)) }) It("podman healthcheck good check results in healthy even in start-period", func() { @@ -226,7 +225,7 @@ var _ = Describe("Podman healthcheck run", func() { Expect(hc).Should(Exit(0)) inspect := podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Health.Status).To(Equal(define.HealthCheckHealthy)) + Expect(inspect[0].State.Health).To(HaveField("Status", define.HealthCheckHealthy)) }) It("podman healthcheck unhealthy but valid arguments check", func() { @@ -249,14 +248,14 @@ var _ = Describe("Podman healthcheck run", func() { Expect(hc).Should(Exit(1)) inspect := podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Health.Status).To(Equal("starting")) + Expect(inspect[0].State.Health).To(HaveField("Status", "starting")) hc = podmanTest.Podman([]string{"healthcheck", "run", "hc"}) hc.WaitWithDefaultTimeout() Expect(hc).Should(Exit(1)) inspect = podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Health.Status).To(Equal(define.HealthCheckUnhealthy)) + Expect(inspect[0].State.Health).To(HaveField("Status", define.HealthCheckUnhealthy)) foo := podmanTest.Podman([]string{"exec", "hc", "touch", "/foo"}) foo.WaitWithDefaultTimeout() @@ -267,7 +266,7 @@ var _ = Describe("Podman healthcheck run", func() { Expect(hc).Should(Exit(0)) inspect = podmanTest.InspectContainer("hc") - Expect(inspect[0].State.Health.Status).To(Equal(define.HealthCheckHealthy)) + Expect(inspect[0].State.Health).To(HaveField("Status", define.HealthCheckHealthy)) // Test podman ps --filter heath is working (#11687) ps := podmanTest.Podman([]string{"ps", "--filter", "health=healthy"}) @@ -328,6 +327,6 @@ HEALTHCHECK CMD ls -l / 2>&1`, ALPINE) // Check to make sure a default time interval value was added Expect(inspect[0].Config.Healthcheck.Interval).To(BeNumerically("==", 30000000000)) // Check to make sure characters were not coerced to utf8 - Expect(inspect[0].Config.Healthcheck.Test).To(Equal([]string{"CMD-SHELL", "ls -l / 2>&1"})) + Expect(inspect[0].Config.Healthcheck).To(HaveField("Test", []string{"CMD-SHELL", "ls -l / 2>&1"})) }) }) diff --git a/test/e2e/history_test.go b/test/e2e/history_test.go index 92e0e1b08..d637fd9af 100644 --- a/test/e2e/history_test.go +++ b/test/e2e/history_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman history", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/hooks/checkhook.json b/test/e2e/hooks/checkhook.json deleted file mode 100644 index 5a9bc86d1..000000000 --- a/test/e2e/hooks/checkhook.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "cmd" : [".*"], - "hook" : "/tmp/checkhook.sh", - "stage" : [ "prestart" ] -} diff --git a/test/e2e/hooks/checkhook.sh b/test/e2e/hooks/checkhook.sh deleted file mode 100755 index 8b755cb40..000000000 --- a/test/e2e/hooks/checkhook.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -echo $@ >> /run/hookscheck -read line -echo $line >> /run/hookscheck diff --git a/test/e2e/image_scp_test.go b/test/e2e/image_scp_test.go index 5abdf74f8..2ad3cc75e 100644 --- a/test/e2e/image_scp_test.go +++ b/test/e2e/image_scp_test.go @@ -75,7 +75,7 @@ var _ = Describe("podman image scp", func() { cfg, err := config.ReadCustomConfig() Expect(err).ShouldNot(HaveOccurred()) - Expect(cfg.Engine.ActiveService).To(Equal("QA")) + Expect(cfg.Engine).To(HaveField("ActiveService", "QA")) Expect(cfg.Engine.ServiceDestinations).To(HaveKeyWithValue("QA", config.Destination{ URI: "ssh://root@server.fubar.com:2222/run/podman/podman.sock", diff --git a/test/e2e/image_sign_test.go b/test/e2e/image_sign_test.go index dbf697bb0..3c819a7d2 100644 --- a/test/e2e/image_sign_test.go +++ b/test/e2e/image_sign_test.go @@ -28,8 +28,6 @@ var _ = Describe("Podman image sign", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() - tempGNUPGHOME := filepath.Join(podmanTest.TempDir, "tmpGPG") err := os.Mkdir(tempGNUPGHOME, os.ModePerm) Expect(err).To(BeNil()) diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index fc1c48c15..2473ec59e 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -27,7 +27,6 @@ var _ = Describe("Podman images", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/import_test.go b/test/e2e/import_test.go index f62df23d9..e6995f0e6 100644 --- a/test/e2e/import_test.go +++ b/test/e2e/import_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman import", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/init_test.go b/test/e2e/init_test.go index c4c090daf..ccc102fa3 100644 --- a/test/e2e/init_test.go +++ b/test/e2e/init_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman init", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -57,7 +56,7 @@ var _ = Describe("Podman init", func() { result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) conData := result.InspectContainerToJSON() - Expect(conData[0].State.Status).To(Equal("initialized")) + Expect(conData[0].State).To(HaveField("Status", "initialized")) }) It("podman init single container by name", func() { @@ -72,7 +71,7 @@ var _ = Describe("Podman init", func() { result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) conData := result.InspectContainerToJSON() - Expect(conData[0].State.Status).To(Equal("initialized")) + Expect(conData[0].State).To(HaveField("Status", "initialized")) }) It("podman init latest container", func() { @@ -87,7 +86,7 @@ var _ = Describe("Podman init", func() { result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) conData := result.InspectContainerToJSON() - Expect(conData[0].State.Status).To(Equal("initialized")) + Expect(conData[0].State).To(HaveField("Status", "initialized")) }) It("podman init all three containers, one running", func() { @@ -107,17 +106,17 @@ var _ = Describe("Podman init", func() { result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) conData := result.InspectContainerToJSON() - Expect(conData[0].State.Status).To(Equal("initialized")) + Expect(conData[0].State).To(HaveField("Status", "initialized")) result2 := podmanTest.Podman([]string{"inspect", "test2"}) result2.WaitWithDefaultTimeout() Expect(result2).Should(Exit(0)) conData2 := result2.InspectContainerToJSON() - Expect(conData2[0].State.Status).To(Equal("initialized")) + Expect(conData2[0].State).To(HaveField("Status", "initialized")) result3 := podmanTest.Podman([]string{"inspect", "test3"}) result3.WaitWithDefaultTimeout() Expect(result3).Should(Exit(0)) conData3 := result3.InspectContainerToJSON() - Expect(conData3[0].State.Status).To(Equal("running")) + Expect(conData3[0].State).To(HaveField("Status", "running")) }) It("podman init running container errors", func() { diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go index bb5a3a6ad..6fe850f0b 100644 --- a/test/e2e/inspect_test.go +++ b/test/e2e/inspect_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman inspect", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -189,7 +188,7 @@ var _ = Describe("Podman inspect", func() { imageData := session.InspectImageJSON() Expect(imageData[0].HealthCheck.Timeout).To(BeNumerically("==", 3000000000)) Expect(imageData[0].HealthCheck.Interval).To(BeNumerically("==", 60000000000)) - Expect(imageData[0].HealthCheck.Test).To(Equal([]string{"CMD-SHELL", "curl -f http://localhost/ || exit 1"})) + Expect(imageData[0].HealthCheck).To(HaveField("Test", []string{"CMD-SHELL", "curl -f http://localhost/ || exit 1"})) }) It("podman inspect --latest with no container fails", func() { @@ -217,7 +216,7 @@ var _ = Describe("Podman inspect", func() { imageJSON := imageInspect.InspectImageJSON() Expect(imageJSON).To(HaveLen(1)) - Expect(baseJSON[0].ID).To(Equal(imageJSON[0].ID)) + Expect(baseJSON[0]).To(HaveField("ID", imageJSON[0].ID)) }) It("podman [image, container] inspect on container", func() { @@ -242,7 +241,7 @@ var _ = Describe("Podman inspect", func() { imageInspect.WaitWithDefaultTimeout() Expect(imageInspect).To(ExitWithError()) - Expect(baseJSON[0].ID).To(Equal(ctrJSON[0].ID)) + Expect(baseJSON[0]).To(HaveField("ID", ctrJSON[0].ID)) }) It("podman inspect always produces a valid array", func() { @@ -264,7 +263,7 @@ var _ = Describe("Podman inspect", func() { Expect(baseInspect).To(ExitWithError()) baseJSON := baseInspect.InspectContainerToJSON() Expect(baseJSON).To(HaveLen(1)) - Expect(baseJSON[0].Name).To(Equal(ctrName)) + Expect(baseJSON[0]).To(HaveField("Name", ctrName)) }) It("podman inspect container + image with same name gives container", func() { @@ -283,7 +282,7 @@ var _ = Describe("Podman inspect", func() { Expect(baseInspect).Should(Exit(0)) baseJSON := baseInspect.InspectContainerToJSON() Expect(baseJSON).To(HaveLen(1)) - Expect(baseJSON[0].Name).To(Equal(ctrName)) + Expect(baseJSON[0]).To(HaveField("Name", ctrName)) }) It("podman inspect - HostConfig.SecurityOpt ", func() { @@ -307,7 +306,7 @@ var _ = Describe("Podman inspect", func() { Expect(baseInspect).Should(Exit(0)) baseJSON := baseInspect.InspectContainerToJSON() Expect(baseJSON).To(HaveLen(1)) - Expect(baseJSON[0].HostConfig.SecurityOpt).To(Equal([]string{"label=type:spc_t,label=level:s0", "seccomp=unconfined"})) + Expect(baseJSON[0].HostConfig).To(HaveField("SecurityOpt", []string{"label=type:spc_t,label=level:s0", "seccomp=unconfined"})) }) It("podman inspect pod", func() { @@ -321,7 +320,7 @@ var _ = Describe("Podman inspect", func() { Expect(inspect).Should(Exit(0)) Expect(inspect.OutputToString()).To(BeValidJSON()) podData := inspect.InspectPodArrToJSON() - Expect(podData[0].Name).To(Equal(podName)) + Expect(podData[0]).To(HaveField("Name", podName)) }) It("podman inspect pod with type", func() { @@ -335,7 +334,7 @@ var _ = Describe("Podman inspect", func() { Expect(inspect).Should(Exit(0)) Expect(inspect.OutputToString()).To(BeValidJSON()) podData := inspect.InspectPodArrToJSON() - Expect(podData[0].Name).To(Equal(podName)) + Expect(podData[0]).To(HaveField("Name", podName)) }) It("podman inspect latest pod", func() { @@ -350,7 +349,7 @@ var _ = Describe("Podman inspect", func() { Expect(inspect).Should(Exit(0)) Expect(inspect.OutputToString()).To(BeValidJSON()) podData := inspect.InspectPodArrToJSON() - Expect(podData[0].Name).To(Equal(podName)) + Expect(podData[0]).To(HaveField("Name", podName)) }) It("podman inspect latest defaults to latest container", func() { SkipIfRemote("--latest flag n/a") @@ -371,7 +370,7 @@ var _ = Describe("Podman inspect", func() { Expect(inspect).Should(Exit(0)) Expect(inspect.OutputToString()).To(BeValidJSON()) containerData := inspect.InspectContainerToJSON() - Expect(containerData[0].Name).To(Equal(infra)) + Expect(containerData[0]).To(HaveField("Name", infra)) }) It("podman inspect network", func() { diff --git a/test/e2e/libpod_suite_remote_test.go b/test/e2e/libpod_suite_remote_test.go index 9ad2bf7b9..19affbc6d 100644 --- a/test/e2e/libpod_suite_remote_test.go +++ b/test/e2e/libpod_suite_remote_test.go @@ -16,6 +16,7 @@ import ( "time" "github.com/containers/podman/v4/pkg/rootless" + . "github.com/onsi/gomega" ) func IsRemote() bool { @@ -57,7 +58,8 @@ func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() { func (p *PodmanTestIntegration) setRegistriesConfigEnv(b []byte) { outfile := filepath.Join(p.TempDir, "registries.conf") os.Setenv("CONTAINERS_REGISTRIES_CONF", outfile) - ioutil.WriteFile(outfile, b, 0644) + err := ioutil.WriteFile(outfile, b, 0644) + Expect(err).ToNot(HaveOccurred()) } func resetRegistriesConfigEnv() { @@ -71,7 +73,8 @@ func PodmanTestCreate(tempDir string) *PodmanTestIntegration { func (p *PodmanTestIntegration) StartRemoteService() { if os.Geteuid() == 0 { - os.MkdirAll("/run/podman", 0755) + err := os.MkdirAll("/run/podman", 0755) + Expect(err).ToNot(HaveOccurred()) } args := []string{} @@ -88,7 +91,8 @@ func (p *PodmanTestIntegration) StartRemoteService() { command.Stdout = os.Stdout command.Stderr = os.Stderr fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " ")) - command.Start() + err := command.Start() + Expect(err).ToNot(HaveOccurred()) command.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} p.RemoteCommand = command p.RemoteSession = command.Process @@ -134,9 +138,6 @@ func getRemoteOptions(p *PodmanTestIntegration, args []string) []string { networkDir := p.NetworkConfigDir podmanOptions := strings.Split(fmt.Sprintf("--root %s --runroot %s --runtime %s --conmon %s --network-config-dir %s --cgroup-manager %s", p.Root, p.RunRoot, p.OCIRuntime, p.ConmonBinary, networkDir, p.CgroupManager), " ") - if os.Getenv("HOOK_OPTION") != "" { - podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION")) - } if p.NetworkBackend.ToString() == "netavark" { podmanOptions = append(podmanOptions, "--network-backend", "netavark") } @@ -145,11 +146,6 @@ func getRemoteOptions(p *PodmanTestIntegration, args []string) []string { return podmanOptions } -// SeedImages restores all the artifacts into the main store for remote tests -func (p *PodmanTestIntegration) SeedImages() error { - return nil -} - // RestoreArtifact puts the cached image into our test store func (p *PodmanTestIntegration) RestoreArtifact(image string) error { tarball := imageTarPath(image) @@ -159,8 +155,12 @@ func (p *PodmanTestIntegration) RestoreArtifact(image string) error { podmanOptions := getRemoteOptions(p, args) command := exec.Command(p.PodmanBinary, podmanOptions...) fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " ")) - command.Start() - command.Wait() + if err := command.Start(); err != nil { + return err + } + if err := command.Wait(); err != nil { + return err + } } return nil } diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go index cf81a0348..a633bd3d7 100644 --- a/test/e2e/libpod_suite_test.go +++ b/test/e2e/libpod_suite_test.go @@ -10,6 +10,7 @@ import ( "path/filepath" "github.com/containers/podman/v4/pkg/rootless" + . "github.com/onsi/gomega" ) func IsRemote() bool { @@ -40,13 +41,15 @@ func (p *PodmanTestIntegration) PodmanExtraFiles(args []string, extraFiles []*os func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() { defaultFile := filepath.Join(INTEGRATION_ROOT, "test/registries.conf") - os.Setenv("CONTAINERS_REGISTRIES_CONF", defaultFile) + err := os.Setenv("CONTAINERS_REGISTRIES_CONF", defaultFile) + Expect(err).ToNot(HaveOccurred()) } func (p *PodmanTestIntegration) setRegistriesConfigEnv(b []byte) { outfile := filepath.Join(p.TempDir, "registries.conf") os.Setenv("CONTAINERS_REGISTRIES_CONF", outfile) - ioutil.WriteFile(outfile, b, 0644) + err := ioutil.WriteFile(outfile, b, 0644) + Expect(err).ToNot(HaveOccurred()) } func resetRegistriesConfigEnv() { @@ -70,11 +73,6 @@ func (p *PodmanTestIntegration) RestoreArtifact(image string) error { func (p *PodmanTestIntegration) StopRemoteService() {} -// SeedImages is a no-op for localized testing -func (p *PodmanTestIntegration) SeedImages() error { - return nil -} - // We don't support running API service when local func (p *PodmanTestIntegration) StartRemoteService() { } diff --git a/test/e2e/login_logout_test.go b/test/e2e/login_logout_test.go index 001779cdf..bce8b78c6 100644 --- a/test/e2e/login_logout_test.go +++ b/test/e2e/login_logout_test.go @@ -36,7 +36,8 @@ var _ = Describe("Podman login and logout", func() { podmanTest = PodmanTestCreate(tempdir) authPath = filepath.Join(podmanTest.TempDir, "auth") - os.Mkdir(authPath, os.ModePerm) + err := os.Mkdir(authPath, os.ModePerm) + Expect(err).ToNot(HaveOccurred()) if IsCommandAvailable("getenforce") { ge := SystemExec("getenforce", []string{}) @@ -55,11 +56,14 @@ var _ = Describe("Podman login and logout", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - f, _ := os.Create(filepath.Join(authPath, "htpasswd")) + f, err := os.Create(filepath.Join(authPath, "htpasswd")) + Expect(err).ToNot(HaveOccurred()) defer f.Close() - f.WriteString(session.OutputToString()) - f.Sync() + _, err = f.WriteString(session.OutputToString()) + Expect(err).ToNot(HaveOccurred()) + err = f.Sync() + Expect(err).ToNot(HaveOccurred()) port := GetPort() server = strings.Join([]string{"localhost", strconv.Itoa(port)}, ":") @@ -68,7 +72,8 @@ var _ = Describe("Podman login and logout", func() { testImg = strings.Join([]string{server, "test-alpine"}, "/") certDirPath = filepath.Join(os.Getenv("HOME"), ".config/containers/certs.d", server) - os.MkdirAll(certDirPath, os.ModePerm) + err = os.MkdirAll(certDirPath, os.ModePerm) + Expect(err).ToNot(HaveOccurred()) cwd, _ := os.Getwd() certPath = filepath.Join(cwd, "../", "certs") @@ -207,7 +212,8 @@ var _ = Describe("Podman login and logout", func() { }) It("podman login and logout with --cert-dir", func() { certDir := filepath.Join(podmanTest.TempDir, "certs") - os.MkdirAll(certDir, os.ModePerm) + err := os.MkdirAll(certDir, os.ModePerm) + Expect(err).ToNot(HaveOccurred()) setup := SystemExec("cp", []string{filepath.Join(certPath, "domain.crt"), filepath.Join(certDir, "ca.crt")}) setup.WaitWithDefaultTimeout() @@ -226,7 +232,8 @@ var _ = Describe("Podman login and logout", func() { }) It("podman login and logout with multi registry", func() { certDir := filepath.Join(os.Getenv("HOME"), ".config/containers/certs.d", "localhost:9001") - os.MkdirAll(certDir, os.ModePerm) + err = os.MkdirAll(certDir, os.ModePerm) + Expect(err).ToNot(HaveOccurred()) cwd, _ := os.Getwd() certPath = filepath.Join(cwd, "../", "certs") diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index 934a306ce..4e6dcb8af 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -37,9 +37,6 @@ var _ = Describe("Podman logs", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - if err := podmanTest.SeedImages(); err != nil { - os.Exit(1) - } }) AfterEach(func() { diff --git a/test/e2e/manifest_test.go b/test/e2e/manifest_test.go index 230864891..92b8bc2e1 100644 --- a/test/e2e/manifest_test.go +++ b/test/e2e/manifest_test.go @@ -36,7 +36,6 @@ var _ = Describe("Podman manifest", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/mount_rootless_test.go b/test/e2e/mount_rootless_test.go index 30d7ce8a9..994a5899b 100644 --- a/test/e2e/mount_rootless_test.go +++ b/test/e2e/mount_rootless_test.go @@ -25,7 +25,6 @@ var _ = Describe("Podman mount", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/namespace_test.go b/test/e2e/namespace_test.go index bc9db4cd9..0000a2327 100644 --- a/test/e2e/namespace_test.go +++ b/test/e2e/namespace_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman namespaces", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/network_create_test.go b/test/e2e/network_create_test.go index 82b99bd68..69966b07e 100644 --- a/test/e2e/network_create_test.go +++ b/test/e2e/network_create_test.go @@ -32,7 +32,6 @@ var _ = Describe("Podman network create", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -59,7 +58,7 @@ var _ = Describe("Podman network create", func() { Expect(err).To(BeNil()) Expect(results).To(HaveLen(1)) result := results[0] - Expect(result.Name).To(Equal(netName)) + Expect(result).To(HaveField("Name", netName)) Expect(result.Subnets).To(HaveLen(1)) Expect(result.Subnets[0].Subnet.String()).To(Equal("10.11.12.0/24")) Expect(result.Subnets[0].Gateway.String()).To(Equal("10.11.12.1")) @@ -102,7 +101,7 @@ var _ = Describe("Podman network create", func() { Expect(err).To(BeNil()) Expect(results).To(HaveLen(1)) result := results[0] - Expect(result.Name).To(Equal(netName)) + Expect(result).To(HaveField("Name", netName)) Expect(result.Subnets).To(HaveLen(1)) Expect(result.Subnets[0].Gateway.String()).To(Equal("fd00:1:2:3::1")) Expect(result.Subnets[0].Subnet.String()).To(Equal("fd00:1:2:3::/64")) @@ -141,7 +140,7 @@ var _ = Describe("Podman network create", func() { Expect(err).To(BeNil()) Expect(results).To(HaveLen(1)) result := results[0] - Expect(result.Name).To(Equal(netName)) + Expect(result).To(HaveField("Name", netName)) Expect(result.Subnets).To(HaveLen(2)) Expect(result.Subnets[0].Subnet.IP).ToNot(BeNil()) Expect(result.Subnets[1].Subnet.IP).ToNot(BeNil()) @@ -173,7 +172,7 @@ var _ = Describe("Podman network create", func() { Expect(err).To(BeNil()) Expect(results).To(HaveLen(1)) result = results[0] - Expect(result.Name).To(Equal(netName2)) + Expect(result).To(HaveField("Name", netName2)) Expect(result.Subnets).To(HaveLen(2)) Expect(result.Subnets[0].Subnet.IP).ToNot(BeNil()) Expect(result.Subnets[1].Subnet.IP).ToNot(BeNil()) diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go index 89a9005f5..c67a4baed 100644 --- a/test/e2e/network_test.go +++ b/test/e2e/network_test.go @@ -293,8 +293,8 @@ var _ = Describe("Podman network", func() { Expect(conData[0].NetworkSettings.Networks).To(HaveLen(1)) net, ok := conData[0].NetworkSettings.Networks[netName] Expect(ok).To(BeTrue()) - Expect(net.NetworkID).To(Equal(netName)) - Expect(net.IPPrefixLen).To(Equal(24)) + Expect(net).To(HaveField("NetworkID", netName)) + Expect(net).To(HaveField("IPPrefixLen", 24)) Expect(net.IPAddress).To(HavePrefix("10.50.50.")) // Necessary to ensure the CNI network is removed cleanly @@ -329,10 +329,10 @@ var _ = Describe("Podman network", func() { Expect(conData[0].NetworkSettings.Networks).To(HaveLen(2)) net1, ok := conData[0].NetworkSettings.Networks[netName1] Expect(ok).To(BeTrue()) - Expect(net1.NetworkID).To(Equal(netName1)) + Expect(net1).To(HaveField("NetworkID", netName1)) net2, ok := conData[0].NetworkSettings.Networks[netName2] Expect(ok).To(BeTrue()) - Expect(net2.NetworkID).To(Equal(netName2)) + Expect(net2).To(HaveField("NetworkID", netName2)) // Necessary to ensure the CNI network is removed cleanly rmAll := podmanTest.Podman([]string{"rm", "-t", "0", "-f", ctrName}) @@ -366,13 +366,13 @@ var _ = Describe("Podman network", func() { Expect(conData[0].NetworkSettings.Networks).To(HaveLen(2)) net1, ok := conData[0].NetworkSettings.Networks[netName1] Expect(ok).To(BeTrue()) - Expect(net1.NetworkID).To(Equal(netName1)) - Expect(net1.IPPrefixLen).To(Equal(25)) + Expect(net1).To(HaveField("NetworkID", netName1)) + Expect(net1).To(HaveField("IPPrefixLen", 25)) Expect(net1.IPAddress).To(HavePrefix("10.50.51.")) net2, ok := conData[0].NetworkSettings.Networks[netName2] Expect(ok).To(BeTrue()) - Expect(net2.NetworkID).To(Equal(netName2)) - Expect(net2.IPPrefixLen).To(Equal(26)) + Expect(net2).To(HaveField("NetworkID", netName2)) + Expect(net2).To(HaveField("IPPrefixLen", 26)) Expect(net2.IPAddress).To(HavePrefix("10.50.51.")) // Necessary to ensure the CNI network is removed cleanly @@ -601,7 +601,7 @@ var _ = Describe("Podman network", func() { Expect(err).To(BeNil()) Expect(results).To(HaveLen(1)) result := results[0] - Expect(result.NetworkInterface).To(Equal("")) + Expect(result).To(HaveField("NetworkInterface", "")) Expect(result.IPAMOptions).To(HaveKeyWithValue("driver", "dhcp")) nc = podmanTest.Podman([]string{"network", "rm", net}) @@ -628,8 +628,8 @@ var _ = Describe("Podman network", func() { Expect(results).To(HaveLen(1)) result := results[0] - Expect(result.Driver).To(Equal("macvlan")) - Expect(result.NetworkInterface).To(Equal("lo")) + Expect(result).To(HaveField("Driver", "macvlan")) + Expect(result).To(HaveField("NetworkInterface", "lo")) Expect(result.IPAMOptions).To(HaveKeyWithValue("driver", "dhcp")) Expect(result.Subnets).To(HaveLen(0)) @@ -672,8 +672,8 @@ var _ = Describe("Podman network", func() { result := results[0] Expect(result.Options).To(HaveKeyWithValue("mtu", "1500")) - Expect(result.Driver).To(Equal("macvlan")) - Expect(result.NetworkInterface).To(Equal("lo")) + Expect(result).To(HaveField("Driver", "macvlan")) + Expect(result).To(HaveField("NetworkInterface", "lo")) Expect(result.IPAMOptions).To(HaveKeyWithValue("driver", "host-local")) Expect(result.Subnets).To(HaveLen(1)) diff --git a/test/e2e/pause_test.go b/test/e2e/pause_test.go index 66638d71c..402719de2 100644 --- a/test/e2e/pause_test.go +++ b/test/e2e/pause_test.go @@ -45,7 +45,6 @@ var _ = Describe("Podman pause", func() { podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/play_build_test.go b/test/e2e/play_build_test.go index 96785c569..914144ae6 100644 --- a/test/e2e/play_build_test.go +++ b/test/e2e/play_build_test.go @@ -29,7 +29,6 @@ var _ = Describe("Podman play kube with build", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 46a8e88bc..0e91db04c 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -1206,8 +1206,6 @@ var _ = Describe("Podman play kube", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() - kubeYaml = filepath.Join(podmanTest.TempDir, "kube.yaml") }) @@ -2220,7 +2218,7 @@ spec: Expect(ctr[0].Config.WorkingDir).To(ContainSubstring("/etc")) Expect(ctr[0].Config.Labels).To(HaveKeyWithValue("key1", ContainSubstring("value1"))) Expect(ctr[0].Config.Labels).To(HaveKeyWithValue("key1", ContainSubstring("value1"))) - Expect(ctr[0].Config.StopSignal).To(Equal(uint(51))) + Expect(ctr[0].Config).To(HaveField("StopSignal", uint(51))) }) // Deployment related tests @@ -2528,7 +2526,7 @@ VOLUME %s`, ALPINE, hostPathDir+"/") // only one will be mounted. Host path volumes take precedence. ctrJSON := inspect.InspectContainerToJSON() Expect(ctrJSON[0].Mounts).To(HaveLen(1)) - Expect(ctrJSON[0].Mounts[0].Type).To(Equal("bind")) + Expect(ctrJSON[0].Mounts[0]).To(HaveField("Type", "bind")) }) @@ -2744,6 +2742,7 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`}) }) It("podman play kube applies log driver to containers", func() { + SkipIfInContainer("journald inside a container doesn't work") pod := getPod() err := generateKubeYaml("pod", pod, kubeYaml) Expect(err).To(BeNil()) diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index 8def80213..dedb1caeb 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -35,7 +35,6 @@ var _ = Describe("Podman pod create", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -279,7 +278,7 @@ var _ = Describe("Podman pod create", func() { ctrInspect.WaitWithDefaultTimeout() Expect(ctrInspect).Should(Exit(0)) ctrJSON := ctrInspect.InspectContainerToJSON() - Expect(ctrJSON[0].NetworkSettings.IPAddress).To(Equal(ip)) + Expect(ctrJSON[0].NetworkSettings).To(HaveField("IPAddress", ip)) }) It("podman create pod with IP address and no infra should fail", func() { @@ -336,7 +335,7 @@ var _ = Describe("Podman pod create", func() { check := podmanTest.Podman([]string{"pod", "inspect", "abc"}) check.WaitWithDefaultTimeout() data := check.InspectPodToJSON() - Expect(data.ID).To(Equal(string(id))) + Expect(data).To(HaveField("ID", string(id))) }) It("podman pod create --replace", func() { @@ -551,8 +550,8 @@ ENTRYPOINT ["sleep","99999"] podInspect.WaitWithDefaultTimeout() Expect(podInspect).Should(Exit(0)) podJSON := podInspect.InspectPodToJSON() - Expect(podJSON.CPUPeriod).To(Equal(period)) - Expect(podJSON.CPUQuota).To(Equal(quota)) + Expect(podJSON).To(HaveField("CPUPeriod", period)) + Expect(podJSON).To(HaveField("CPUQuota", quota)) }) It("podman pod create --cpuset-cpus", func() { @@ -573,7 +572,7 @@ ENTRYPOINT ["sleep","99999"] podInspect.WaitWithDefaultTimeout() Expect(podInspect).Should(Exit(0)) podJSON := podInspect.InspectPodToJSON() - Expect(podJSON.CPUSetCPUs).To(Equal(in)) + Expect(podJSON).To(HaveField("CPUSetCPUs", in)) }) It("podman pod create --pid", func() { @@ -587,7 +586,7 @@ ENTRYPOINT ["sleep","99999"] podInspect.WaitWithDefaultTimeout() Expect(podInspect).Should(Exit(0)) podJSON := podInspect.InspectPodToJSON() - Expect(podJSON.InfraConfig.PidNS).To(Equal(ns)) + Expect(podJSON.InfraConfig).To(HaveField("PidNS", ns)) podName = "pidPod2" ns = "pod" @@ -607,7 +606,7 @@ ENTRYPOINT ["sleep","99999"] podInspect.WaitWithDefaultTimeout() Expect(podInspect).Should(Exit(0)) podJSON = podInspect.InspectPodToJSON() - Expect(podJSON.InfraConfig.PidNS).To(Equal("host")) + Expect(podJSON.InfraConfig).To(HaveField("PidNS", "host")) podName = "pidPod4" ns = "private" @@ -620,7 +619,7 @@ ENTRYPOINT ["sleep","99999"] podInspect.WaitWithDefaultTimeout() Expect(podInspect).Should(Exit(0)) podJSON = podInspect.InspectPodToJSON() - Expect(podJSON.InfraConfig.PidNS).To(Equal("private")) + Expect(podJSON.InfraConfig).To(HaveField("PidNS", "private")) podName = "pidPod5" ns = "container:randomfakeid" @@ -856,7 +855,7 @@ ENTRYPOINT ["sleep","99999"] podInspect.WaitWithDefaultTimeout() Expect(podInspect).Should(Exit(0)) data := podInspect.InspectPodToJSON() - Expect(data.Mounts[0].Name).To(Equal(volName)) + Expect(data.Mounts[0]).To(HaveField("Name", volName)) ctrName := "testCtr" ctrCreate := podmanTest.Podman([]string{"create", "--pod", podName, "--name", ctrName, ALPINE}) ctrCreate.WaitWithDefaultTimeout() @@ -865,7 +864,7 @@ ENTRYPOINT ["sleep","99999"] ctrInspect.WaitWithDefaultTimeout() Expect(ctrInspect).Should(Exit(0)) ctrData := ctrInspect.InspectContainerToJSON() - Expect(ctrData[0].Mounts[0].Name).To(Equal(volName)) + Expect(ctrData[0].Mounts[0]).To(HaveField("Name", volName)) ctr2 := podmanTest.Podman([]string{"run", "--pod", podName, ALPINE, "sh", "-c", "echo hello >> " + "/tmp1/test"}) ctr2.WaitWithDefaultTimeout() @@ -934,7 +933,7 @@ ENTRYPOINT ["sleep","99999"] ctrInspect.WaitWithDefaultTimeout() Expect(ctrInspect).Should(Exit(0)) data := ctrInspect.InspectContainerToJSON() - Expect(data[0].Mounts[0].Name).To(Equal(volName)) + Expect(data[0].Mounts[0]).To(HaveField("Name", volName)) podName := "testPod" podCreate := podmanTest.Podman([]string{"pod", "create", "--volumes-from", ctrName, "--name", podName}) podCreate.WaitWithDefaultTimeout() @@ -943,7 +942,7 @@ ENTRYPOINT ["sleep","99999"] podInspect.WaitWithDefaultTimeout() Expect(podInspect).Should(Exit(0)) podData := podInspect.InspectPodToJSON() - Expect(podData.Mounts[0].Name).To(Equal(volName)) + Expect(podData.Mounts[0]).To(HaveField("Name", volName)) ctr2 := podmanTest.Podman([]string{"run", "--pod", podName, ALPINE, "sh", "-c", "echo hello >> " + "/tmp1/test"}) ctr2.WaitWithDefaultTimeout() @@ -986,7 +985,7 @@ ENTRYPOINT ["sleep","99999"] Expect(ctrCreate).Should(Exit(0)) ctrInspect := podmanTest.InspectContainer(ctrCreate.OutputToString()) - Expect(ctrInspect[0].HostConfig.SecurityOpt).To(Equal([]string{"label=type:spc_t", "seccomp=unconfined"})) + Expect(ctrInspect[0].HostConfig).To(HaveField("SecurityOpt", []string{"label=type:spc_t", "seccomp=unconfined"})) podCreate = podmanTest.Podman([]string{"pod", "create", "--security-opt", "label=disable"}) podCreate.WaitWithDefaultTimeout() @@ -1012,7 +1011,7 @@ ENTRYPOINT ["sleep","99999"] Expect(ctrCreate).Should(Exit(0)) ctrInspect := podmanTest.InspectContainer(ctrCreate.OutputToString()) - Expect(ctrInspect[0].HostConfig.SecurityOpt).To(Equal([]string{"seccomp=unconfined"})) + Expect(ctrInspect[0].HostConfig).To(HaveField("SecurityOpt", []string{"seccomp=unconfined"})) }) It("podman pod create --security-opt apparmor test", func() { @@ -1028,7 +1027,7 @@ ENTRYPOINT ["sleep","99999"] Expect(ctrCreate).Should(Exit(0)) inspect := podmanTest.InspectContainer(ctrCreate.OutputToString()) - Expect(inspect[0].AppArmorProfile).To(Equal(apparmor.Profile)) + Expect(inspect[0]).To(HaveField("AppArmorProfile", apparmor.Profile)) }) @@ -1090,7 +1089,7 @@ ENTRYPOINT ["sleep","99999"] if podmanTest.CgroupManager == "cgroupfs" || !rootless.IsRootless() { Expect(inspect[0].HostConfig.CgroupParent).To(HaveLen(0)) } else if podmanTest.CgroupManager == "systemd" { - Expect(inspect[0].HostConfig.CgroupParent).To(Equal("user.slice")) + Expect(inspect[0].HostConfig).To(HaveField("CgroupParent", "user.slice")) } podCreate2 := podmanTest.Podman([]string{"pod", "create", "--share", "cgroup,ipc,net,uts", "--share-parent=false", "--infra-name", "cgroupCtr"}) diff --git a/test/e2e/pod_infra_container_test.go b/test/e2e/pod_infra_container_test.go index 2b56502b0..ab204992c 100644 --- a/test/e2e/pod_infra_container_test.go +++ b/test/e2e/pod_infra_container_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman pod create", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_initcontainers_test.go b/test/e2e/pod_initcontainers_test.go index cefaa3dc1..ec429f568 100644 --- a/test/e2e/pod_initcontainers_test.go +++ b/test/e2e/pod_initcontainers_test.go @@ -26,7 +26,6 @@ var _ = Describe("Podman init containers", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -66,7 +65,7 @@ var _ = Describe("Podman init containers", func() { inspect.WaitWithDefaultTimeout() Expect(inspect).Should(Exit(0)) data := inspect.InspectPodToJSON() - Expect(data.State).To(Equal(define.PodStateRunning)) + Expect(data).To(HaveField("State", define.PodStateRunning)) }) It("podman create init container should fail in running pod", func() { diff --git a/test/e2e/pod_inspect_test.go b/test/e2e/pod_inspect_test.go index 19a2772fd..351317cc5 100644 --- a/test/e2e/pod_inspect_test.go +++ b/test/e2e/pod_inspect_test.go @@ -25,7 +25,6 @@ var _ = Describe("Podman pod inspect", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -58,7 +57,7 @@ var _ = Describe("Podman pod inspect", func() { Expect(inspect).Should(Exit(0)) Expect(inspect.OutputToString()).To(BeValidJSON()) podData := inspect.InspectPodToJSON() - Expect(podData.ID).To(Equal(podid)) + Expect(podData).To(HaveField("ID", podid)) }) It("podman pod inspect (CreateCommand)", func() { @@ -98,7 +97,7 @@ var _ = Describe("Podman pod inspect", func() { Expect(err).To(BeNil()) Expect(inspectJSON.InfraConfig).To(Not(BeNil())) Expect(inspectJSON.InfraConfig.PortBindings["80/tcp"]).To(HaveLen(1)) - Expect(inspectJSON.InfraConfig.PortBindings["80/tcp"][0].HostPort).To(Equal("8383")) + Expect(inspectJSON.InfraConfig.PortBindings["80/tcp"][0]).To(HaveField("HostPort", "8383")) }) It("podman pod inspect outputs show correct MAC", func() { diff --git a/test/e2e/pod_kill_test.go b/test/e2e/pod_kill_test.go index 18f9769a1..0612200d4 100644 --- a/test/e2e/pod_kill_test.go +++ b/test/e2e/pod_kill_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman pod kill", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_pause_test.go b/test/e2e/pod_pause_test.go index 57ae75926..d78890347 100644 --- a/test/e2e/pod_pause_test.go +++ b/test/e2e/pod_pause_test.go @@ -26,7 +26,6 @@ var _ = Describe("Podman pod pause", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_pod_namespaces_test.go b/test/e2e/pod_pod_namespaces_test.go index 667a54861..5b288898f 100644 --- a/test/e2e/pod_pod_namespaces_test.go +++ b/test/e2e/pod_pod_namespaces_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman pod create", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_prune_test.go b/test/e2e/pod_prune_test.go index 55ecc1593..dce3e34e4 100644 --- a/test/e2e/pod_prune_test.go +++ b/test/e2e/pod_prune_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman pod prune", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_ps_test.go b/test/e2e/pod_ps_test.go index a0a1e1438..97ca5ff94 100644 --- a/test/e2e/pod_ps_test.go +++ b/test/e2e/pod_ps_test.go @@ -26,7 +26,6 @@ var _ = Describe("Podman ps", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_restart_test.go b/test/e2e/pod_restart_test.go index 1897104cc..fab448f92 100644 --- a/test/e2e/pod_restart_test.go +++ b/test/e2e/pod_restart_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman pod restart", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_rm_test.go b/test/e2e/pod_rm_test.go index dbb2d6d13..a5eab7eed 100644 --- a/test/e2e/pod_rm_test.go +++ b/test/e2e/pod_rm_test.go @@ -28,7 +28,6 @@ var _ = Describe("Podman pod rm", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_start_test.go b/test/e2e/pod_start_test.go index 2f3ef3a11..084a48636 100644 --- a/test/e2e/pod_start_test.go +++ b/test/e2e/pod_start_test.go @@ -27,7 +27,6 @@ var _ = Describe("Podman pod start", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_stats_test.go b/test/e2e/pod_stats_test.go index 0e94406f8..8f76e6e5a 100644 --- a/test/e2e/pod_stats_test.go +++ b/test/e2e/pod_stats_test.go @@ -28,7 +28,6 @@ var _ = Describe("Podman pod stats", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_stop_test.go b/test/e2e/pod_stop_test.go index fc78f9ed6..2fe0aa486 100644 --- a/test/e2e/pod_stop_test.go +++ b/test/e2e/pod_stop_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman pod stop", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_top_test.go b/test/e2e/pod_top_test.go index 564170412..07028da45 100644 --- a/test/e2e/pod_top_test.go +++ b/test/e2e/pod_top_test.go @@ -25,7 +25,6 @@ var _ = Describe("Podman top", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/port_test.go b/test/e2e/port_test.go index d81c03e5b..03263a198 100644 --- a/test/e2e/port_test.go +++ b/test/e2e/port_test.go @@ -25,7 +25,6 @@ var _ = Describe("Podman port", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/prune_test.go b/test/e2e/prune_test.go index 01f987b92..75adf1724 100644 --- a/test/e2e/prune_test.go +++ b/test/e2e/prune_test.go @@ -35,7 +35,6 @@ var _ = Describe("Podman prune", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index 021ebc30b..1100a5d90 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -29,7 +29,6 @@ var _ = Describe("Podman ps", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index 231869e8c..41eb8b449 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -345,7 +345,8 @@ var _ = Describe("Podman pull", func() { podmanTest.AddImageToRWStore(cirros) dirpath := filepath.Join(podmanTest.TempDir, "cirros") - os.MkdirAll(dirpath, os.ModePerm) + err = os.MkdirAll(dirpath, os.ModePerm) + Expect(err).ToNot(HaveOccurred()) imgPath := fmt.Sprintf("dir:%s", dirpath) session := podmanTest.Podman([]string{"push", "cirros", imgPath}) @@ -368,7 +369,8 @@ var _ = Describe("Podman pull", func() { podmanTest.AddImageToRWStore(cirros) dirpath := filepath.Join(podmanTest.TempDir, "cirros") - os.MkdirAll(dirpath, os.ModePerm) + err = os.MkdirAll(dirpath, os.ModePerm) + Expect(err).ToNot(HaveOccurred()) imgPath := fmt.Sprintf("oci:%s", dirpath) session := podmanTest.Podman([]string{"push", "cirros", imgPath}) @@ -387,7 +389,8 @@ var _ = Describe("Podman pull", func() { }) It("podman pull check quiet", func() { - podmanTest.RestoreArtifact(ALPINE) + err := podmanTest.RestoreArtifact(ALPINE) + Expect(err).ToNot(HaveOccurred()) setup := podmanTest.Podman([]string{"images", ALPINE, "-q", "--no-trunc"}) setup.WaitWithDefaultTimeout() Expect(setup).Should(Exit(0)) @@ -428,8 +431,10 @@ var _ = Describe("Podman pull", func() { // We already tested pulling, so we can save some energy and // just restore local artifacts and tag them. - podmanTest.RestoreArtifact(ALPINE) - podmanTest.RestoreArtifact(BB) + err := podmanTest.RestoreArtifact(ALPINE) + Expect(err).ToNot(HaveOccurred()) + err = podmanTest.RestoreArtifact(BB) + Expect(err).ToNot(HaveOccurred()) // What we want is at least two images which have the same name // and are prefixed with two different unqualified-search @@ -514,7 +519,7 @@ var _ = Describe("Podman pull", func() { Expect(data).To(HaveLen(1)) Expect(data[0].RepoTags).To(HaveLen(1)) Expect(data[0].RepoTags[0]).To(Equal(t.tag1)) - Expect(data[0].ID).To(Equal(image1)) + Expect(data[0]).To(HaveField("ID", image1)) } }) @@ -541,8 +546,8 @@ var _ = Describe("Podman pull", func() { data := setup.InspectImageJSON() // returns []inspect.ImageData Expect(data).To(HaveLen(1)) - Expect(data[0].Os).To(Equal(runtime.GOOS)) - Expect(data[0].Architecture).To(Equal("arm64")) + Expect(data[0]).To(HaveField("Os", runtime.GOOS)) + Expect(data[0]).To(HaveField("Architecture", "arm64")) }) It("podman pull --arch", func() { @@ -568,7 +573,7 @@ var _ = Describe("Podman pull", func() { data := setup.InspectImageJSON() // returns []inspect.ImageData Expect(data).To(HaveLen(1)) - Expect(data[0].Os).To(Equal(runtime.GOOS)) - Expect(data[0].Architecture).To(Equal("arm64")) + Expect(data[0]).To(HaveField("Os", runtime.GOOS)) + Expect(data[0]).To(HaveField("Architecture", "arm64")) }) }) diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go index 3b571ab20..0288bf915 100644 --- a/test/e2e/push_test.go +++ b/test/e2e/push_test.go @@ -101,7 +101,8 @@ var _ = Describe("Podman push", func() { Skip("No registry image for ppc64le") } if rootless.IsRootless() { - podmanTest.RestoreArtifact(registry) + err := podmanTest.RestoreArtifact(registry) + Expect(err).ToNot(HaveOccurred()) } lock := GetPortLock("5000") defer lock.Unlock() @@ -132,8 +133,10 @@ var _ = Describe("Podman push", func() { Skip("No registry image for ppc64le") } authPath := filepath.Join(podmanTest.TempDir, "auth") - os.Mkdir(authPath, os.ModePerm) - os.MkdirAll("/etc/containers/certs.d/localhost:5000", os.ModePerm) + err = os.Mkdir(authPath, os.ModePerm) + Expect(err).ToNot(HaveOccurred()) + err = os.MkdirAll("/etc/containers/certs.d/localhost:5000", os.ModePerm) + Expect(err).ToNot(HaveOccurred()) defer os.RemoveAll("/etc/containers/certs.d/localhost:5000") cwd, _ := os.Getwd() @@ -157,11 +160,14 @@ var _ = Describe("Podman push", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - f, _ := os.Create(filepath.Join(authPath, "htpasswd")) + f, err := os.Create(filepath.Join(authPath, "htpasswd")) + Expect(err).ToNot(HaveOccurred()) defer f.Close() - f.WriteString(session.OutputToString()) - f.Sync() + _, err = f.WriteString(session.OutputToString()) + Expect(err).ToNot(HaveOccurred()) + err = f.Sync() + Expect(err).ToNot(HaveOccurred()) session = podmanTest.Podman([]string{"run", "-d", "-p", "5000:5000", "--name", "registry", "-v", strings.Join([]string{authPath, "/auth"}, ":"), "-e", "REGISTRY_AUTH=htpasswd", "-e", diff --git a/test/e2e/rename_test.go b/test/e2e/rename_test.go index ef90c3f22..341490d9c 100644 --- a/test/e2e/rename_test.go +++ b/test/e2e/rename_test.go @@ -24,7 +24,6 @@ var _ = Describe("podman rename", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/restart_test.go b/test/e2e/restart_test.go index b8c74d395..b3052623b 100644 --- a/test/e2e/restart_test.go +++ b/test/e2e/restart_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman restart", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go index f836540b4..7dbe5fed8 100644 --- a/test/e2e/rm_test.go +++ b/test/e2e/rm_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman rm", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_aardvark_test.go b/test/e2e/run_aardvark_test.go index 7b4598423..25eb8b538 100644 --- a/test/e2e/run_aardvark_test.go +++ b/test/e2e/run_aardvark_test.go @@ -25,7 +25,6 @@ var _ = Describe("Podman run networking", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() SkipIfCNI(podmanTest) }) diff --git a/test/e2e/run_apparmor_test.go b/test/e2e/run_apparmor_test.go index 64a01deb7..18d011e6d 100644 --- a/test/e2e/run_apparmor_test.go +++ b/test/e2e/run_apparmor_test.go @@ -42,7 +42,6 @@ var _ = Describe("Podman run", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -61,7 +60,7 @@ var _ = Describe("Podman run", func() { cid := session.OutputToString() // Verify that apparmor.Profile is being set inspect := podmanTest.InspectContainer(cid) - Expect(inspect[0].AppArmorProfile).To(Equal(apparmor.Profile)) + Expect(inspect[0]).To(HaveField("AppArmorProfile", apparmor.Profile)) }) It("podman run no apparmor --privileged", func() { @@ -73,7 +72,7 @@ var _ = Describe("Podman run", func() { cid := session.OutputToString() // Verify that apparmor.Profile is being set inspect := podmanTest.InspectContainer(cid) - Expect(inspect[0].AppArmorProfile).To(Equal("")) + Expect(inspect[0]).To(HaveField("AppArmorProfile", "")) }) It("podman run no apparmor --security-opt=apparmor.Profile --privileged", func() { @@ -85,7 +84,7 @@ var _ = Describe("Podman run", func() { cid := session.OutputToString() // Verify that apparmor.Profile is being set inspect := podmanTest.InspectContainer(cid) - Expect(inspect[0].AppArmorProfile).To(Equal(apparmor.Profile)) + Expect(inspect[0]).To(HaveField("AppArmorProfile", apparmor.Profile)) }) It("podman run apparmor aa-test-profile", func() { @@ -116,7 +115,7 @@ profile aa-test-profile flags=(attach_disconnected,mediate_deleted) { cid := session.OutputToString() // Verify that apparmor.Profile is being set inspect := podmanTest.InspectContainer(cid) - Expect(inspect[0].AppArmorProfile).To(Equal("aa-test-profile")) + Expect(inspect[0]).To(HaveField("AppArmorProfile", "aa-test-profile")) }) It("podman run apparmor invalid", func() { @@ -135,7 +134,7 @@ profile aa-test-profile flags=(attach_disconnected,mediate_deleted) { cid := session.OutputToString() // Verify that apparmor.Profile is being set inspect := podmanTest.InspectContainer(cid) - Expect(inspect[0].AppArmorProfile).To(Equal("unconfined")) + Expect(inspect[0]).To(HaveField("AppArmorProfile", "unconfined")) }) It("podman run apparmor disabled --security-opt apparmor fails", func() { @@ -156,7 +155,7 @@ profile aa-test-profile flags=(attach_disconnected,mediate_deleted) { cid := session.OutputToString() // Verify that apparmor.Profile is being set inspect := podmanTest.InspectContainer(cid) - Expect(inspect[0].AppArmorProfile).To(Equal("")) + Expect(inspect[0]).To(HaveField("AppArmorProfile", "")) }) It("podman run apparmor disabled unconfined", func() { @@ -169,6 +168,6 @@ profile aa-test-profile flags=(attach_disconnected,mediate_deleted) { cid := session.OutputToString() // Verify that apparmor.Profile is being set inspect := podmanTest.InspectContainer(cid) - Expect(inspect[0].AppArmorProfile).To(Equal("")) + Expect(inspect[0]).To(HaveField("AppArmorProfile", "")) }) }) diff --git a/test/e2e/run_cgroup_parent_test.go b/test/e2e/run_cgroup_parent_test.go index 34715be22..24cae43b1 100644 --- a/test/e2e/run_cgroup_parent_test.go +++ b/test/e2e/run_cgroup_parent_test.go @@ -30,7 +30,6 @@ var _ = Describe("Podman run with --cgroup-parent", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_cleanup_test.go b/test/e2e/run_cleanup_test.go index 2282ef913..ea2caf907 100644 --- a/test/e2e/run_cleanup_test.go +++ b/test/e2e/run_cleanup_test.go @@ -23,7 +23,8 @@ var _ = Describe("Podman run exit", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreArtifact(ALPINE) + err = podmanTest.RestoreArtifact(ALPINE) + Expect(err).ToNot(HaveOccurred()) }) AfterEach(func() { diff --git a/test/e2e/run_cpu_test.go b/test/e2e/run_cpu_test.go index fda0a7c24..b21be5729 100644 --- a/test/e2e/run_cpu_test.go +++ b/test/e2e/run_cpu_test.go @@ -33,7 +33,6 @@ var _ = Describe("Podman run cpu", func() { podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_device_test.go b/test/e2e/run_device_test.go index 479837dda..c46afdaca 100644 --- a/test/e2e/run_device_test.go +++ b/test/e2e/run_device_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman run device", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_dns_test.go b/test/e2e/run_dns_test.go index 7561a2e85..61177b4c7 100644 --- a/test/e2e/run_dns_test.go +++ b/test/e2e/run_dns_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman run dns", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_entrypoint_test.go b/test/e2e/run_entrypoint_test.go index fde43dfec..9f35b9e7e 100644 --- a/test/e2e/run_entrypoint_test.go +++ b/test/e2e/run_entrypoint_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman run entrypoint", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_env_test.go b/test/e2e/run_env_test.go index f4c44c23b..bab52efc5 100644 --- a/test/e2e/run_env_test.go +++ b/test/e2e/run_env_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman run", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_exit_test.go b/test/e2e/run_exit_test.go index aa9a4295c..0663e4d9a 100644 --- a/test/e2e/run_exit_test.go +++ b/test/e2e/run_exit_test.go @@ -25,7 +25,6 @@ var _ = Describe("Podman run exit", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_memory_test.go b/test/e2e/run_memory_test.go index d6a67da57..083020f08 100644 --- a/test/e2e/run_memory_test.go +++ b/test/e2e/run_memory_test.go @@ -26,7 +26,6 @@ var _ = Describe("Podman run memory", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 49c387227..39c26ec4a 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -32,7 +32,6 @@ var _ = Describe("Podman run networking", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -99,7 +98,7 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Not(Equal("80"))) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostIP", "")) }) It("podman run -p 80-82 -p 8090:8090", func() { @@ -111,16 +110,16 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(4)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Not(Equal("80"))) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostIP", "")) Expect(inspectOut[0].NetworkSettings.Ports["81/tcp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["81/tcp"][0].HostPort).To(Not(Equal("81"))) - Expect(inspectOut[0].NetworkSettings.Ports["81/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["81/tcp"][0]).To(HaveField("HostIP", "")) Expect(inspectOut[0].NetworkSettings.Ports["82/tcp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["82/tcp"][0].HostPort).To(Not(Equal("82"))) - Expect(inspectOut[0].NetworkSettings.Ports["82/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["82/tcp"][0]).To(HaveField("HostIP", "")) Expect(inspectOut[0].NetworkSettings.Ports["8090/tcp"]).To(HaveLen(1)) - Expect(inspectOut[0].NetworkSettings.Ports["8090/tcp"][0].HostPort).To(Equal("8090")) - Expect(inspectOut[0].NetworkSettings.Ports["8090/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["8090/tcp"][0]).To(HaveField("HostPort", "8090")) + Expect(inspectOut[0].NetworkSettings.Ports["8090/tcp"][0]).To(HaveField("HostIP", "")) }) It("podman run -p 80-81 -p 8180-8181", func() { @@ -132,16 +131,16 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(4)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Not(Equal("80"))) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostIP", "")) Expect(inspectOut[0].NetworkSettings.Ports["81/tcp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["81/tcp"][0].HostPort).To(Not(Equal("81"))) - Expect(inspectOut[0].NetworkSettings.Ports["81/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["81/tcp"][0]).To(HaveField("HostIP", "")) Expect(inspectOut[0].NetworkSettings.Ports["8180/tcp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["8180/tcp"][0].HostPort).To(Not(Equal("8180"))) - Expect(inspectOut[0].NetworkSettings.Ports["8180/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["8180/tcp"][0]).To(HaveField("HostIP", "")) Expect(inspectOut[0].NetworkSettings.Ports["8181/tcp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["8181/tcp"][0].HostPort).To(Not(Equal("8181"))) - Expect(inspectOut[0].NetworkSettings.Ports["8181/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["8181/tcp"][0]).To(HaveField("HostIP", "")) }) It("podman run -p 80 -p 8280-8282:8280-8282", func() { @@ -153,16 +152,16 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(4)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Not(Equal("80"))) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostIP", "")) Expect(inspectOut[0].NetworkSettings.Ports["8280/tcp"]).To(HaveLen(1)) - Expect(inspectOut[0].NetworkSettings.Ports["8280/tcp"][0].HostPort).To(Equal("8280")) - Expect(inspectOut[0].NetworkSettings.Ports["8280/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["8280/tcp"][0]).To(HaveField("HostPort", "8280")) + Expect(inspectOut[0].NetworkSettings.Ports["8280/tcp"][0]).To(HaveField("HostIP", "")) Expect(inspectOut[0].NetworkSettings.Ports["8281/tcp"]).To(HaveLen(1)) - Expect(inspectOut[0].NetworkSettings.Ports["8281/tcp"][0].HostPort).To(Equal("8281")) - Expect(inspectOut[0].NetworkSettings.Ports["8281/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["8281/tcp"][0]).To(HaveField("HostPort", "8281")) + Expect(inspectOut[0].NetworkSettings.Ports["8281/tcp"][0]).To(HaveField("HostIP", "")) Expect(inspectOut[0].NetworkSettings.Ports["8282/tcp"]).To(HaveLen(1)) - Expect(inspectOut[0].NetworkSettings.Ports["8282/tcp"][0].HostPort).To(Equal("8282")) - Expect(inspectOut[0].NetworkSettings.Ports["8282/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["8282/tcp"][0]).To(HaveField("HostPort", "8282")) + Expect(inspectOut[0].NetworkSettings.Ports["8282/tcp"][0]).To(HaveField("HostIP", "")) }) It("podman run -p 8380:80", func() { @@ -173,8 +172,8 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"]).To(HaveLen(1)) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("8380")) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostPort", "8380")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostIP", "")) }) It("podman run -p 8480:80/TCP", func() { @@ -187,8 +186,8 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) // "tcp" in lower characters Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"]).To(HaveLen(1)) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("8480")) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostPort", "8480")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostIP", "")) }) It("podman run -p 80/udp", func() { @@ -200,7 +199,7 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/udp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostPort).To(Not(Equal("80"))) - Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0]).To(HaveField("HostIP", "")) }) It("podman run -p 127.0.0.1:8580:80", func() { @@ -211,8 +210,8 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"]).To(HaveLen(1)) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("8580")) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("127.0.0.1")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostPort", "8580")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostIP", "127.0.0.1")) }) It("podman run -p 127.0.0.1:8680:80/udp", func() { @@ -223,8 +222,8 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/udp"]).To(HaveLen(1)) - Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostPort).To(Equal("8680")) - Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostIP).To(Equal("127.0.0.1")) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0]).To(HaveField("HostPort", "8680")) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0]).To(HaveField("HostIP", "127.0.0.1")) }) It("podman run -p [::1]:8780:80/udp", func() { @@ -235,8 +234,8 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/udp"]).To(HaveLen(1)) - Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostPort).To(Equal("8780")) - Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostIP).To(Equal("::1")) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0]).To(HaveField("HostPort", "8780")) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0]).To(HaveField("HostIP", "::1")) }) It("podman run -p [::1]:8880:80/tcp", func() { @@ -247,8 +246,8 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"]).To(HaveLen(1)) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("8880")) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("::1")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostPort", "8880")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostIP", "::1")) }) It("podman run --expose 80 -P", func() { @@ -260,7 +259,7 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Not(Equal("0"))) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostIP", "")) }) It("podman run --expose 80/udp -P", func() { @@ -272,7 +271,7 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/udp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostPort).To(Not(Equal("0"))) - Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0]).To(HaveField("HostIP", "")) }) It("podman run --expose 80 -p 80", func() { @@ -284,7 +283,7 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Not(Equal("80"))) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostIP", "")) }) It("podman run --publish-all with EXPOSE port ranges in Dockerfile", func() { @@ -332,7 +331,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["8980/udp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["8980/udp"][0].HostPort).To(Not(Equal("8980"))) - Expect(inspectOut[0].NetworkSettings.Ports["8980/udp"][0].HostIP).To(Equal("127.0.0.1")) + Expect(inspectOut[0].NetworkSettings.Ports["8980/udp"][0]).To(HaveField("HostIP", "127.0.0.1")) }) It("podman run -p :8181", func() { @@ -344,7 +343,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["8181/tcp"]).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["8181/tcp"][0].HostPort).To(Not(Equal("8181"))) - Expect(inspectOut[0].NetworkSettings.Ports["8181/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["8181/tcp"][0]).To(HaveField("HostIP", "")) }) It("podman run -p xxx:8080 -p yyy:8080", func() { @@ -371,8 +370,8 @@ EXPOSE 2004-2005/tcp`, ALPINE) Expect(inspectOut).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"]).To(HaveLen(1)) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("9280")) - Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostPort", "9280")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0]).To(HaveField("HostIP", "")) }) It("podman run network expose host port 80 to container port", func() { @@ -747,11 +746,12 @@ EXPOSE 2004-2005/tcp`, ALPINE) routeAdd := func(gateway string) { gw := net.ParseIP(gateway) route := &netlink.Route{Dst: nil, Gw: gw} - netlink.RouteAdd(route) + err = netlink.RouteAdd(route) + Expect(err).ToNot(HaveOccurred()) } setupNetworkNs := func(networkNSName string) { - ns.WithNetNSPath("/run/netns/"+networkNSName, func(_ ns.NetNS) error { + _ = ns.WithNetNSPath("/run/netns/"+networkNSName, func(_ ns.NetNS) error { loopbackup() linkup("eth0", "46:7f:45:6e:4f:c8", []string{"10.25.40.0/24", "fd04:3e42:4a4e:3381::/64"}) linkup("eth1", "56:6e:35:5d:3e:a8", []string{"10.88.0.0/16"}) @@ -763,18 +763,18 @@ EXPOSE 2004-2005/tcp`, ALPINE) checkNetworkNsInspect := func(name string) { inspectOut := podmanTest.InspectContainer(name) - Expect(inspectOut[0].NetworkSettings.IPAddress).To(Equal("10.25.40.0")) - Expect(inspectOut[0].NetworkSettings.IPPrefixLen).To(Equal(24)) + Expect(inspectOut[0].NetworkSettings).To(HaveField("IPAddress", "10.25.40.0")) + Expect(inspectOut[0].NetworkSettings).To(HaveField("IPPrefixLen", 24)) Expect(len(inspectOut[0].NetworkSettings.SecondaryIPAddresses)).To(Equal(1)) - Expect(inspectOut[0].NetworkSettings.SecondaryIPAddresses[0].Addr).To(Equal("10.88.0.0")) - Expect(inspectOut[0].NetworkSettings.SecondaryIPAddresses[0].PrefixLength).To(Equal(16)) - Expect(inspectOut[0].NetworkSettings.GlobalIPv6Address).To(Equal("fd04:3e42:4a4e:3381::")) - Expect(inspectOut[0].NetworkSettings.GlobalIPv6PrefixLen).To(Equal(64)) + Expect(inspectOut[0].NetworkSettings.SecondaryIPAddresses[0]).To(HaveField("Addr", "10.88.0.0")) + Expect(inspectOut[0].NetworkSettings.SecondaryIPAddresses[0]).To(HaveField("PrefixLength", 16)) + Expect(inspectOut[0].NetworkSettings).To(HaveField("GlobalIPv6Address", "fd04:3e42:4a4e:3381::")) + Expect(inspectOut[0].NetworkSettings).To(HaveField("GlobalIPv6PrefixLen", 64)) Expect(len(inspectOut[0].NetworkSettings.SecondaryIPv6Addresses)).To(Equal(0)) - Expect(inspectOut[0].NetworkSettings.MacAddress).To(Equal("46:7f:45:6e:4f:c8")) + Expect(inspectOut[0].NetworkSettings).To(HaveField("MacAddress", "46:7f:45:6e:4f:c8")) Expect(len(inspectOut[0].NetworkSettings.AdditionalMacAddresses)).To(Equal(1)) Expect(inspectOut[0].NetworkSettings.AdditionalMacAddresses[0]).To(Equal("56:6e:35:5d:3e:a8")) - Expect(inspectOut[0].NetworkSettings.Gateway).To(Equal("10.25.40.0")) + Expect(inspectOut[0].NetworkSettings).To(HaveField("Gateway", "10.25.40.0")) } @@ -796,7 +796,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) Expect(delNetworkNamespace).Should(Exit(0)) inspectOut := podmanTest.InspectContainer(name) - Expect(inspectOut[0].NetworkSettings.IPAddress).To(Equal("")) + Expect(inspectOut[0].NetworkSettings).To(HaveField("IPAddress", "")) Expect(len(inspectOut[0].NetworkSettings.Networks)).To(Equal(0)) }) diff --git a/test/e2e/run_ns_test.go b/test/e2e/run_ns_test.go index 23fd298d7..f99d6cf3f 100644 --- a/test/e2e/run_ns_test.go +++ b/test/e2e/run_ns_test.go @@ -25,7 +25,6 @@ var _ = Describe("Podman run ns", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_passwd_test.go b/test/e2e/run_passwd_test.go index ce6c6ffda..411e12218 100644 --- a/test/e2e/run_passwd_test.go +++ b/test/e2e/run_passwd_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman run passwd", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_privileged_test.go b/test/e2e/run_privileged_test.go index 59223c589..4f0b512c6 100644 --- a/test/e2e/run_privileged_test.go +++ b/test/e2e/run_privileged_test.go @@ -49,7 +49,6 @@ var _ = Describe("Podman privileged container tests", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_restart_test.go b/test/e2e/run_restart_test.go index ec8fbfe98..b1002ece4 100644 --- a/test/e2e/run_restart_test.go +++ b/test/e2e/run_restart_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman run restart containers", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_seccomp_test.go b/test/e2e/run_seccomp_test.go index 03212b6dc..bd44a3ef1 100644 --- a/test/e2e/run_seccomp_test.go +++ b/test/e2e/run_seccomp_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman run", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_security_labels_test.go b/test/e2e/run_security_labels_test.go index 8aebeaebb..915566a2c 100644 --- a/test/e2e/run_security_labels_test.go +++ b/test/e2e/run_security_labels_test.go @@ -25,8 +25,6 @@ var _ = Describe("Podman generate kube", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() - }) AfterEach(func() { diff --git a/test/e2e/run_selinux_test.go b/test/e2e/run_selinux_test.go index b71c68baf..4a433f308 100644 --- a/test/e2e/run_selinux_test.go +++ b/test/e2e/run_selinux_test.go @@ -25,7 +25,6 @@ var _ = Describe("Podman run", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() if !selinux.GetEnabled() { Skip("SELinux not enabled") } diff --git a/test/e2e/run_signal_test.go b/test/e2e/run_signal_test.go index d40a5a1b4..e5d9b6c7b 100644 --- a/test/e2e/run_signal_test.go +++ b/test/e2e/run_signal_test.go @@ -34,7 +34,6 @@ var _ = Describe("Podman run with --sig-proxy", func() { } podmanTest = PodmanTestCreate(tmpdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -51,11 +50,14 @@ var _ = Describe("Podman run with --sig-proxy", func() { signal := syscall.SIGFPE // Set up a socket for communication udsDir := filepath.Join(tmpdir, "socket") - os.Mkdir(udsDir, 0700) + err := os.Mkdir(udsDir, 0700) + Expect(err).ToNot(HaveOccurred()) udsPath := filepath.Join(udsDir, "fifo") - syscall.Mkfifo(udsPath, 0600) + err = syscall.Mkfifo(udsPath, 0600) + Expect(err).ToNot(HaveOccurred()) if rootless.IsRootless() { - podmanTest.RestoreArtifact(fedoraMinimal) + err = podmanTest.RestoreArtifact(fedoraMinimal) + Expect(err).ToNot(HaveOccurred()) } _, pid := podmanTest.PodmanPID([]string{"run", "-it", "-v", fmt.Sprintf("%s:/h:Z", udsDir), fedoraMinimal, "bash", "-c", sigCatch}) @@ -112,7 +114,8 @@ var _ = Describe("Podman run with --sig-proxy", func() { Specify("signals are not forwarded to container with sig-proxy false", func() { signal := syscall.SIGFPE if rootless.IsRootless() { - podmanTest.RestoreArtifact(fedoraMinimal) + err = podmanTest.RestoreArtifact(fedoraMinimal) + Expect(err).ToNot(HaveOccurred()) } session, pid := podmanTest.PodmanPID([]string{"run", "--name", "test2", "--sig-proxy=false", fedoraMinimal, "bash", "-c", sigCatch2}) diff --git a/test/e2e/run_staticip_test.go b/test/e2e/run_staticip_test.go index 7e61e7c5e..af3f98d4b 100644 --- a/test/e2e/run_staticip_test.go +++ b/test/e2e/run_staticip_test.go @@ -28,7 +28,6 @@ var _ = Describe("Podman run with --ip flag", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() // Cleanup the CNI networks used by the tests os.RemoveAll("/var/lib/cni/networks/podman") }) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 4c399dc2b..182ae1888 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -16,7 +16,6 @@ import ( "github.com/containers/podman/v4/pkg/rootless" . "github.com/containers/podman/v4/test/utils" "github.com/containers/storage/pkg/stringid" - "github.com/mrunalp/fileutils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" @@ -36,7 +35,6 @@ var _ = Describe("Podman run", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -288,7 +286,7 @@ var _ = Describe("Podman run", func() { result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) conData := result.InspectContainerToJSON() - Expect(conData[0].Path).To(Equal("/dev/init")) + Expect(conData[0]).To(HaveField("Path", "/dev/init")) Expect(conData[0].Config.Annotations).To(HaveKeyWithValue("io.podman.annotations.init", "TRUE")) }) @@ -300,7 +298,7 @@ var _ = Describe("Podman run", func() { result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) conData := result.InspectContainerToJSON() - Expect(conData[0].Path).To(Equal("/dev/init")) + Expect(conData[0]).To(HaveField("Path", "/dev/init")) Expect(conData[0].Config.Annotations).To(HaveKeyWithValue("io.podman.annotations.init", "TRUE")) }) @@ -312,7 +310,7 @@ var _ = Describe("Podman run", func() { result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) conData := result.InspectContainerToJSON() - Expect(conData[0].Path).To(Equal("ls")) + Expect(conData[0]).To(HaveField("Path", "ls")) Expect(conData[0].Config.Annotations).To(HaveKeyWithValue("io.podman.annotations.init", "FALSE")) }) @@ -812,16 +810,38 @@ USER bin`, BB) }) It("podman test hooks", func() { - hcheck := "/run/hookscheck" + SkipIfRemote("--hooks-dir does not work with remote") hooksDir := tempdir + "/hooks" - os.Mkdir(hooksDir, 0755) - fileutils.CopyFile("hooks/hooks.json", hooksDir) - os.Setenv("HOOK_OPTION", fmt.Sprintf("--hooks-dir=%s", hooksDir)) - os.Remove(hcheck) - session := podmanTest.Podman([]string{"run", ALPINE, "ls"}) + err := os.Mkdir(hooksDir, 0755) + Expect(err).ToNot(HaveOccurred()) + hookJSONPath := filepath.Join(hooksDir, "checkhooks.json") + hookScriptPath := filepath.Join(hooksDir, "checkhooks.sh") + targetFile := filepath.Join(hooksDir, "target") + + hookJSON := fmt.Sprintf(`{ + "cmd" : [".*"], + "hook" : "%s", + "stage" : [ "prestart" ] +} +`, hookScriptPath) + err = ioutil.WriteFile(hookJSONPath, []byte(hookJSON), 0644) + Expect(err).ToNot(HaveOccurred()) + + random := stringid.GenerateNonCryptoID() + + hookScript := fmt.Sprintf(`#!/bin/sh +echo -n %s >%s +`, random, targetFile) + err = ioutil.WriteFile(hookScriptPath, []byte(hookScript), 0755) + Expect(err).ToNot(HaveOccurred()) + + session := podmanTest.Podman([]string{"--hooks-dir", hooksDir, "run", ALPINE, "ls"}) session.Wait(10) - os.Unsetenv("HOOK_OPTION") Expect(session).Should(Exit(0)) + + b, err := ioutil.ReadFile(targetFile) + Expect(err).ToNot(HaveOccurred()) + Expect(string(b)).To(Equal(random)) }) It("podman run with subscription secrets", func() { diff --git a/test/e2e/run_userns_test.go b/test/e2e/run_userns_test.go index 092621c27..613727118 100644 --- a/test/e2e/run_userns_test.go +++ b/test/e2e/run_userns_test.go @@ -33,7 +33,6 @@ var _ = Describe("Podman UserNS support", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index a31c1959e..3bef889b7 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -34,7 +34,6 @@ var _ = Describe("Podman run with volumes", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -55,7 +54,8 @@ var _ = Describe("Podman run with volumes", func() { It("podman run with volume flag", func() { mountPath := filepath.Join(podmanTest.TempDir, "secrets") - os.Mkdir(mountPath, 0755) + err = os.Mkdir(mountPath, 0755) + Expect(err).ToNot(HaveOccurred()) vol := mountPath + ":" + dest // [5] is flags @@ -82,7 +82,8 @@ var _ = Describe("Podman run with volumes", func() { Skip("skip failing test on ppc64le") } mountPath := filepath.Join(podmanTest.TempDir, "secrets") - os.Mkdir(mountPath, 0755) + err = os.Mkdir(mountPath, 0755) + Expect(err).ToNot(HaveOccurred()) mount := "type=bind,src=" + mountPath + ",target=" + dest session := podmanTest.Podman([]string{"run", "--rm", "--mount", mount, ALPINE, "grep", dest, "/proc/self/mountinfo"}) @@ -141,14 +142,16 @@ var _ = Describe("Podman run with volumes", func() { It("podman run with conflicting volumes errors", func() { mountPath := filepath.Join(podmanTest.TmpDir, "secrets") - os.Mkdir(mountPath, 0755) + err := os.Mkdir(mountPath, 0755) + Expect(err).ToNot(HaveOccurred()) session := podmanTest.Podman([]string{"run", "-v", mountPath + ":" + dest, "-v", "/tmp" + ":" + dest, ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(125)) }) It("podman run with conflict between image volume and user mount succeeds", func() { - podmanTest.RestoreArtifact(redis) + err = podmanTest.RestoreArtifact(redis) + Expect(err).ToNot(HaveOccurred()) mountPath := filepath.Join(podmanTest.TempDir, "secrets") err := os.Mkdir(mountPath, 0755) Expect(err).To(BeNil()) @@ -164,7 +167,8 @@ var _ = Describe("Podman run with volumes", func() { It("podman run with mount flag and boolean options", func() { mountPath := filepath.Join(podmanTest.TempDir, "secrets") - os.Mkdir(mountPath, 0755) + err := os.Mkdir(mountPath, 0755) + Expect(err).ToNot(HaveOccurred()) mount := "type=bind,src=" + mountPath + ",target=" + dest session := podmanTest.Podman([]string{"run", "--rm", "--mount", mount + ",ro=false", ALPINE, "grep", dest, "/proc/self/mountinfo"}) @@ -193,7 +197,8 @@ var _ = Describe("Podman run with volumes", func() { It("podman run with volumes and suid/dev/exec options", func() { SkipIfRemote("podman-remote does not support --volumes") mountPath := filepath.Join(podmanTest.TempDir, "secrets") - os.Mkdir(mountPath, 0755) + err := os.Mkdir(mountPath, 0755) + Expect(err).ToNot(HaveOccurred()) session := podmanTest.Podman([]string{"run", "--rm", "-v", mountPath + ":" + dest + ":suid,dev,exec", ALPINE, "grep", dest, "/proc/self/mountinfo"}) session.WaitWithDefaultTimeout() @@ -224,7 +229,8 @@ var _ = Describe("Podman run with volumes", func() { } } mountPath := filepath.Join(podmanTest.TempDir, "secrets") - os.Mkdir(mountPath, 0755) + err := os.Mkdir(mountPath, 0755) + Expect(err).ToNot(HaveOccurred()) // Container should be able to start with custom overlay volume session := podmanTest.Podman([]string{"run", "--rm", "-v", mountPath + ":/data:O", "--workdir=/data", ALPINE, "echo", "hello"}) @@ -588,8 +594,8 @@ VOLUME /test/`, ALPINE) data := podmanTest.InspectContainer(ctrName) Expect(data).To(HaveLen(1)) Expect(data[0].Mounts).To(HaveLen(1)) - Expect(data[0].Mounts[0].Source).To(Equal("/tmp")) - Expect(data[0].Mounts[0].Destination).To(Equal("/test")) + Expect(data[0].Mounts[0]).To(HaveField("Source", "/tmp")) + Expect(data[0].Mounts[0]).To(HaveField("Destination", "/test")) }) It("podman run with overlay volume flag", func() { @@ -603,7 +609,8 @@ VOLUME /test/`, ALPINE) } } mountPath := filepath.Join(podmanTest.TempDir, "secrets") - os.Mkdir(mountPath, 0755) + err := os.Mkdir(mountPath, 0755) + Expect(err).ToNot(HaveOccurred()) testFile := filepath.Join(mountPath, "test1") f, err := os.Create(testFile) Expect(err).To(BeNil(), "os.Create "+testFile) @@ -651,7 +658,8 @@ VOLUME /test/`, ALPINE) It("overlay volume conflicts with named volume and mounts", func() { mountPath := filepath.Join(podmanTest.TempDir, "secrets") - os.Mkdir(mountPath, 0755) + err := os.Mkdir(mountPath, 0755) + Expect(err).ToNot(HaveOccurred()) testFile := filepath.Join(mountPath, "test1") f, err := os.Create(testFile) Expect(err).To(BeNil()) @@ -716,7 +724,8 @@ VOLUME /test/`, ALPINE) } mountPath := filepath.Join(podmanTest.TempDir, "secrets") - os.Mkdir(mountPath, 0755) + err = os.Mkdir(mountPath, 0755) + Expect(err).ToNot(HaveOccurred()) vol := mountPath + ":" + dest + ":U" session := podmanTest.Podman([]string{"run", "--rm", "--user", "888:888", "-v", vol, ALPINE, "stat", "-c", "%u:%g", dest}) @@ -754,7 +763,8 @@ VOLUME /test/`, ALPINE) } mountPath := filepath.Join(podmanTest.TempDir, "foo") - os.Mkdir(mountPath, 0755) + err = os.Mkdir(mountPath, 0755) + Expect(err).ToNot(HaveOccurred()) // false bind mount vol := "type=bind,src=" + mountPath + ",dst=" + dest + ",U=false" diff --git a/test/e2e/run_working_dir_test.go b/test/e2e/run_working_dir_test.go index 50d0a2194..ff91a420f 100644 --- a/test/e2e/run_working_dir_test.go +++ b/test/e2e/run_working_dir_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman run", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/runlabel_test.go b/test/e2e/runlabel_test.go index d1e11dd9a..018ed37c2 100644 --- a/test/e2e/runlabel_test.go +++ b/test/e2e/runlabel_test.go @@ -37,7 +37,6 @@ var _ = Describe("podman container runlabel", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index 39295608e..536eefda7 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -170,7 +170,8 @@ var _ = Describe("Podman save", func() { } defer func() { cmd = exec.Command("cp", "default.yaml", "/etc/containers/registries.d/default.yaml") - cmd.Run() + err := cmd.Run() + Expect(err).ToNot(HaveOccurred()) }() cmd = exec.Command("cp", "sign/key.gpg", "/tmp/key.gpg") diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index 07198d799..8237f6433 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -64,8 +64,6 @@ registries = ['{{.Host}}:{{.Port}}']` podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() - }) AfterEach(func() { @@ -242,7 +240,8 @@ registries = ['{{.Host}}:{{.Port}}']` Fail("Cannot start docker registry on port %s", port) } ep := endpoint{Port: fmt.Sprintf("%d", port), Host: "localhost"} - podmanTest.RestoreArtifact(ALPINE) + err = podmanTest.RestoreArtifact(ALPINE) + Expect(err).ToNot(HaveOccurred()) image := fmt.Sprintf("%s/my-alpine", ep.Address()) push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) push.WaitWithDefaultTimeout() @@ -277,7 +276,8 @@ registries = ['{{.Host}}:{{.Port}}']` Fail("unable to start registry on port %s", port) } - podmanTest.RestoreArtifact(ALPINE) + err = podmanTest.RestoreArtifact(ALPINE) + Expect(err).ToNot(HaveOccurred()) image := fmt.Sprintf("%s/my-alpine", ep.Address()) push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) push.WaitWithDefaultTimeout() @@ -285,9 +285,11 @@ registries = ['{{.Host}}:{{.Port}}']` // registries.conf set up var buffer bytes.Buffer - registryFileTmpl.Execute(&buffer, ep) + err = registryFileTmpl.Execute(&buffer, ep) + Expect(err).ToNot(HaveOccurred()) podmanTest.setRegistriesConfigEnv(buffer.Bytes()) - ioutil.WriteFile(fmt.Sprintf("%s/registry4.conf", tempdir), buffer.Bytes(), 0644) + err = ioutil.WriteFile(fmt.Sprintf("%s/registry4.conf", tempdir), buffer.Bytes(), 0644) + Expect(err).ToNot(HaveOccurred()) if IsRemote() { podmanTest.RestartRemoteService() defer podmanTest.RestartRemoteService() @@ -319,16 +321,19 @@ registries = ['{{.Host}}:{{.Port}}']` Fail("Cannot start docker registry on port %s", port) } - podmanTest.RestoreArtifact(ALPINE) + err = podmanTest.RestoreArtifact(ALPINE) + Expect(err).ToNot(HaveOccurred()) image := fmt.Sprintf("%s/my-alpine", ep.Address()) push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) push.WaitWithDefaultTimeout() Expect(push).Should(Exit(0)) var buffer bytes.Buffer - registryFileTmpl.Execute(&buffer, ep) + err = registryFileTmpl.Execute(&buffer, ep) + Expect(err).ToNot(HaveOccurred()) podmanTest.setRegistriesConfigEnv(buffer.Bytes()) - ioutil.WriteFile(fmt.Sprintf("%s/registry5.conf", tempdir), buffer.Bytes(), 0644) + err = ioutil.WriteFile(fmt.Sprintf("%s/registry5.conf", tempdir), buffer.Bytes(), 0644) + Expect(err).ToNot(HaveOccurred()) search := podmanTest.Podman([]string{"search", image, "--tls-verify=true"}) search.WaitWithDefaultTimeout() @@ -356,16 +361,19 @@ registries = ['{{.Host}}:{{.Port}}']` Fail("Cannot start docker registry on port %s", port) } - podmanTest.RestoreArtifact(ALPINE) + err = podmanTest.RestoreArtifact(ALPINE) + Expect(err).ToNot(HaveOccurred()) image := fmt.Sprintf("%s/my-alpine", ep.Address()) push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) push.WaitWithDefaultTimeout() Expect(push).Should(Exit(0)) var buffer bytes.Buffer - registryFileBadTmpl.Execute(&buffer, ep) + err = registryFileBadTmpl.Execute(&buffer, ep) + Expect(err).ToNot(HaveOccurred()) podmanTest.setRegistriesConfigEnv(buffer.Bytes()) - ioutil.WriteFile(fmt.Sprintf("%s/registry6.conf", tempdir), buffer.Bytes(), 0644) + err = ioutil.WriteFile(fmt.Sprintf("%s/registry6.conf", tempdir), buffer.Bytes(), 0644) + Expect(err).ToNot(HaveOccurred()) if IsRemote() { podmanTest.RestartRemoteService() @@ -409,16 +417,19 @@ registries = ['{{.Host}}:{{.Port}}']` Fail("Cannot start docker registry on port %s", port2) } - podmanTest.RestoreArtifact(ALPINE) + err = podmanTest.RestoreArtifact(ALPINE) + Expect(err).ToNot(HaveOccurred()) push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, fmt.Sprintf("localhost:%d/my-alpine", port2)}) push.WaitWithDefaultTimeout() Expect(push).Should(Exit(0)) // registries.conf set up var buffer bytes.Buffer - registryFileTwoTmpl.Execute(&buffer, ep3) + err = registryFileTwoTmpl.Execute(&buffer, ep3) + Expect(err).ToNot(HaveOccurred()) podmanTest.setRegistriesConfigEnv(buffer.Bytes()) - ioutil.WriteFile(fmt.Sprintf("%s/registry8.conf", tempdir), buffer.Bytes(), 0644) + err = ioutil.WriteFile(fmt.Sprintf("%s/registry8.conf", tempdir), buffer.Bytes(), 0644) + Expect(err).ToNot(HaveOccurred()) if IsRemote() { podmanTest.RestartRemoteService() diff --git a/test/e2e/secret_test.go b/test/e2e/secret_test.go index 90d760c81..ed328d84a 100644 --- a/test/e2e/secret_test.go +++ b/test/e2e/secret_test.go @@ -26,7 +26,6 @@ var _ = Describe("Podman secret", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/start_test.go b/test/e2e/start_test.go index 98943c6fc..73af9d12c 100644 --- a/test/e2e/start_test.go +++ b/test/e2e/start_test.go @@ -26,7 +26,6 @@ var _ = Describe("Podman start", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/stats_test.go b/test/e2e/stats_test.go index 7435a0e3b..b43a81cd3 100644 --- a/test/e2e/stats_test.go +++ b/test/e2e/stats_test.go @@ -32,7 +32,6 @@ var _ = Describe("Podman stats", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/stop_test.go b/test/e2e/stop_test.go index 99d7f278c..8864ba5fd 100644 --- a/test/e2e/stop_test.go +++ b/test/e2e/stop_test.go @@ -25,7 +25,6 @@ var _ = Describe("Podman stop", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/system_connection_test.go b/test/e2e/system_connection_test.go index ac4c5e5ea..95920136e 100644 --- a/test/e2e/system_connection_test.go +++ b/test/e2e/system_connection_test.go @@ -47,7 +47,7 @@ var _ = Describe("podman system connection", func() { } f := CurrentGinkgoTestDescription() - GinkgoWriter.Write( + _, _ = GinkgoWriter.Write( []byte( fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds()))) }) diff --git a/test/e2e/system_df_test.go b/test/e2e/system_df_test.go index a9fa5f4ac..ba4a40ab4 100644 --- a/test/e2e/system_df_test.go +++ b/test/e2e/system_df_test.go @@ -26,14 +26,13 @@ var _ = Describe("podman system df", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { podmanTest.Cleanup() f := CurrentGinkgoTestDescription() timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds()) - GinkgoWriter.Write([]byte(timedResult)) + _, _ = GinkgoWriter.Write([]byte(timedResult)) }) It("podman system df", func() { diff --git a/test/e2e/system_dial_stdio_test.go b/test/e2e/system_dial_stdio_test.go index 5fcb20cb8..4e4c99bfe 100644 --- a/test/e2e/system_dial_stdio_test.go +++ b/test/e2e/system_dial_stdio_test.go @@ -24,14 +24,13 @@ var _ = Describe("podman system dial-stdio", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { podmanTest.Cleanup() f := CurrentGinkgoTestDescription() timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds()) - GinkgoWriter.Write([]byte(timedResult)) + _, _ = GinkgoWriter.Write([]byte(timedResult)) }) It("podman system dial-stdio help", func() { diff --git a/test/e2e/system_reset_test.go b/test/e2e/system_reset_test.go index f413ce147..ec94bb819 100644 --- a/test/e2e/system_reset_test.go +++ b/test/e2e/system_reset_test.go @@ -24,14 +24,13 @@ var _ = Describe("podman system reset", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { podmanTest.Cleanup() f := CurrentGinkgoTestDescription() timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds()) - GinkgoWriter.Write([]byte(timedResult)) + _, _ = GinkgoWriter.Write([]byte(timedResult)) }) It("podman system reset", func() { diff --git a/test/e2e/systemd_activate_test.go b/test/e2e/systemd_activate_test.go index 04acafe1b..aeea4f932 100644 --- a/test/e2e/systemd_activate_test.go +++ b/test/e2e/systemd_activate_test.go @@ -31,7 +31,6 @@ var _ = Describe("Systemd activate", func() { podmanTest = PodmanTestCreate(tempDir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go index 57fc323ce..a1a080904 100644 --- a/test/e2e/systemd_test.go +++ b/test/e2e/systemd_test.go @@ -28,7 +28,6 @@ var _ = Describe("Podman systemd", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() systemdUnitFile = `[Unit] Description=redis container [Service] diff --git a/test/e2e/toolbox_test.go b/test/e2e/toolbox_test.go index 1fc28a06d..1e9a6da1f 100644 --- a/test/e2e/toolbox_test.go +++ b/test/e2e/toolbox_test.go @@ -56,7 +56,6 @@ var _ = Describe("Toolbox-specific testing", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/top_test.go b/test/e2e/top_test.go index 344568da5..66bb887dc 100644 --- a/test/e2e/top_test.go +++ b/test/e2e/top_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman top", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/tree_test.go b/test/e2e/tree_test.go index ab6e49e88..e1282d2b4 100644 --- a/test/e2e/tree_test.go +++ b/test/e2e/tree_test.go @@ -31,7 +31,7 @@ var _ = Describe("Podman image tree", func() { podmanTest.Cleanup() f := CurrentGinkgoTestDescription() timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds()) - GinkgoWriter.Write([]byte(timedResult)) + _, _ = GinkgoWriter.Write([]byte(timedResult)) }) It("podman image tree", func() { diff --git a/test/e2e/trust_test.go b/test/e2e/trust_test.go index d17e34e9c..eee802e43 100644 --- a/test/e2e/trust_test.go +++ b/test/e2e/trust_test.go @@ -28,7 +28,6 @@ var _ = Describe("Podman trust", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { @@ -75,7 +74,8 @@ var _ = Describe("Podman trust", func() { Expect(session).Should(Exit(0)) Expect(session.OutputToString()).To(BeValidJSON()) var teststruct []map[string]string - json.Unmarshal(session.Out.Contents(), &teststruct) + err = json.Unmarshal(session.Out.Contents(), &teststruct) + Expect(err).ToNot(HaveOccurred()) Expect(teststruct).To(HaveLen(3)) // To ease comparison, group the unordered array of repos by repo (and we expect only one entry by repo, so order within groups doesn’t matter) repoMap := map[string][]map[string]string{} diff --git a/test/e2e/unshare_test.go b/test/e2e/unshare_test.go index 8b06dd4f5..520a2f884 100644 --- a/test/e2e/unshare_test.go +++ b/test/e2e/unshare_test.go @@ -32,7 +32,6 @@ var _ = Describe("Podman unshare", func() { podmanTest.CgroupManager = "cgroupfs" podmanTest.StorageOptions = ROOTLESS_STORAGE_OPTIONS podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/version_test.go b/test/e2e/version_test.go index a30db80eb..052b9aa39 100644 --- a/test/e2e/version_test.go +++ b/test/e2e/version_test.go @@ -30,7 +30,7 @@ var _ = Describe("Podman version", func() { podmanTest.Cleanup() f := CurrentGinkgoTestDescription() processTestResult(f) - podmanTest.SeedImages() + }) It("podman version", func() { diff --git a/test/e2e/volume_create_test.go b/test/e2e/volume_create_test.go index 0ac91abd3..09e5da8a0 100644 --- a/test/e2e/volume_create_test.go +++ b/test/e2e/volume_create_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman volume create", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/volume_exists_test.go b/test/e2e/volume_exists_test.go index fdadbda27..0de574968 100644 --- a/test/e2e/volume_exists_test.go +++ b/test/e2e/volume_exists_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman volume exists", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/volume_inspect_test.go b/test/e2e/volume_inspect_test.go index 5e3edfe24..344fe8b05 100644 --- a/test/e2e/volume_inspect_test.go +++ b/test/e2e/volume_inspect_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman volume inspect", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/volume_ls_test.go b/test/e2e/volume_ls_test.go index ce4cfc77d..19f87fb8a 100644 --- a/test/e2e/volume_ls_test.go +++ b/test/e2e/volume_ls_test.go @@ -24,7 +24,6 @@ var _ = Describe("Podman volume ls", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/volume_plugin_test.go b/test/e2e/volume_plugin_test.go index fd205805d..4700afdb5 100644 --- a/test/e2e/volume_plugin_test.go +++ b/test/e2e/volume_plugin_test.go @@ -25,11 +25,11 @@ var _ = Describe("Podman volume plugins", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() os.Setenv("CONTAINERS_CONF", "config/containers.conf") SkipIfRemote("Volume plugins only supported as local") SkipIfRootless("Root is required for volume plugin testing") - os.MkdirAll("/run/docker/plugins", 0755) + err = os.MkdirAll("/run/docker/plugins", 0755) + Expect(err).ToNot(HaveOccurred()) }) AfterEach(func() { @@ -55,7 +55,8 @@ var _ = Describe("Podman volume plugins", func() { podmanTest.AddImageToRWStore(volumeTest) pluginStatePath := filepath.Join(podmanTest.TempDir, "volumes") - os.Mkdir(pluginStatePath, 0755) + err := os.Mkdir(pluginStatePath, 0755) + Expect(err).ToNot(HaveOccurred()) // Keep this distinct within tests to avoid multiple tests using the same plugin. pluginName := "testvol1" @@ -89,7 +90,8 @@ var _ = Describe("Podman volume plugins", func() { podmanTest.AddImageToRWStore(volumeTest) pluginStatePath := filepath.Join(podmanTest.TempDir, "volumes") - os.Mkdir(pluginStatePath, 0755) + err := os.Mkdir(pluginStatePath, 0755) + Expect(err).ToNot(HaveOccurred()) // Keep this distinct within tests to avoid multiple tests using the same plugin. pluginName := "testvol2" @@ -112,7 +114,8 @@ var _ = Describe("Podman volume plugins", func() { podmanTest.AddImageToRWStore(volumeTest) pluginStatePath := filepath.Join(podmanTest.TempDir, "volumes") - os.Mkdir(pluginStatePath, 0755) + err := os.Mkdir(pluginStatePath, 0755) + Expect(err).ToNot(HaveOccurred()) // Keep this distinct within tests to avoid multiple tests using the same plugin. pluginName := "testvol3" @@ -153,7 +156,8 @@ var _ = Describe("Podman volume plugins", func() { podmanTest.AddImageToRWStore(volumeTest) pluginStatePath := filepath.Join(podmanTest.TempDir, "volumes") - os.Mkdir(pluginStatePath, 0755) + err := os.Mkdir(pluginStatePath, 0755) + Expect(err).ToNot(HaveOccurred()) // Keep this distinct within tests to avoid multiple tests using the same plugin. pluginName := "testvol4" diff --git a/test/e2e/volume_prune_test.go b/test/e2e/volume_prune_test.go index 0b4c30a48..600f1b887 100644 --- a/test/e2e/volume_prune_test.go +++ b/test/e2e/volume_prune_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman volume prune", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/volume_rm_test.go b/test/e2e/volume_rm_test.go index 2a2de0920..0180b7a46 100644 --- a/test/e2e/volume_rm_test.go +++ b/test/e2e/volume_rm_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman volume rm", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/wait_test.go b/test/e2e/wait_test.go index 098780c70..16e876af9 100644 --- a/test/e2e/wait_test.go +++ b/test/e2e/wait_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman wait", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/system/110-history.bats b/test/system/110-history.bats index 0f6d75cb3..da6f2177c 100644 --- a/test/system/110-history.bats +++ b/test/system/110-history.bats @@ -55,4 +55,17 @@ size | -\\\?[0-9]\\\+ } +@test "podman image history Created" { + # Values from image LIST + run_podman image list --format '{{.CreatedSince}}--{{.CreatedAt}}' $IMAGE + from_imagelist="$output" + assert "$from_imagelist" =~ "^[0-9].* ago--[0-9]+-[0-9]+-[0-9]+ [0-9:]+ " \ + "CreatedSince and CreatedAt look reasonable" + + # Values from image HISTORY + run_podman image history --format '{{.CreatedSince}}--{{.CreatedAt}}' $IMAGE + assert "${lines[0]}" == "$from_imagelist" \ + "CreatedSince and CreatedAt from image history should == image list" +} + # vim: filetype=sh diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats index ef4bf1a6c..64f95f723 100644 --- a/test/system/200-pod.bats +++ b/test/system/200-pod.bats @@ -381,4 +381,32 @@ EOF is "$output" ".*$container_3_ID.*" } +@test "podman pod create share net" { + run_podman pod create --name test + run_podman pod inspect test --format {{.InfraConfig.HostNetwork}} + is "$output" "false" "Default network sharing should be false" + run_podman pod rm test + + run_podman pod create --name test --share ipc --network private + run_podman pod inspect test --format {{.InfraConfig.HostNetwork}} + is "$output" "false" "Private network sharing with only ipc should be false" + run_podman pod rm test + + run_podman pod create --name test --share net --network private + run_podman pod inspect test --format {{.InfraConfig.HostNetwork}} + is "$output" "false" "Private network sharing with only net should be false" + run_podman pod rm test + + run_podman pod create --name test --share net --network host + run_podman pod inspect test --format {{.InfraConfig.HostNetwork}} + is "$output" "true" "Host network sharing with only net should be true" + run_podman pod rm test + + run_podman pod create --name test --share ipc --network host + run_podman pod inspect test --format {{.InfraConfig.HostNetwork}} + is "$output" "true" "Host network sharing with only ipc should be true" + run_podman pod rm test + +} + # vim: filetype=sh diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats index 01571d176..3db0804d1 100644 --- a/test/system/500-networking.bats +++ b/test/system/500-networking.bats @@ -656,6 +656,15 @@ EOF run_podman run --network $netname --rm $IMAGE cat /etc/resolv.conf is "$output" "search dns.podman.*" "correct search domain" is "$output" ".*nameserver $subnet.1.*" "integrated dns nameserver is set" + + # host network should keep localhost nameservers + if grep 127.0.0. /etc/resolv.conf >/dev/null; then + run_podman run --network host --rm $IMAGE cat /etc/resolv.conf + is "$output" ".*nameserver 127\.0\.0.*" "resolv.conf contains localhost nameserver" + fi + # host net + dns still works + run_podman run --network host --dns 1.1.1.1 --rm $IMAGE cat /etc/resolv.conf + is "$output" ".*nameserver 1\.1\.1\.1.*" "resolv.conf contains 1.1.1.1 nameserver" } @test "podman run port forward range" { @@ -723,4 +732,19 @@ EOF is "${#lines[@]}" "5" "expect 5 host entries in /etc/hosts" } +@test "podman run /etc/* permissions" { + userns="--userns=keep-id" + if ! is_rootless; then + userns="--uidmap=0:1111111:65536 --gidmap=0:1111111:65536" + fi + # check with and without userns + for userns in "" "$userns"; do + # check the /etc/hosts /etc/hostname /etc/resolv.conf are owned by root + run_podman run $userns --rm $IMAGE stat -c %u:%g /etc/hosts /etc/resolv.conf /etc/hostname + is "${lines[0]}" "0\:0" "/etc/hosts owned by root" + is "${lines[1]}" "0\:0" "/etc/resolv.conf owned by root" + is "${lines[2]}" "0\:0" "/etc/hosts owned by root" + done +} + # vim: filetype=sh diff --git a/test/test_podman_baseline.sh b/test/test_podman_baseline.sh index 5a420fe60..5ef2d1bda 100755 --- a/test/test_podman_baseline.sh +++ b/test/test_podman_baseline.sh @@ -309,6 +309,28 @@ else echo "Overlay test within limits failed" fi +before=`xfs_quota -x -c 'report -N -p' $TMPDIR | grep -c ^#` +podman $PODMANBASE volume create -o o=noquota test-no-quota +after=`xfs_quota -x -c 'report -N -p' $TMPDIR | grep -c ^#` + +if [ $before != $after ]; +then + echo "Test -o=noquota doesn't create a projid failed" +else + echo "Test -o=noquota doesn't create a projid passed" +fi + +before=`xfs_quota -x -c 'report -N -p' $TMPDIR | grep -c ^#` +podman $PODMANBASE volume create -o test-no-quota +after=`xfs_quota -x -c 'report -N -p' $TMPDIR | grep -c ^#` + +if [ $before == $after ]; +then + echo "Test without -o=noquota creates a projid failed" +else + echo "Test without -o=noquota creates a projid passed" +fi + ######## # Expected to fail ######## diff --git a/test/utils/common_function_test.go b/test/utils/common_function_test.go index a73d75490..7092e40a1 100644 --- a/test/utils/common_function_test.go +++ b/test/utils/common_function_test.go @@ -113,8 +113,10 @@ var _ = Describe("Common functions test", func() { Expect(err).To(BeNil(), "Can not find the JSON file after we write it.") defer read.Close() - bytes, _ := ioutil.ReadAll(read) - json.Unmarshal(bytes, compareData) + bytes, err := ioutil.ReadAll(read) + Expect(err).ToNot(HaveOccurred()) + err = json.Unmarshal(bytes, compareData) + Expect(err).ToNot(HaveOccurred()) Expect(reflect.DeepEqual(testData, compareData)).To(BeTrue(), "Data changed after we store it to file.") }) diff --git a/test/utils/podmantest_test.go b/test/utils/podmantest_test.go index a9b5aef1f..26d359d38 100644 --- a/test/utils/podmantest_test.go +++ b/test/utils/podmantest_test.go @@ -1,8 +1,6 @@ package utils_test import ( - "os" - . "github.com/containers/podman/v4/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -19,16 +17,6 @@ var _ = Describe("PodmanTest test", func() { FakeOutputs = make(map[string][]string) }) - It("Test PodmanAsUserBase", func() { - FakeOutputs["check"] = []string{"check"} - os.Setenv("HOOK_OPTION", "hook_option") - env := os.Environ() - session := podmanTest.PodmanAsUserBase([]string{"check"}, 1000, 1000, "", env, true, false, nil, nil) - os.Unsetenv("HOOK_OPTION") - session.WaitWithDefaultTimeout() - Expect(session.Command.Process).ShouldNot(BeNil()) - }) - It("Test NumberOfContainersRunning", func() { FakeOutputs["ps -q"] = []string{"one", "two"} Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2)) diff --git a/test/utils/utils.go b/test/utils/utils.go index f3e14c784..36f5a9414 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -489,7 +489,9 @@ func IsCommandAvailable(command string) bool { // WriteJSONFile write json format data to a json file func WriteJSONFile(data []byte, filePath string) error { var jsonData map[string]interface{} - json.Unmarshal(data, &jsonData) + if err := json.Unmarshal(data, &jsonData); err != nil { + return err + } formatJSON, err := json.MarshalIndent(jsonData, "", " ") if err != nil { return err |