Пример #1
0
// waitForAnImageStreamTag waits until an image stream with given name has non-empty history for given tag
func waitForAnImageStreamTag(oc *exutil.CLI, name, tag string) error {
	g.By(fmt.Sprintf("waiting for an is importer to import a tag %s into a stream %s", tag, name))
	start := time.Now()
	c := make(chan error)
	go func() {
		err := exutil.WaitForAnImageStream(
			oc.REST().ImageStreams(oc.Namespace()),
			name,
			func(is *imageapi.ImageStream) bool {
				if history, exists := is.Status.Tags[tag]; !exists || len(history.Items) == 0 {
					return false
				}
				return true
			},
			func(is *imageapi.ImageStream) bool {
				return time.Now().After(start.Add(waitTimeout))
			})
		c <- err
	}()

	select {
	case e := <-c:
		return e
	case <-time.After(waitTimeout):
		return fmt.Errorf("timed out while waiting of an image stream tag %s/%s:%s", oc.Namespace(), name, tag)
	}
}
Пример #2
0
var _ = g.Describe("[builds][Slow] build can have Docker image source", func() {
	defer g.GinkgoRecover()
	var (
		buildFixture     = exutil.FixturePath("testdata", "test-imagesource-build.yaml")
		oc               = exutil.NewCLI("build-image-source", exutil.KubeConfigPath())
		imageSourceLabel = exutil.ParseLabelsOrDie("app=imagesourceapp")
		imageDockerLabel = exutil.ParseLabelsOrDie("app=imagedockerapp")
	)

	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.By("waiting for imagestreams to be imported")
		err = exutil.WaitForAnImageStream(oc.AdminREST().ImageStreams("openshift"), "jenkins", exutil.CheckImageStreamLatestTagPopulatedFn, exutil.CheckImageStreamTagNotFoundFn)
		o.Expect(err).NotTo(o.HaveOccurred())
	})

	g.Describe("build with image source", func() {
		g.It("should complete successfully and contain the expected file", func() {
			g.By("Creating build configs for source build")
			err := oc.Run("create").Args("-f", buildFixture).Execute()
			o.Expect(err).NotTo(o.HaveOccurred())
			g.By("starting the source strategy build")
			err = oc.Run("start-build").Args("imagesourcebuild").Execute()
			o.Expect(err).NotTo(o.HaveOccurred())
			g.By("expecting the builds to complete successfully")
			err = exutil.WaitForABuild(oc.REST().Builds(oc.Namespace()), "imagesourcebuild-1", exutil.CheckBuildSuccessFn, exutil.CheckBuildFailedFn)
			if err != nil {
				exutil.DumpBuildLogs("imagesourcebuild", oc)
Пример #3
0
		serviceConfigFixture     = exutil.FixturePath("fixtures", "ldap", "ldapserver-service.json")
		oc                       = exutil.NewCLI("openldap", exutil.KubeConfigPath())
	)

	g.Describe("Building and deploying an OpenLDAP server", func() {
		g.It(fmt.Sprintf("should create a image from %s template and run it in a pod", buildConfigFixture), func() {
			nameRegex := regexp.MustCompile(`"[A-Za-z0-9\-]+"`)
			oc.SetOutputDir(exutil.TestContext.OutputDir)

			g.By(fmt.Sprintf("calling oc create -f %s", imageStreamFixture))
			imageStreamMessage, err := oc.Run("create").Args("-f", imageStreamFixture).Output()
			o.Expect(err).NotTo(o.HaveOccurred())

			imageStreamName := strings.Trim(nameRegex.FindString(imageStreamMessage), `"`)
			g.By("expecting the imagestream to fetch and tag the latest image")
			err = exutil.WaitForAnImageStream(oc.REST().ImageStreams(oc.Namespace()), imageStreamName,
				exutil.CheckImageStreamLatestTagPopulatedFunc, exutil.CheckImageStreamTagNotFoundFunc)
			o.Expect(err).NotTo(o.HaveOccurred())

			g.By(fmt.Sprintf("calling oc create -f %s", imageStreamTargetFixture))
			err = oc.Run("create").Args("-f", imageStreamTargetFixture).Execute()
			o.Expect(err).NotTo(o.HaveOccurred())

			g.By(fmt.Sprintf("calling oc create -f %s", buildConfigFixture))
			buildConfigMessage, err := oc.Run("create").Args("-f", buildConfigFixture).Output()
			o.Expect(err).NotTo(o.HaveOccurred())

			buildConfigName := strings.Trim(nameRegex.FindString(buildConfigMessage), `"`)
			g.By(fmt.Sprintf("calling oc start-build %s", buildConfigName))
			buildName, err := oc.Run("start-build").Args(buildConfigName).Output()
			o.Expect(err).NotTo(o.HaveOccurred())