Skip to content

Commit 04c4ce3

Browse files
author
OpenShift Bot
authored
Merge pull request #14720 from coreydaley/github_14390_tests_for_build_phase_error
Merged by openshift-bot
2 parents fa750b9 + 3037ae5 commit 04c4ce3

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

test/extended/builds/build_pruning.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var _ = g.Describe("[builds][pruning] prune builds based on settings in the buil
1818
isFixture = filepath.Join(buildPruningBaseDir, "imagestream.yaml")
1919
successfulBuildConfig = filepath.Join(buildPruningBaseDir, "successful-build-config.yaml")
2020
failedBuildConfig = filepath.Join(buildPruningBaseDir, "failed-build-config.yaml")
21+
erroredBuildConfig = filepath.Join(buildPruningBaseDir, "errored-build-config.yaml")
2122
oc = exutil.NewCLI("build-pruning", exutil.KubeConfigPath())
2223
)
2324

@@ -119,4 +120,33 @@ var _ = g.Describe("[builds][pruning] prune builds based on settings in the buil
119120
o.Expect(int32(len(builds.Items))).To(o.Equal(*buildConfig.Spec.FailedBuildsHistoryLimit), "there should be %v canceled builds left after pruning, but instead there were %v", *buildConfig.Spec.FailedBuildsHistoryLimit, len(builds.Items))
120121

121122
})
123+
124+
g.It("should prune errored builds based on the failedBuildsHistoryLimit setting", func() {
125+
126+
g.By("creating test failed build config")
127+
err := oc.Run("create").Args("-f", erroredBuildConfig).Execute()
128+
o.Expect(err).NotTo(o.HaveOccurred())
129+
130+
g.By("starting three test builds")
131+
br, _ := exutil.StartBuildAndWait(oc, "myphp")
132+
br.AssertFailure()
133+
br, _ = exutil.StartBuildAndWait(oc, "myphp")
134+
br.AssertFailure()
135+
br, _ = exutil.StartBuildAndWait(oc, "myphp")
136+
br.AssertFailure()
137+
138+
buildConfig, err := oc.Client().BuildConfigs(oc.Namespace()).Get("myphp", metav1.GetOptions{})
139+
if err != nil {
140+
fmt.Fprintf(g.GinkgoWriter, "%v", err)
141+
}
142+
143+
builds, err := oc.Client().Builds(oc.Namespace()).List(metav1.ListOptions{})
144+
if err != nil {
145+
fmt.Fprintf(g.GinkgoWriter, "%v", err)
146+
}
147+
148+
o.Expect(int32(len(builds.Items))).To(o.Equal(*buildConfig.Spec.FailedBuildsHistoryLimit), "there should be %v failed builds left after pruning, but instead there were %v", *buildConfig.Spec.FailedBuildsHistoryLimit, len(builds.Items))
149+
150+
})
151+
122152
})

test/extended/testdata/bindata.go

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: v1
2+
kind: BuildConfig
3+
metadata:
4+
name: myphp
5+
spec:
6+
failedBuildsHistoryLimit: 2
7+
source:
8+
type: Git
9+
git:
10+
uri: 'https://github.com/openshift/cakephp-ex.git'
11+
ref: master
12+
strategy:
13+
type: Source
14+
sourceStrategy:
15+
env:
16+
- name: FIELDREF_ENV
17+
valueFrom:
18+
fieldRef:
19+
fieldPath: metadata.nofield
20+
from:
21+
kind: ImageStreamTag
22+
namespace: openshift
23+
name: 'php:7.0'

0 commit comments

Comments
 (0)