-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_source.go
83 lines (70 loc) · 3.61 KB
/
image_source.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package builds
import (
"time"
g "github.com/onsi/ginkgo"
o "github.com/onsi/gomega"
exutil "github.com/openshift/origin/test/extended/util"
)
var _ = g.Describe("[builds] build can have Docker image source", func() {
defer g.GinkgoRecover()
var (
buildFixture = exutil.FixturePath("fixtures", "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)
o.Expect(err).NotTo(o.HaveOccurred())
g.By("expecting the pod to deploy successfully")
pods, err := exutil.WaitForPods(oc.KubeREST().Pods(oc.Namespace()), imageSourceLabel, exutil.CheckPodIsRunningFn, 1, 2*time.Minute)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(len(pods)).To(o.Equal(1))
pod, err := oc.KubeREST().Pods(oc.Namespace()).Get(pods[0])
o.Expect(err).NotTo(o.HaveOccurred())
g.By("expecting the pod to contain the file from the input image")
out, err := oc.Run("exec").Args(pod.Name, "-c", pod.Spec.Containers[0].Name, "--", "ls", "injected/dir").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(out).To(o.ContainSubstring("jenkins.war"))
})
})
g.Describe("build with image docker", func() {
g.It("should complete successfully and contain the expected file", func() {
g.By("Creating build configs for docker build")
err := oc.Run("create").Args("-f", buildFixture).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("starting the docker strategy build")
err = oc.Run("start-build").Args("imagedockerbuild").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("expect the builds to complete successfully")
err = exutil.WaitForABuild(oc.REST().Builds(oc.Namespace()), "imagedockerbuild-1", exutil.CheckBuildSuccessFn, exutil.CheckBuildFailedFn)
o.Expect(err).NotTo(o.HaveOccurred())
g.By("expect the pod to deploy successfully")
pods, err := exutil.WaitForPods(oc.KubeREST().Pods(oc.Namespace()), imageDockerLabel, exutil.CheckPodIsRunningFn, 1, 2*time.Minute)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(len(pods)).To(o.Equal(1))
pod, err := oc.KubeREST().Pods(oc.Namespace()).Get(pods[0])
o.Expect(err).NotTo(o.HaveOccurred())
g.By("expecting the pod to contain the file from the input image")
out, err := oc.Run("exec").Args(pod.Name, "-c", pod.Spec.Containers[0].Name, "--", "ls", "injected/dir").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(out).To(o.ContainSubstring("jenkins.war"))
})
})
})