@@ -240,6 +240,57 @@ var _ = g.Describe("[Feature:Builds][pruning] prune builds based on settings in
240
240
241
241
})
242
242
243
+ g .It ("should prune builds after a buildConfig change" , func () {
244
+
245
+ g .By ("creating test failed build config" )
246
+ err := oc .Run ("create" ).Args ("-f" , failedBuildConfig ).Execute ()
247
+ o .Expect (err ).NotTo (o .HaveOccurred ())
248
+
249
+ g .By ("patching the build config to leave 5 builds" )
250
+ err = oc .Run ("patch" ).Args ("bc/myphp" , "-p" , `{"spec":{"failedBuildsHistoryLimit": 5}}` ).Execute ()
251
+
252
+ g .By ("starting and canceling three test builds" )
253
+ for i := 1 ; i < 4 ; i ++ {
254
+ _ , _ , _ = exutil .StartBuild (oc , "myphp" )
255
+ err = oc .Run ("cancel-build" ).Args (fmt .Sprintf ("myphp-%d" , i )).Execute ()
256
+ }
257
+
258
+ g .By ("patching the build config to leave 1 build" )
259
+ err = oc .Run ("patch" ).Args ("bc/myphp" , "-p" , `{"spec":{"failedBuildsHistoryLimit": 1}}` ).Execute ()
260
+
261
+ buildConfig , err := oc .BuildClient ().Build ().BuildConfigs (oc .Namespace ()).Get ("myphp" , metav1.GetOptions {})
262
+ if err != nil {
263
+ fmt .Fprintf (g .GinkgoWriter , "%v" , err )
264
+ }
265
+
266
+ var builds * buildapi.BuildList
267
+
268
+ g .By ("waiting up to one minute for pruning to complete" )
269
+ err = wait .PollImmediate (pollingInterval , timeout , func () (bool , error ) {
270
+ builds , err = oc .BuildClient ().Build ().Builds (oc .Namespace ()).List (metav1.ListOptions {})
271
+ if err != nil {
272
+ fmt .Fprintf (g .GinkgoWriter , "%v" , err )
273
+ return false , err
274
+ }
275
+ if int32 (len (builds .Items )) == * buildConfig .Spec .FailedBuildsHistoryLimit {
276
+ fmt .Fprintf (g .GinkgoWriter , "%v builds exist, retrying..." , len (builds .Items ))
277
+ return true , nil
278
+ }
279
+ return false , nil
280
+ })
281
+
282
+ if err != nil {
283
+ fmt .Fprintf (g .GinkgoWriter , "%v" , err )
284
+ }
285
+
286
+ passed := false
287
+ if int32 (len (builds .Items )) == 1 || int32 (len (builds .Items )) == 2 {
288
+ passed = true
289
+ }
290
+ o .Expect (passed ).To (o .BeTrue (), "there should be 1-2 completed builds left after pruning, but instead there were %v" , len (builds .Items ))
291
+
292
+ })
293
+
243
294
g .It ("[Conformance] buildconfigs should have a default history limit set when created via the group api" , func () {
244
295
245
296
g .By ("creating a build config with the group api" )
0 commit comments