Skip to content

Commit

Permalink
Merge pull request #18544 from Luap99/e2e-dedup
Browse files Browse the repository at this point in the history
test/e2e: dedup Before/AfterEach nodes
  • Loading branch information
openshift-merge-robot authored May 15, 2023
2 parents 493aac6 + ab29ff2 commit 7d305d5
Show file tree
Hide file tree
Showing 129 changed files with 44 additions and 2,695 deletions.
19 changes: 0 additions & 19 deletions test/e2e/attach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,12 @@ import (
"syscall"
"time"

. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)

var _ = Describe("Podman attach", func() {
var (
tempdir string
err error
podmanTest *PodmanTestIntegration
)

BeforeEach(func() {
tempdir, err = CreateTempDirInTempDir()
Expect(err).ToNot(HaveOccurred())
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
})

AfterEach(func() {
podmanTest.Cleanup()
f := CurrentSpecReport()
processTestResult(f)
})

It("podman attach to bogus container", func() {
session := podmanTest.Podman([]string{"attach", "foobar"})
Expand Down
22 changes: 0 additions & 22 deletions test/e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,12 @@ import (
"strings"

"github.com/containers/buildah"
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)

var _ = Describe("Podman build", func() {
var (
tempdir string
err error
podmanTest *PodmanTestIntegration
)

BeforeEach(func() {
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
}
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
})

AfterEach(func() {
podmanTest.Cleanup()
f := CurrentSpecReport()
processTestResult(f)
})

// Let's first do the most simple build possible to make sure stuff is
// happy and then clean up after ourselves to make sure that works too.
It("podman build and remove basic alpine", func() {
Expand Down
18 changes: 0 additions & 18 deletions test/e2e/checkpoint_image_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package integration

import (
"os"
"os/exec"
"strconv"
"strings"
Expand All @@ -14,21 +13,10 @@ import (
)

var _ = Describe("Podman checkpoint", func() {
var (
tempdir string
err error
podmanTest *PodmanTestIntegration
)

BeforeEach(func() {
SkipIfContainerized("FIXME: #15015. All checkpoint tests hang when containerized.")
SkipIfRootless("checkpoint not supported in rootless mode")
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
}
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
// Check if the runtime implements checkpointing. Currently only
// runc's checkpoint/restore implementation is supported.
cmd := exec.Command(podmanTest.OCIRuntime, "checkpoint", "--help")
Expand All @@ -44,12 +32,6 @@ var _ = Describe("Podman checkpoint", func() {
}
})

AfterEach(func() {
podmanTest.Cleanup()
f := CurrentSpecReport()
processTestResult(f)
})

It("podman checkpoint --create-image with bogus container", func() {
checkpointImage := "foobar-checkpoint"
session := podmanTest.Podman([]string{"container", "checkpoint", "--create-image", checkpointImage, "foobar"})
Expand Down
16 changes: 0 additions & 16 deletions test/e2e/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,11 @@ func getRunString(input []string) []string {
}

var _ = Describe("Podman checkpoint", func() {
var (
tempdir string
err error
podmanTest *PodmanTestIntegration
)

BeforeEach(func() {
SkipIfRootless("checkpoint not supported in rootless mode")
SkipIfContainerized("FIXME: #15015. All checkpoint tests hang when containerized.")
tempdir, err = CreateTempDirInTempDir()
Expect(err).ToNot(HaveOccurred())

podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
// Check if the runtime implements checkpointing. Currently only
// runc's checkpoint/restore implementation is supported.
cmd := exec.Command(podmanTest.OCIRuntime, "checkpoint", "--help")
Expand All @@ -64,13 +55,6 @@ var _ = Describe("Podman checkpoint", func() {
}
})

AfterEach(func() {
podmanTest.Cleanup()
f := CurrentSpecReport()
processTestResult(f)

})

It("podman checkpoint bogus container", func() {
session := podmanTest.Podman([]string{"container", "checkpoint", "foobar"})
session.WaitWithDefaultTimeout()
Expand Down
21 changes: 0 additions & 21 deletions test/e2e/cleanup_test.go
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
package integration

import (
"os"

. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)

var _ = Describe("Podman container cleanup", func() {
var (
tempdir string
err error
podmanTest *PodmanTestIntegration
)

BeforeEach(func() {
SkipIfRemote("podman container cleanup is not supported in remote")
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
}
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
})

AfterEach(func() {
podmanTest.Cleanup()
f := CurrentSpecReport()
processTestResult(f)

})

It("podman cleanup bogus container", func() {
Expand Down
19 changes: 0 additions & 19 deletions test/e2e/commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,6 @@ import (
)

var _ = Describe("Podman commit", func() {
var (
tempdir string
err error
podmanTest *PodmanTestIntegration
)

BeforeEach(func() {
tempdir, err = CreateTempDirInTempDir()
Expect(err).ToNot(HaveOccurred())
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
})

AfterEach(func() {
podmanTest.Cleanup()
f := CurrentSpecReport()
processTestResult(f)

})

It("podman commit container", func() {
_, ec, _ := podmanTest.RunLsContainer("test1")
Expand Down
27 changes: 23 additions & 4 deletions test/e2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,29 @@ func TestLibpod(t *testing.T) {
RunSpecs(t, "Libpod Suite")
}

var (
tempdir string
err error
podmanTest *PodmanTestIntegration

_ = BeforeEach(func() {
tempdir, err = CreateTempDirInTempDir()
Expect(err).ToNot(HaveOccurred())
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
})

_ = AfterEach(func() {
// First unset CONTAINERS_CONF before doing Cleanup() to prevent
// invalid containers.conf files to fail the cleanup.
os.Unsetenv("CONTAINERS_CONF")
os.Unsetenv("CONTAINERS_CONF_OVERRIDE")
podmanTest.Cleanup()
f := CurrentSpecReport()
processTestResult(f)
})
)

var _ = SynchronizedBeforeSuite(func() []byte {
// make cache dir
ImageCacheDir = filepath.Join(os.TempDir(), "imagecachedir")
Expand Down Expand Up @@ -643,8 +666,6 @@ func (p *PodmanTestIntegration) CleanupVolume() {
// Remove all containers
session := p.Podman([]string{"volume", "rm", "-fa"})
session.WaitWithDefaultTimeout()

p.Cleanup()
Expect(session).To(Exit(0), "command: %v\nstdout: %s\nstderr: %s", session.Command.Args, session.OutputToString(), session.ErrorToString())
}

Expand All @@ -654,8 +675,6 @@ func (p *PodmanTestIntegration) CleanupSecrets() {
// Remove all containers
session := p.Podman([]string{"secret", "rm", "-a"})
session.Wait(90)

p.Cleanup()
Expect(session).To(Exit(0), "command: %v\nstdout: %s\nstderr: %s", session.Command.Args, session.OutputToString(), session.ErrorToString())
}

Expand Down
22 changes: 0 additions & 22 deletions test/e2e/container_clone_test.go
Original file line number Diff line number Diff line change
@@ -1,36 +1,14 @@
package integration

import (
"os"

. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)

var _ = Describe("Podman container clone", func() {
var (
tempdir string
err error
podmanTest *PodmanTestIntegration
)

BeforeEach(func() {
SkipIfRemote("podman container clone is not supported in remote")
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
}
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
})

AfterEach(func() {
podmanTest.Cleanup()
f := CurrentSpecReport()
processTestResult(f)

})

It("podman container clone basic test", func() {
Expand Down
22 changes: 0 additions & 22 deletions test/e2e/container_create_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"path/filepath"

. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
Expand Down Expand Up @@ -69,27 +68,6 @@ func checkDataVolumeContainer(pTest *PodmanTestIntegration, image, cont, dest, d
}

var _ = Describe("Podman create data volume", func() {
var (
tempdir string
err error
podmanTest *PodmanTestIntegration
)

BeforeEach(func() {
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
}
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
})

AfterEach(func() {
podmanTest.Cleanup()
f := CurrentSpecReport()
processTestResult(f)
os.Unsetenv("CONTAINERS_CONF")
})

It("podman create with volume data copy turned off", func() {
imgName, volData, volDest := "dataimg", "dummy", "/test"
Expand Down
23 changes: 0 additions & 23 deletions test/e2e/container_inspect_test.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,14 @@
package integration

import (
"os"

"github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/annotations"
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)

var _ = Describe("Podman container inspect", func() {
var (
tempdir string
err error
podmanTest *PodmanTestIntegration
)

BeforeEach(func() {
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
}
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
})

AfterEach(func() {
podmanTest.Cleanup()
f := CurrentSpecReport()
processTestResult(f)
})

It("podman inspect a container for the container manager annotation", func() {
const testContainer = "container-inspect-test-1"
Expand Down
Loading

0 comments on commit 7d305d5

Please sign in to comment.