diff options
author | TomSweeneyRedHat <tsweeney@redhat.com> | 2019-11-06 14:19:34 -0500 |
---|---|---|
committer | TomSweeneyRedHat <tsweeney@redhat.com> | 2019-11-16 19:19:49 -0500 |
commit | f2f45ccb57f69cf6264aa1ad9dd08d196869f7f6 (patch) | |
tree | 1f07278207d277aecefb72153d15cd2480186e02 /test/e2e/build_test.go | |
parent | c6f2383213b6a8ebf4c4b9f5d5162e7c08fa7c9f (diff) | |
download | podman-f2f45ccb57f69cf6264aa1ad9dd08d196869f7f6.tar.gz podman-f2f45ccb57f69cf6264aa1ad9dd08d196869f7f6.tar.bz2 podman-f2f45ccb57f69cf6264aa1ad9dd08d196869f7f6.zip |
Add new test suite for build
Most build testing should be done in Buildah's test
suites, but we should have a minimal amount of tests,
especially testing the parts that are different like
layers and squash. Also the CLI argument handling
of things like the context directory that we've had
issues reported.
This first chunk does a basic test and then checks for
context directory being a file and squash iterations.
More to be added as time goes by.
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Diffstat (limited to 'test/e2e/build_test.go')
-rw-r--r-- | test/e2e/build_test.go | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go new file mode 100644 index 000000000..71f5d1b02 --- /dev/null +++ b/test/e2e/build_test.go @@ -0,0 +1,108 @@ +// +build !remoteclient + +package integration + +import ( + "os" + "strings" + + . "github.com/containers/libpod/test/utils" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +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() + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + f := CurrentGinkgoTestDescription() + 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() { + session := podmanTest.PodmanNoCache([]string{"build", "build/basicalpine"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + + // If the context directory is pointing at a file and not a directory, + // that's a no no, fail out. + It("podman build context directory a file", func() { + session := podmanTest.PodmanNoCache([]string{"build", "build/context_dir_a_file"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(125)) + }) + + // Check that builds with different values for the squash options + // create the appropriate number of layers, then clean up after. + It("podman build basic alpine with squash", func() { + session := podmanTest.PodmanNoCache([]string{"build", "-f", "build/squash/Dockerfile.squash-a", "-t", "test-squash-a:latest", "build/squash"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RootFS.Layers}}", "test-squash-a"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + // Check for two layers + Expect(len(strings.Fields(session.OutputToString()))).To(Equal(2)) + + session = podmanTest.PodmanNoCache([]string{"build", "-f", "build/squash/Dockerfile.squash-b", "--squash", "-t", "test-squash-b:latest", "build/squash"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RootFS.Layers}}", "test-squash-b"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + // Check for three layers + Expect(len(strings.Fields(session.OutputToString()))).To(Equal(3)) + + session = podmanTest.PodmanNoCache([]string{"build", "-f", "build/squash/Dockerfile.squash-c", "--squash", "-t", "test-squash-c:latest", "build/squash"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RootFS.Layers}}", "test-squash-c"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + // Check for two layers + Expect(len(strings.Fields(session.OutputToString()))).To(Equal(2)) + + session = podmanTest.PodmanNoCache([]string{"build", "-f", "build/squash/Dockerfile.squash-c", "--squash-all", "-t", "test-squash-d:latest", "build/squash"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RootFS.Layers}}", "test-squash-d"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + // Check for one layers + Expect(len(strings.Fields(session.OutputToString()))).To(Equal(1)) + + session = podmanTest.PodmanNoCache([]string{"rm", "-a"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.PodmanNoCache([]string{"rmi", "-a", "-f"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) +}) |