func immediateInteractionWithJenkins(uri, method string, body io.Reader, status int) { req, err := http.NewRequest(method, uri, body) o.Expect(err).NotTo(o.HaveOccurred()) if body != nil { req.Header.Set("Content-Type", "application/xml") // jenkins will return 417 if we have an expect hdr req.Header.Del("Expect") } req.SetBasicAuth("admin", "password") client := &http.Client{} resp, err := client.Do(req) o.Expect(err).NotTo(o.HaveOccurred()) defer resp.Body.Close() o.Expect(resp.StatusCode).To(o.BeEquivalentTo(status)) }
func immediateInteractionWithJenkins(uri, method, password string, body io.Reader, status int) { req, err := http.NewRequest(method, uri, body) o.Expect(err).NotTo(o.HaveOccurred()) if body != nil { req.Header.Set("Content-Type", "application/xml") // jenkins will return 417 if we have an expect hdr req.Header.Del("Expect") } req.SetBasicAuth("admin", password) client := &http.Client{} resp, err := client.Do(req) o.Expect(err).NotTo(o.HaveOccurred()) defer resp.Body.Close() contents, err := ioutil.ReadAll(resp.Body) if err == nil && resp.StatusCode != status { consoleLogs := string(contents) fmt.Fprintf(g.GinkgoWriter, "logs from immediate interaction %s\n", consoleLogs) } o.Expect(resp.StatusCode).To(o.BeEquivalentTo(status)) }
err = oc.Run("create").Args("-f", sourceBuildFixture).Execute() o.Expect(err).NotTo(o.HaveOccurred()) g.By("starting the sample source build") out, err := oc.Run("start-build").Args("test", "--follow", "--wait").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")
if b.Name == startedBuilds[0] && b.Status.Phase == buildapi.BuildPhaseRunning { firstBuildRunning = true } return false }) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(firstBuildRunning).Should(o.BeTrue()) counter++ } // When the build failed or completed prematurely, fail the test o.Expect(buildutil.IsBuildComplete(build)).Should(o.BeFalse()) if counter == 2 { break } } o.Expect(counter).Should(o.BeEquivalentTo(2)) }) }) g.Describe("build configuration with Serial build run policy", func() { g.It("runs the builds in serial order", func() { g.By("starting multiple builds") var ( startedBuilds []string counter int ) bcName := "sample-serial-build" buildVerified := map[string]bool{} for i := 0; i < 3; i++ {
o.Expect(out).To(o.ContainSubstring("deployment-test-1 to 2")) o.Expect(out).To(o.ContainSubstring("--> pre: Success")) o.Expect(out).To(o.ContainSubstring("--> Success")) g.By("verifying the deployment is marked complete and scaled to zero") o.Expect(waitForLatestCondition(oc, "deployment-test", deploymentRunTimeout, deploymentReachedCompletion)).NotTo(o.HaveOccurred()) g.By("verifying that scaling does not result in new pods") out, err = oc.Run("scale").Args("dc/deployment-test", "--replicas=1").Output() o.Expect(err).NotTo(o.HaveOccurred()) g.By("ensuring no scale up of the deployment happens") wait.Poll(100*time.Millisecond, 10*time.Second, func() (bool, error) { rc, err := oc.KubeREST().ReplicationControllers(oc.Namespace()).Get("deployment-test-1") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(rc.Spec.Replicas).Should(o.BeEquivalentTo(0)) o.Expect(rc.Status.Replicas).Should(o.BeEquivalentTo(0)) return false, nil }) g.By("verifying the scale is updated on the deployment config") config, err := oc.REST().DeploymentConfigs(oc.Namespace()).Get("deployment-test") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(config.Spec.Replicas).Should(o.BeEquivalentTo(1)) o.Expect(config.Spec.Test).Should(o.BeTrue()) g.By("deploying a few more times") for i := 0; i < 3; i++ { out, err = oc.Run("deploy").Args("--latest", "--follow", "deployment-test").Output() o.Expect(err).NotTo(o.HaveOccurred())
g.JustBeforeEach(func() { g.By("waiting for builder service account") err := exutil.WaitForBuilderAccount(oc.KubeREST().ServiceAccounts(oc.Namespace())) o.Expect(err).NotTo(o.HaveOccurred()) oc.Run("create").Args("-f", buildFixture).Execute() }) g.Describe("start build with broken proxy", func() { g.It("should start a build and wait for the build to to fail", func() { g.By("starting the build with --wait and --follow flags") out, err := oc.Run("start-build").Args("sample-build", "--follow", "--wait").Output() if err != nil { fmt.Fprintln(g.GinkgoWriter, out) } o.Expect(err).To(o.HaveOccurred()) g.By("verifying the build sample-app-1 output") // The git ls-remote check should exit the build when the remote // repository is not accessible. It should never get to the clone. o.Expect(out).NotTo(o.ContainSubstring("clone")) o.Expect(out).To(o.ContainSubstring(`unable to access 'https://github.com/openshift/ruby-hello-world.git/': Failed connect to 127.0.0.1:3128`)) g.By("verifying the build sample-build-1 status") build, err := oc.REST().Builds(oc.Namespace()).Get("sample-build-1") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(build.Status.Phase).Should(o.BeEquivalentTo(buildapi.BuildPhaseFailed)) }) }) })
}) g.Describe("oc start-build source-build --wait", func() { g.It("Source: should start a build and wait for the build failed and build pod being killed by kubelet", func() { g.By("calling oc create source-build") err := oc.Run("create").Args("-f", sourceFixture).Execute() o.Expect(err).NotTo(o.HaveOccurred()) g.By("starting the source build with --wait flag and short timeout") br, err := exutil.StartBuildAndWait(oc, "source-build", "--wait") o.Expect(br.StartBuildErr).To(o.HaveOccurred()) // start-build should detect the build error g.By("verifying the build status") o.Expect(br.BuildAttempt).To(o.BeTrue()) // the build should have been attempted o.Expect(br.Build.Status.Phase).Should(o.BeEquivalentTo(buildapi.BuildPhaseFailed)) // the build should have failed g.By("verifying the build pod status") pod, err := oc.KubeREST().Pods(oc.Namespace()).Get(buildapi.GetBuildPodName(br.Build)) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(pod.Status.Phase).Should(o.BeEquivalentTo(kapi.PodFailed)) o.Expect(pod.Status.Reason).Should(o.ContainSubstring("DeadlineExceeded")) }) }) g.Describe("oc start-build docker-build --wait", func() { g.It("Docker: should start a build and wait for the build failed and build pod being killed by kubelet", func() { g.By("calling oc create docker-build") err := oc.Run("create").Args("-f", dockerFixture).Execute()