g.By("starting a test build") buildName, err := oc.Run("start-build").Args("test").Output() o.Expect(err).NotTo(o.HaveOccurred()) g.By("expecting the build is in Complete phase") err = exutil.WaitForABuild(oc.REST().Builds(oc.Namespace()), buildName, exutil.CheckBuildSuccessFunc, exutil.CheckBuildFailedFunc) o.Expect(err).NotTo(o.HaveOccurred()) g.By("getting the Docker image reference from ImageStream") imageName, err := exutil.GetDockerImageReference(oc.REST().ImageStreams(oc.Namespace()), "test", "latest") o.Expect(err).NotTo(o.HaveOccurred()) g.By("writing the pod definition to a file") outputPath := filepath.Join(exutil.TestContext.OutputDir, oc.Namespace()+"-sample-pod.json") pod := exutil.GetPodForContainer(kapi.Container{ Image: imageName, Name: "test", }) _, err = oc.KubeREST().Pods(oc.Namespace()).Create(pod) o.Expect(err).NotTo(o.HaveOccurred()) g.By(fmt.Sprintf("calling oc create -f %q", outputPath)) err = oc.Run("create").Args("-f", outputPath).Execute() o.Expect(err).NotTo(o.HaveOccurred()) g.By("expecting the pod to be running") err = oc.KubeFramework().WaitForPodRunning(pod.Name) o.Expect(err).NotTo(o.HaveOccurred()) g.By("expecting the pod container has TEST_ENV variable set") out, err := oc.Run("exec").Args("-p", pod.Name, "--", "curl", "http://0.0.0.0:8080").Output() o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(out).To(o.ContainSubstring("secret1=secret1")) o.Expect(out).To(o.ContainSubstring("secret3=secret3")) o.Expect(out).To(o.ContainSubstring("relative-secret1=secret1")) o.Expect(out).To(o.ContainSubstring("relative-secret3=secret3")) g.By("checking the status of the build") build, err := oc.REST().Builds(oc.Namespace()).Get("test-1") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(build.Status.Phase).Should(o.BeEquivalentTo(buildapi.BuildPhaseComplete)) g.By("getting the image name") image, err := exutil.GetDockerImageReference(oc.REST().ImageStreams(oc.Namespace()), "test", "latest") o.Expect(err).NotTo(o.HaveOccurred()) g.By("verifying the build secrets are not present in the output image") pod := exutil.GetPodForContainer(kapi.Container{Name: "test", Image: image}) oc.KubeFramework().TestContainerOutput("test-build-secret-source", pod, 0, []string{ "relative-secret1=empty", "secret3=empty", }) }) g.It("should print the secrets during the docker strategy build", func() { g.By("creating the sample secret files") err := oc.Run("create").Args("-f", secretsFixture).Execute() o.Expect(err).NotTo(o.HaveOccurred()) err = oc.Run("create").Args("-f", secondSecretsFixture).Execute() o.Expect(err).NotTo(o.HaveOccurred()) g.By("creating the sample source build config and image stream") err = oc.Run("create").Args("-f", isFixture).Execute()
defer g.GinkgoRecover() var oc = exutil.NewCLI("s2i-usage", exutil.KubeConfigPath()) g.JustBeforeEach(func() { g.By("waiting for builder service account") err := exutil.WaitForBuilderAccount(oc.KubeClient().Core().ServiceAccounts(oc.Namespace())) o.Expect(err).NotTo(o.HaveOccurred()) }) for image, tcs := range GetTestCaseForImages(AllImages) { for _, t := range tcs { g.Describe("returning s2i usage when running the image", func() { g.It(fmt.Sprintf("%q should print the usage", t.DockerImageReference), func() { g.By(fmt.Sprintf("creating a sample pod for %q", t.DockerImageReference)) pod := exutil.GetPodForContainer(kapi.Container{ Name: "test", Image: t.DockerImageReference, }) oc.KubeFramework().TestContainerOutput(getPodNameForTest(image, t), pod, 0, []string{"Sample invocation"}) }) }) g.Describe("using the SCL in s2i images", func() { g.It(fmt.Sprintf("%q should be SCL enabled", t.DockerImageReference), func() { g.By(fmt.Sprintf("creating a sample pod for %q with /bin/bash -c command", t.DockerImageReference)) pod := exutil.GetPodForContainer(kapi.Container{ Image: t.DockerImageReference, Name: "test", Command: []string{"/bin/bash", "-c", t.Cmd}, }) oc.KubeFramework().TestContainerOutput(getPodNameForTest(image, t), pod, 0, []string{t.Expected})