本文整理汇总了Golang中github.com/openshift/origin/test/extended/util.StartBuildAndWait函数的典型用法代码示例。如果您正苦于以下问题:Golang StartBuildAndWait函数的具体用法?Golang StartBuildAndWait怎么用?Golang StartBuildAndWait使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StartBuildAndWait函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: doTest
func doTest(bldPrefix, debugStr string, same bool, oc *exutil.CLI) {
// corrupt the builder image
exutil.CorruptImage(fullImageName, corruptor)
if bldPrefix == buildPrefixFC || bldPrefix == buildPrefixTC {
// grant access to the custom build strategy
err := oc.AsAdmin().Run("adm").Args("policy", "add-cluster-role-to-user", "system:build-strategy-custom", oc.Username()).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
defer func() {
err = oc.AsAdmin().Run("adm").Args("policy", "remove-cluster-role-from-user", "system:build-strategy-custom", oc.Username()).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
}()
}
// kick off the app/lang build and verify the builder image accordingly
_, err := exutil.StartBuildAndWait(oc, bldPrefix)
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred())
if same {
exutil.VerifyImagesSame(fullImageName, corruptor, debugStr)
} else {
exutil.VerifyImagesDifferent(fullImageName, corruptor, debugStr)
}
// reset corrupted tagging for next test
exutil.ResetImage(resetData)
// dump tags/hexids for debug
_, err = exutil.DumpAndReturnTagging(tags)
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred())
}
示例2: doTest
func doTest(bldPrefix, debugStr string, same bool, oc *exutil.CLI) {
// corrupt the builder image
exutil.CorruptImage(fullImageName, corruptor)
// kick off the app/lang build and verify the builder image accordingly
_, err := exutil.StartBuildAndWait(oc, bldPrefix)
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred())
if same {
exutil.VerifyImagesSame(fullImageName, corruptor, debugStr)
} else {
exutil.VerifyImagesDifferent(fullImageName, corruptor, debugStr)
}
// reset corrupted tagging for next test
exutil.ResetImage(resetData)
// dump tags/hexids for debug
_, err = exutil.DumpAndReturnTagging(tags)
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred())
}
示例3:
g.It("by creating slave from existing builder and adding it to Jenkins master", func() {
g.By("create the jenkins slave builder template")
err := oc.Run("create").Args("-f", jenkinsSlaveBuilderTemplate).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("create the jenkins master template")
err = oc.Run("create").Args("-f", jenkinsMasterTemplate).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("instantiate the slave template")
err = oc.Run("new-app").Args("--template", "jenkins-slave-builder").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("build the Jenkins slave for ruby-22-centos7")
br, err := exutil.StartBuildAndWait(oc, "ruby-22-centos7-jenkins-slave", "--wait", "--from-dir", "examples/jenkins/master-slave/slave")
br.AssertSuccess()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("grant service account in jenkins container access to API")
err = oc.Run("policy").Args("add-role-to-user", "edit", "system:serviceaccount:"+oc.Namespace()+":default", "-n", oc.Namespace()).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("instantiate the master template")
err = oc.Run("new-app").Args("--template", "jenkins-master").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("build the Jenkins master")
br, err = exutil.StartBuildAndWait(oc, "jenkins-master", "--wait", "--from-dir", "examples/jenkins/master-slave")
br.AssertSuccess()
o.Expect(err).NotTo(o.HaveOccurred())
示例4:
g.Describe("build with long names", func() {
oc.SetOutputDir(exutil.TestContext.OutputDir)
g.It("delete builds with long names without collateral damage", func() {
g.By("creating long_names fixtures")
err := oc.Run("create").Args("-f", longNamesFixture).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
// Names can be a maximum of 253 chars. These build config names are 201 (to allow for suffixes appiled during the test process, e.g. -1, -2 for builds and log filenames)
// and the names differ only in the last character.
bcA := "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890a"
bcB := "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890b"
g.By("starting long name build config A-1")
brA1, err := exutil.StartBuildAndWait(oc, bcA)
brA1.AssertSuccess()
g.By("starting long name build config B-1")
brB1, err := exutil.StartBuildAndWait(oc, bcB)
brB1.AssertSuccess()
g.By("starting long name build config A-2")
brA2, err := exutil.StartBuildAndWait(oc, bcA)
brA2.AssertSuccess()
g.By("starting long name build config B-2")
brB2, err := exutil.StartBuildAndWait(oc, bcB)
brB2.AssertSuccess()
builds := [...]*exutil.BuildResult{brA1, brB1, brA2, brB2}
示例5:
})
g.Describe("S2I build from a template", func() {
g.It(fmt.Sprintf("should create a image from %q template with proper Docker labels", stiBuildFixture), func() {
oc.SetOutputDir(exutil.TestContext.OutputDir)
g.By(fmt.Sprintf("calling oc create -f %q", imageStreamFixture))
err := oc.Run("create").Args("-f", imageStreamFixture).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By(fmt.Sprintf("calling oc create -f %q", stiBuildFixture))
err = oc.Run("create").Args("-f", stiBuildFixture).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("starting a test build")
br, err := exutil.StartBuildAndWait(oc, "test")
br.AssertSuccess()
g.By("getting the Docker image reference from ImageStream")
imageRef, err := exutil.GetDockerImageReference(oc.REST().ImageStreams(oc.Namespace()), "test", "latest")
o.Expect(err).NotTo(o.HaveOccurred())
imageLabels, err := eximages.GetImageLabels(oc.REST().ImageStreamImages(oc.Namespace()), "test", imageRef)
o.Expect(err).NotTo(o.HaveOccurred())
g.By("inspecting the new image for proper Docker labels")
err = ExpectOpenShiftLabels(imageLabels)
o.Expect(err).NotTo(o.HaveOccurred())
})
})
示例6:
g.JustBeforeEach(func() {
g.By("waiting for builder service account")
err := exutil.WaitForBuilderAccount(oc.KubeREST().ServiceAccounts(oc.Namespace()))
o.Expect(err).NotTo(o.HaveOccurred())
})
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"))
})
})
示例7:
})
g.Context("Pipeline with maven slave", func() {
g.It("Should build and complete successfully", func() {
// Deploy Jenkins
g.By(fmt.Sprintf("calling oc new-app -f %q", jenkinsTemplatePath))
err := oc.Run("new-app").Args("-f", jenkinsTemplatePath).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
// instantiate the template
g.By(fmt.Sprintf("calling oc new-app -f %q", mavenSlavePipelinePath))
err = oc.Run("new-app").Args("-f", mavenSlavePipelinePath).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
// start the build
g.By("starting the pipeline build and waiting for it to complete")
br, _ := exutil.StartBuildAndWait(oc, "openshift-jee-sample")
br.AssertSuccess()
// wait for the service to be running
g.By("expecting the openshift-jee-sample service to be deployed and running")
_, err = exutil.GetEndpointAddress(oc, "openshift-jee-sample")
o.Expect(err).NotTo(o.HaveOccurred())
})
})
g.Context("Orchestration pipeline", func() {
g.It("Should build and complete successfully", func() {
// Deploy Jenkins
g.By(fmt.Sprintf("calling oc new-app -f %q", jenkinsTemplatePath))
err := oc.Run("new-app").Args("-f", jenkinsTemplatePath).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
示例8:
buildFixture = exutil.FixturePath("testdata", "test-build-proxy.json")
oc = exutil.NewCLI("build-proxy", exutil.KubeConfigPath())
)
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")
br, _ := exutil.StartBuildAndWait(oc, "sample-build")
br.AssertFailure()
g.By("verifying the build sample-build-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.
buildLog, err := br.Logs()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(buildLog).NotTo(o.ContainSubstring("clone"))
if !strings.Contains(buildLog, `unable to access 'https://github.com/openshift/ruby-hello-world.git/': Failed connect to 127.0.0.1:3128`) {
fmt.Fprintf(g.GinkgoWriter, "\nbuild log:\n%s\n", buildLog)
}
o.Expect(buildLog).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")
o.Expect(br.Build.Status.Phase).Should(o.BeEquivalentTo(buildapi.BuildPhaseFailed))
示例9:
})
g.Describe("Building from a template", func() {
g.It(fmt.Sprintf("should create a image from %q template and run it in a pod", stiEnvBuildFixture), func() {
oc.SetOutputDir(exutil.TestContext.OutputDir)
g.By(fmt.Sprintf("calling oc create -f %q", imageStreamFixture))
err := oc.Run("create").Args("-f", imageStreamFixture).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By(fmt.Sprintf("calling oc create -f %q", stiEnvBuildFixture))
err = oc.Run("create").Args("-f", stiEnvBuildFixture).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("starting a test build")
br, _ := exutil.StartBuildAndWait(oc, "test")
br.AssertSuccess()
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("instantiating a pod and service with the new image")
err = oc.Run("new-app").Args("-f", podAndServiceFixture, "-p", "IMAGE_NAME="+imageName).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("waiting for the service to become available")
err = oc.KubeFramework().WaitForAnEndpoint(buildTestService)
o.Expect(err).NotTo(o.HaveOccurred())
g.By("expecting the pod container has TEST_ENV variable set")
示例10:
// See this issue for details: https://github.com/openshift/origin/issues/10103
err = exutil.WaitForAnImageStreamTag(oc, "openshift", "wildfly", "10.0")
o.Expect(err).NotTo(o.HaveOccurred())
})
g.Describe("with scripts from the source repository", func() {
oc.SetOutputDir(exutil.TestContext.OutputDir)
g.It("should use assemble-runtime script from the source repository", func() {
g.By("creating jvm-runner configuration")
err := exutil.CreateResource(runnerConf, oc)
o.Expect(err).NotTo(o.HaveOccurred())
g.By("building jvm-runner image")
br, _ := exutil.StartBuildAndWait(oc, "jvm-runner")
br.AssertSuccess()
g.By("creating build config")
err = exutil.CreateResource(scriptsFromRepoBc, oc)
o.Expect(err).NotTo(o.HaveOccurred())
g.By("running the build")
br, _ = exutil.StartBuildAndWait(oc, "java-extended-build-from-repo", "--build-loglevel=5")
br.AssertSuccess()
buildLog, err := br.Logs()
if err != nil {
e2e.Failf("Failed to fetch build logs: %v", err)
}
g.By("expecting that .s2i/bin/assemble-runtime was executed")
示例11:
defer g.GinkgoRecover()
var (
dockerImageFixture = exutil.FixturePath("testdata", "test-docker-no-outputname.json")
s2iImageFixture = exutil.FixturePath("testdata", "test-s2i-no-outputname.json")
oc = exutil.NewCLI("build-no-outputname", exutil.KubeConfigPath())
)
g.Describe("building from templates", func() {
oc.SetOutputDir(exutil.TestContext.OutputDir)
g.It(fmt.Sprintf("should create an image from %q docker template without an output image reference defined", dockerImageFixture), func() {
err := oc.Run("create").Args("-f", dockerImageFixture).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("expecting build to pass without an output image reference specified")
br, err := exutil.StartBuildAndWait(oc, "test-docker")
br.AssertSuccess()
g.By("verifying the build test-docker-1 output")
buildLog, err := br.Logs()
fmt.Fprintf(g.GinkgoWriter, "\nBuild log:\n%s\n", buildLog)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(buildLog).Should(o.ContainSubstring(`Build complete, no image push requested`))
})
g.It(fmt.Sprintf("should create an image from %q S2i template without an output image reference defined", s2iImageFixture), func() {
err := oc.Run("create").Args("-f", s2iImageFixture).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("expecting build to pass without an output image reference specified")
br, err := exutil.StartBuildAndWait(oc, "test-sti")
示例12:
g.By("creating secret fixtures")
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 test image stream")
err = oc.Run("create").Args("-f", isFixture).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("creating test build config")
err = oc.Run("create").Args("-f", sourceBuildFixture).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("starting the test source build")
br, _ := exutil.StartBuildAndWait(oc, "test", "--from-dir", sourceBuildBinDir)
br.AssertSuccess()
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 were available during build and 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{
"testsecret/secret1=secret1",
"testsecret/secret2=secret2",
"testsecret/secret3=secret3",
"testsecret2/secret1=secret1",
"testsecret2/secret2=secret2",
"testsecret2/secret3=secret3",
示例13:
defer g.GinkgoRecover()
var (
buildFixture = exutil.FixturePath("testdata", "test-nosrc-build.json")
oc = exutil.NewCLI("cli-build-nosrc", exutil.KubeConfigPath())
exampleBuild = exutil.FixturePath("testdata", "test-build-app")
)
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())
oc.Run("create").Args("-f", buildFixture).Execute()
})
g.Describe("started build", func() {
g.It("should build even with an empty source in build config", func() {
g.By("starting the empty source build")
br, err := exutil.StartBuildAndWait(oc, "nosrc-build", fmt.Sprintf("--from-dir=%s", exampleBuild))
br.AssertSuccess()
g.By(fmt.Sprintf("verifying the status of %q", br.BuildPath))
build, err := oc.Client().Builds(oc.Namespace()).Get(br.Build.Name)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(build.Spec.Source.Dockerfile).To(o.BeNil())
o.Expect(build.Spec.Source.Git).To(o.BeNil())
o.Expect(build.Spec.Source.Images).To(o.BeNil())
o.Expect(build.Spec.Source.Binary).NotTo(o.BeNil())
})
})
})
示例14:
)
g.JustBeforeEach(func() {
g.By("waiting for builder service account")
err := exutil.WaitForBuilderAccount(oc.KubeREST().ServiceAccounts(oc.Namespace()))
o.Expect(err).NotTo(o.HaveOccurred())
})
g.Describe("s2i build with a rootable builder", func() {
g.It("should not be able to switch to root with an assemble script", func() {
g.By("calling oc new-build for rootable-builder")
err := oc.Run("new-build").Args("--binary", "--name=rootable-ruby").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("starting the rootable-ruby build")
br, _ := exutil.StartBuildAndWait(oc, "rootable-ruby", fmt.Sprintf("--from-dir=%s", s2ibuilderFixture))
br.AssertSuccess()
g.By("creating a build that tries to gain root access via su")
err = oc.Run("create").Args("-f", rootAccessBuildFixture).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("start the root-access-build which attempts root access")
br2, _ := exutil.StartBuildAndWait(oc, "root-access-build")
br2.AssertFailure()
})
})
})
示例15:
binaryBuildDir = exutil.FixturePath("testdata", "statusfail-assemble")
oc = exutil.NewCLI("update-buildstatus", exutil.KubeConfigPath())
)
g.JustBeforeEach(func() {
g.By("waiting for the builder service account")
err := exutil.WaitForBuilderAccount(oc.KubeClient().ServiceAccounts(oc.Namespace()))
o.Expect(err).NotTo(o.HaveOccurred())
})
g.Describe("Build status postcommit hook failure", func() {
g.It("should contain the post commit hook failure reason and message", func() {
err := oc.Run("create").Args("-f", postCommitHookFixture).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
br, err := exutil.StartBuildAndWait(oc, "statusfail-postcommithook")
o.Expect(err).NotTo(o.HaveOccurred())
br.AssertFailure()
build, err := oc.Client().Builds(oc.Namespace()).Get(br.Build.Name)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(build.Status.Reason).To(o.Equal(buildapi.StatusReasonPostCommitHookFailed))
o.Expect(build.Status.Message).To(o.Equal(buildapi.StatusMessagePostCommitHookFailed))
})
})
g.Describe("Build status Docker fetch source failure", func() {
g.It("should contain the Docker build fetch source failure reason and message", func() {
err := oc.Run("create").Args("-f", fetchDockerSrc).Execute()
o.Expect(err).NotTo(o.HaveOccurred())