Skip to content

Commit

Permalink
Merge pull request #14720 from coreydaley/github_14390_tests_for_buil…
Browse files Browse the repository at this point in the history
…d_phase_error

Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Jun 18, 2017
2 parents fa750b9 + 3037ae5 commit 04c4ce3
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/extended/builds/build_pruning.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var _ = g.Describe("[builds][pruning] prune builds based on settings in the buil
isFixture = filepath.Join(buildPruningBaseDir, "imagestream.yaml")
successfulBuildConfig = filepath.Join(buildPruningBaseDir, "successful-build-config.yaml")
failedBuildConfig = filepath.Join(buildPruningBaseDir, "failed-build-config.yaml")
erroredBuildConfig = filepath.Join(buildPruningBaseDir, "errored-build-config.yaml")
oc = exutil.NewCLI("build-pruning", exutil.KubeConfigPath())
)

Expand Down Expand Up @@ -119,4 +120,33 @@ var _ = g.Describe("[builds][pruning] prune builds based on settings in the buil
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))

})

g.It("should prune errored builds based on the failedBuildsHistoryLimit setting", func() {

g.By("creating test failed build config")
err := oc.Run("create").Args("-f", erroredBuildConfig).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

g.By("starting three test builds")
br, _ := exutil.StartBuildAndWait(oc, "myphp")
br.AssertFailure()
br, _ = exutil.StartBuildAndWait(oc, "myphp")
br.AssertFailure()
br, _ = exutil.StartBuildAndWait(oc, "myphp")
br.AssertFailure()

buildConfig, err := oc.Client().BuildConfigs(oc.Namespace()).Get("myphp", metav1.GetOptions{})
if err != nil {
fmt.Fprintf(g.GinkgoWriter, "%v", err)
}

builds, err := oc.Client().Builds(oc.Namespace()).List(metav1.ListOptions{})
if err != nil {
fmt.Fprintf(g.GinkgoWriter, "%v", err)
}

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))

})

})
43 changes: 43 additions & 0 deletions test/extended/testdata/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions test/extended/testdata/build-pruning/errored-build-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
kind: BuildConfig
metadata:
name: myphp
spec:
failedBuildsHistoryLimit: 2
source:
type: Git
git:
uri: 'https://github.com/openshift/cakephp-ex.git'
ref: master
strategy:
type: Source
sourceStrategy:
env:
- name: FIELDREF_ENV
valueFrom:
fieldRef:
fieldPath: metadata.nofield
from:
kind: ImageStreamTag
namespace: openshift
name: 'php:7.0'

0 comments on commit 04c4ce3

Please sign in to comment.