summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorAditya R <arajan@redhat.com>2022-02-18 16:54:18 +0530
committerAditya R <arajan@redhat.com>2022-02-21 23:52:48 +0530
commit9ce61e3a4911ad89151788539f10d96f69362bc3 (patch)
treeab975d947d99bb81f297f65c1e6892dd90979842 /test/e2e
parenta88ea2c68b1ef01077a53b1c568b85667dcbc1e2 (diff)
downloadpodman-9ce61e3a4911ad89151788539f10d96f69362bc3.tar.gz
podman-9ce61e3a4911ad89151788539f10d96f69362bc3.tar.bz2
podman-9ce61e3a4911ad89151788539f10d96f69362bc3.zip
kube: honor --build=false and make --build=true by default
`podman play kube` tries to build images even if `--build` is set to false so lets honor that and make `--build` , `true` by default so it matches the original behviour. Signed-off-by: Aditya R <arajan@redhat.com>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/play_build_test.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/e2e/play_build_test.go b/test/e2e/play_build_test.go
index 70e042b4d..849ba7162 100644
--- a/test/e2e/play_build_test.go
+++ b/test/e2e/play_build_test.go
@@ -212,6 +212,53 @@ LABEL marge=mom
Expect(inspectData[0].Config.Labels).To(HaveKeyWithValue("marge", "mom"))
})
+ It("Do not build image at all if --build=false", func() {
+ // Setup
+ yamlDir := filepath.Join(tempdir, RandomString(12))
+ err := os.Mkdir(yamlDir, 0755)
+ Expect(err).To(BeNil(), "mkdir "+yamlDir)
+ err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
+ Expect(err).To(BeNil())
+
+ // build an image called foobar but make sure it doesn't have
+ // the same label as the yaml buildfile, so we can check that
+ // the image is NOT rebuilt.
+ err = writeYaml(prebuiltImage, filepath.Join(yamlDir, "Containerfile"))
+ Expect(err).To(BeNil())
+
+ app1Dir := filepath.Join(yamlDir, "foobar")
+ err = os.Mkdir(app1Dir, 0755)
+ Expect(err).To(BeNil())
+ err = writeYaml(playBuildFile, filepath.Join(app1Dir, "Containerfile"))
+ Expect(err).To(BeNil())
+ // Write a file to be copied
+ err = writeYaml(copyFile, filepath.Join(app1Dir, "copyfile"))
+ Expect(err).To(BeNil())
+
+ // Switch to temp dir and restore it afterwards
+ cwd, err := os.Getwd()
+ Expect(err).To(BeNil())
+ Expect(os.Chdir(yamlDir)).To(BeNil())
+ defer func() { (Expect(os.Chdir(cwd)).To(BeNil())) }()
+
+ // Build the image into the local store
+ build := podmanTest.Podman([]string{"build", "-t", "foobar", "-f", "Containerfile"})
+ build.WaitWithDefaultTimeout()
+ Expect(build).Should(Exit(0))
+
+ session := podmanTest.Podman([]string{"play", "kube", "--build=false", "top.yaml"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ inspect := podmanTest.Podman([]string{"container", "inspect", "top_pod-foobar"})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect).Should(Exit(0))
+ inspectData := inspect.InspectContainerToJSON()
+ Expect(len(inspectData)).To(BeNumerically(">", 0))
+ Expect(inspectData[0].Config.Labels).To(Not(HaveKey("homer")))
+ Expect(inspectData[0].Config.Labels).To(HaveKeyWithValue("marge", "mom"))
+ })
+
It("--build should override image in store", func() {
// Setup
yamlDir := filepath.Join(tempdir, RandomString(12))