Skip to content

Commit 9d9243a

Browse files
author
Jim Minter
committed
verify that imagechangetriggers trigger all build types
1 parent bcf0a77 commit 9d9243a

File tree

3 files changed

+258
-0
lines changed

3 files changed

+258
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package builds
2+
3+
import (
4+
"time"
5+
6+
g "github.com/onsi/ginkgo"
7+
o "github.com/onsi/gomega"
8+
9+
kerrors "k8s.io/apimachinery/pkg/api/errors"
10+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11+
"k8s.io/apimachinery/pkg/util/wait"
12+
13+
exutil "github.com/openshift/origin/test/extended/util"
14+
)
15+
16+
var _ = g.Describe("[Feature:Builds][Conformance] imagechangetriggers", func() {
17+
defer g.GinkgoRecover()
18+
19+
var (
20+
buildFixture = exutil.FixturePath("testdata", "builds", "test-imagechangetriggers.yaml")
21+
oc = exutil.NewCLI("imagechangetriggers", exutil.KubeConfigPath())
22+
)
23+
24+
g.Context("", func() {
25+
g.JustBeforeEach(func() {
26+
g.By("waiting for builder service account")
27+
err := exutil.WaitForBuilderAccount(oc.AdminKubeClient().Core().ServiceAccounts(oc.Namespace()))
28+
o.Expect(err).NotTo(o.HaveOccurred())
29+
})
30+
31+
g.AfterEach(func() {
32+
if g.CurrentGinkgoTestDescription().Failed {
33+
exutil.DumpPodStates(oc)
34+
exutil.DumpPodLogsStartingWith("", oc)
35+
}
36+
})
37+
38+
g.It("imagechangetriggers should trigger builds of all types", func() {
39+
err := oc.AsAdmin().Run("create").Args("-f", buildFixture).Execute()
40+
o.Expect(err).NotTo(o.HaveOccurred())
41+
42+
err = wait.Poll(time.Second, 30*time.Second, func() (done bool, err error) {
43+
for _, build := range []string{"bc-docker-1", "bc-jenkins-1", "bc-source-1", "bc-custom-1"} {
44+
_, err := oc.BuildClient().Build().Builds(oc.Namespace()).Get(build, metav1.GetOptions{})
45+
if err == nil {
46+
continue
47+
}
48+
if kerrors.IsNotFound(err) {
49+
return false, nil
50+
}
51+
return false, err
52+
}
53+
return true, nil
54+
})
55+
o.Expect(err).NotTo(o.HaveOccurred())
56+
})
57+
})
58+
})

test/extended/testdata/bindata.go

+110
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
kind: List
2+
apiVersion: v1
3+
items:
4+
- kind: ImageStream
5+
apiVersion: v1
6+
metadata:
7+
name: nodejs-ex
8+
spec:
9+
tags:
10+
- name: latest
11+
from:
12+
kind: DockerImage
13+
name: centos/nodejs-6-centos7:latest
14+
15+
- kind: BuildConfig
16+
apiVersion: v1
17+
metadata:
18+
name: bc-source
19+
spec:
20+
source:
21+
type: Git
22+
git:
23+
uri: https://github.com/openshift/nodejs-ex.git
24+
strategy:
25+
type: Source
26+
sourceStrategy:
27+
from:
28+
kind: ImageStreamTag
29+
name: nodejs-ex:latest
30+
triggers:
31+
- type: ImageChange
32+
imageChange:
33+
from:
34+
kind: ImageStreamTag
35+
name: nodejs-ex:latest
36+
37+
- kind: BuildConfig
38+
apiVersion: v1
39+
metadata:
40+
name: bc-docker
41+
spec:
42+
source:
43+
type: Dockerfile
44+
dockerfile: FROM nodejs
45+
strategy:
46+
type: Docker
47+
dockerStrategy:
48+
from:
49+
kind: ImageStreamTag
50+
name: nodejs-ex:latest
51+
triggers:
52+
- type: ImageChange
53+
imageChange:
54+
from:
55+
kind: ImageStreamTag
56+
name: nodejs-ex:latest
57+
58+
- kind: BuildConfig
59+
apiVersion: v1
60+
metadata:
61+
name: bc-custom
62+
spec:
63+
strategy:
64+
type: Custom
65+
customStrategy:
66+
from:
67+
kind: ImageStreamTag
68+
name: nodejs-ex:latest
69+
triggers:
70+
- type: ImageChange
71+
imageChange:
72+
from:
73+
kind: ImageStreamTag
74+
name: nodejs-ex:latest
75+
76+
- kind: BuildConfig
77+
apiVersion: v1
78+
metadata:
79+
name: bc-jenkins
80+
spec:
81+
strategy:
82+
type: Jenkins
83+
jenkinsPipelineStrategy:
84+
jenkinsfile: node {}
85+
triggers:
86+
- type: ImageChange
87+
imageChange:
88+
from:
89+
kind: ImageStreamTag
90+
name: nodejs-ex:latest

0 commit comments

Comments
 (0)