Skip to content

Commit bccbe9c

Browse files
Merge pull request #15994 from coreydaley/build_pruning_tests_fix
Automatic merge from submit-queue Fixing build pruning tests Updating tests to look for 2-3 remaining builds based on HandleBuildPruning getting it's information from the cache.
2 parents 971d942 + 21552a0 commit bccbe9c

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

test/extended/builds/build_pruning.go

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import (
1515
exutil "github.com/openshift/origin/test/extended/util"
1616
)
1717

18+
// These build pruning tests create 4 builds and check that 2-3 of them are left after pruning.
19+
// This variation in the number of builds that could be left is caused by the HandleBuildPruning
20+
// function using cached information from the buildLister.
1821
var _ = g.Describe("[builds][pruning] prune builds based on settings in the buildconfig", func() {
1922
var (
2023
buildPruningBaseDir = exutil.FixturePath("testdata", "build-pruning")
@@ -50,8 +53,8 @@ var _ = g.Describe("[builds][pruning] prune builds based on settings in the buil
5053
err := oc.Run("create").Args("-f", successfulBuildConfig).Execute()
5154
o.Expect(err).NotTo(o.HaveOccurred())
5255

53-
g.By("starting three test builds")
54-
for i := 0; i < 3; i++ {
56+
g.By("starting four test builds")
57+
for i := 0; i < 4; i++ {
5558
br, _ := exutil.StartBuildAndWait(oc, "myphp")
5659
br.AssertSuccess()
5760
}
@@ -81,7 +84,11 @@ var _ = g.Describe("[builds][pruning] prune builds based on settings in the buil
8184
fmt.Fprintf(g.GinkgoWriter, "%v", err)
8285
}
8386

84-
o.Expect(int32(len(builds.Items))).To(o.Equal(*buildConfig.Spec.SuccessfulBuildsHistoryLimit), "there should be %v completed builds left after pruning, but instead there were %v", *buildConfig.Spec.SuccessfulBuildsHistoryLimit, len(builds.Items))
87+
passed := false
88+
if int32(len(builds.Items)) == 2 || int32(len(builds.Items)) == 3 {
89+
passed = true
90+
}
91+
o.Expect(passed).To(o.BeTrue(), "there should be 2-3 completed builds left after pruning, but instead there were %v", len(builds.Items))
8592

8693
})
8794

@@ -91,8 +98,8 @@ var _ = g.Describe("[builds][pruning] prune builds based on settings in the buil
9198
err := oc.Run("create").Args("-f", failedBuildConfig).Execute()
9299
o.Expect(err).NotTo(o.HaveOccurred())
93100

94-
g.By("starting three test builds")
95-
for i := 0; i < 3; i++ {
101+
g.By("starting four test builds")
102+
for i := 0; i < 4; i++ {
96103
br, _ := exutil.StartBuildAndWait(oc, "myphp")
97104
br.AssertFailure()
98105
}
@@ -122,7 +129,11 @@ var _ = g.Describe("[builds][pruning] prune builds based on settings in the buil
122129
fmt.Fprintf(g.GinkgoWriter, "%v", err)
123130
}
124131

125-
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))
132+
passed := false
133+
if int32(len(builds.Items)) == 2 || int32(len(builds.Items)) == 3 {
134+
passed = true
135+
}
136+
o.Expect(passed).To(o.BeTrue(), "there should be 2-3 completed builds left after pruning, but instead there were %v", len(builds.Items))
126137

127138
})
128139

@@ -163,7 +174,11 @@ var _ = g.Describe("[builds][pruning] prune builds based on settings in the buil
163174
fmt.Fprintf(g.GinkgoWriter, "%v", err)
164175
}
165176

166-
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))
177+
passed := false
178+
if int32(len(builds.Items)) == 2 || int32(len(builds.Items)) == 3 {
179+
passed = true
180+
}
181+
o.Expect(passed).To(o.BeTrue(), "there should be 2-3 completed builds left after pruning, but instead there were %v", len(builds.Items))
167182

168183
})
169184

@@ -173,8 +188,8 @@ var _ = g.Describe("[builds][pruning] prune builds based on settings in the buil
173188
err := oc.Run("create").Args("-f", erroredBuildConfig).Execute()
174189
o.Expect(err).NotTo(o.HaveOccurred())
175190

176-
g.By("starting three test builds")
177-
for i := 0; i < 3; i++ {
191+
g.By("starting four test builds")
192+
for i := 0; i < 4; i++ {
178193
br, _ := exutil.StartBuildAndWait(oc, "myphp")
179194
br.AssertFailure()
180195
}
@@ -204,7 +219,11 @@ var _ = g.Describe("[builds][pruning] prune builds based on settings in the buil
204219
fmt.Fprintf(g.GinkgoWriter, "%v", err)
205220
}
206221

207-
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))
222+
passed := false
223+
if int32(len(builds.Items)) == 2 || int32(len(builds.Items)) == 3 {
224+
passed = true
225+
}
226+
o.Expect(passed).To(o.BeTrue(), "there should be 2-3 completed builds left after pruning, but instead there were %v", len(builds.Items))
208227

209228
})
210229

0 commit comments

Comments
 (0)