Skip to content

Commit

Permalink
fix(analysis): Fix Analysis Terminal Decision For Dry-Run Metrics (ar…
Browse files Browse the repository at this point in the history
…goproj#2399)

Signed-off-by: Rohit Agrawal <[email protected]>

Signed-off-by: Rohit Agrawal <[email protected]>
  • Loading branch information
agrawroh authored and jandersen-plaid committed Nov 26, 2022
1 parent c5399f9 commit 9837f92
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 7 additions & 3 deletions utils/analysis/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,15 @@ func IsTerminating(run *v1alpha1.AnalysisRun) bool {
return true
}
for _, res := range run.Status.MetricResults {
// If this metric is running in the dryRun mode then we don't care about the failures and hence the terminal
// decision shouldn't be affected.
if res.DryRun {
continue
}

switch res.Phase {
case v1alpha1.AnalysisPhaseFailed, v1alpha1.AnalysisPhaseError, v1alpha1.AnalysisPhaseInconclusive:
// If this metric is running in the dryRun mode then we don't care about the failures and hence the terminal
// decision shouldn't be affected.
return !res.DryRun
return true
}
}
return false
Expand Down
9 changes: 9 additions & 0 deletions utils/analysis/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func TestIsFastFailTerminating(t *testing.T) {
Phase: v1alpha1.AnalysisPhaseRunning,
DryRun: true,
},
{
Name: "yet-another-metric",
Phase: v1alpha1.AnalysisPhaseRunning,
},
},
},
}
Expand All @@ -78,6 +82,11 @@ func TestIsFastFailTerminating(t *testing.T) {
dryRunMetricResult.Phase = v1alpha1.AnalysisPhaseError
run.Status.MetricResults[2] = dryRunMetricResult
assert.False(t, IsTerminating(run))
// Verify that a wet run metric failure/error which is executed after a dry-run metric results in terminal decision.
yetAnotherMetric := run.Status.MetricResults[3]
yetAnotherMetric.Phase = v1alpha1.AnalysisPhaseError
run.Status.MetricResults[3] = yetAnotherMetric
assert.True(t, IsTerminating(run))
// Verify that a wet run metric failure/error results in terminal decision.
successRate.Phase = v1alpha1.AnalysisPhaseError
run.Status.MetricResults[1] = successRate
Expand Down

0 comments on commit 9837f92

Please sign in to comment.