Skip to content

Commit

Permalink
Merge pull request #75 from MrSupiri/issue-71
Browse files Browse the repository at this point in the history
Completes test as soon as all test cases passes
  • Loading branch information
paynejacob authored Aug 23, 2021
2 parents 5b3ff96 + 8667dd3 commit 3f66e84
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions controllers/flowtest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
14 changes: 14 additions & 0 deletions controllers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 3f66e84

Please sign in to comment.