Skip to content

Commit

Permalink
fix(datadog): allow empty datadog result. Fixes argoproj#1548
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan M Smith <[email protected]>
  • Loading branch information
rms1000watt committed Sep 28, 2021
1 parent 20b0274 commit b3da408
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions metricproviders/datadog/datadog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ func TestRunSuite(t *testing.T) {
webServerResponse: `{"status":"ok","series":[{"pointlist":[]}]}`,
metric: v1alpha1.Metric{
Name: "foo",
SuccessCondition: "resultPointer == nil",
FailureCondition: "result >= 0.05",
SuccessCondition: "resultPointer == nil || result < 0.05",
Provider: v1alpha1.MetricProvider{
Datadog: &v1alpha1.DatadogMetric{
Query: "avg:kubernetes.cpu.user.total{*}",
Expand All @@ -155,6 +154,25 @@ func TestRunSuite(t *testing.T) {
useEnvVarForKeys: false,
},

// Validate nil pointer logic
{
webServerStatus: 200,
webServerResponse: `{"status":"ok","series":[{"pointlist":[]}]}`,
metric: v1alpha1.Metric{
Name: "foo",
SuccessCondition: "resultPointer != nil && result < 0.05",
Provider: v1alpha1.MetricProvider{
Datadog: &v1alpha1.DatadogMetric{
Query: "avg:kubernetes.cpu.user.total{*}",
},
},
},
expectedIntervalSeconds: 300,
expectedValue: "0",
expectedPhase: v1alpha1.AnalysisPhaseFailed,
useEnvVarForKeys: false,
},

// Implicitly succeed if no datapoints are returned
{
webServerStatus: 200,
Expand Down

0 comments on commit b3da408

Please sign in to comment.