diff --git a/controllers/flowtest_controller.go b/controllers/flowtest_controller.go index 29801d7..214e725 100644 --- a/controllers/flowtest_controller.go +++ b/controllers/flowtest_controller.go @@ -132,8 +132,8 @@ func (r *FlowTestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c case loggingplumberv1alpha1.Running: fiveMinuteAfterCreation := flowTest.CreationTimestamp.Add(5 * time.Minute) - // Timeout - if time.Now().After(fiveMinuteAfterCreation) { + // Timeout or all test are passing + if time.Now().After(fiveMinuteAfterCreation) || allTestPassing(flowTest.Status) { flowTest.Status.Status = loggingplumberv1alpha1.Completed if err := r.Status().Update(ctx, &flowTest); err != nil { logger.Error(err, "failed to set status as completed") diff --git a/controllers/utils.go b/controllers/utils.go index 3956a9f..2a3156a 100644 --- a/controllers/utils.go +++ b/controllers/utils.go @@ -214,3 +214,17 @@ func GetLabels(name string, flowTest *loggingplumberv1alpha1.FlowTest, labelsMap labels["app.kubernetes.io/managed-by"] = "logging-pipeline-plumber" return labels } + +func allTestPassing(status loggingplumberv1alpha1.FlowTestStatus) bool { + for _, status := range status.MatchStatus { + if !status { + return false + } + } + for _, status := range status.FilterStatus { + if !status { + return false + } + } + return true +}