Skip to content

Commit

Permalink
Add restoration stopTime (#224)
Browse files Browse the repository at this point in the history
* [FFM-1082] Add restoration stopTime

* FFM-1082 Update unit test for restoration fields

* FFM-1082 Update stopTime

* FFM-1082 Fix values for startTime , stopTime to read from json file

* FFM-1082 Fix error with stopTime does not match
  • Loading branch information
pdoshisplunk authored Aug 29, 2024
1 parent abad07d commit 5391c37
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 5 deletions.
43 changes: 41 additions & 2 deletions metric_ruleset/model_exception_rule_restoration_fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions metric_ruleset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package signalfx

import (
"context"
"net/http"
"testing"

"github.com/signalfx/signalfx-go/metric_ruleset"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
"time"
)

func TestCreateArchivedMetricRuleset(t *testing.T) {
Expand All @@ -16,12 +16,15 @@ func TestCreateArchivedMetricRuleset(t *testing.T) {
mux.HandleFunc(MetricRulesetApiURL, verifyRequest(t, http.MethodPost, true, http.StatusOK, nil, "metric_ruleset/create_archived_ruleset_success.json"))

dest := "Archived"
restorationID := "GWBTAQwAAAA"
metricName := "container_cpu_utilization"
ruleName := "TestRule"
rulesetDescription := "Metric ruleset for container_cpu_utilization"
exceptionRuleDescription := "exception rule 1"
filterNot := false
filterPropertyValue := "container_id"
startTime := (time.Now().Unix() - 900) * 1000
stopTime := (time.Now().Unix() - 200) * 1000
result, err := client.CreateMetricRuleset(context.Background(), &metric_ruleset.CreateMetricRulesetRequest{
MetricName: metricName,
Description: &rulesetDescription,
Expand All @@ -41,6 +44,12 @@ func TestCreateArchivedMetricRuleset(t *testing.T) {
},
},
},
//add restoration
Restoration: &metric_ruleset.ExceptionRuleRestorationFields{
RestorationId: (*string)(&restorationID),
StartTime: &startTime,
StopTime: &stopTime,
},
},
},
RoutingRule: metric_ruleset.RoutingRule{
Expand All @@ -49,6 +58,10 @@ func TestCreateArchivedMetricRuleset(t *testing.T) {
})

assert.NoError(t, err, "Unexpected error creating metric ruleset")
assert.NotNil(t, restorationID, "Restoration ID is null")
assert.Equal(t, restorationID, *result.ExceptionRules[0].Restoration.RestorationId, "Restoration ID does not match")
assert.Equal(t, int64(1724793174572), *result.ExceptionRules[0].Restoration.StartTime, "StartTime does not match")
assert.Equal(t, int64(1724796774661), *result.ExceptionRules[0].Restoration.StopTime, "StopTime does not match")
assert.Equal(t, metricName, *result.MetricName, "MetricName does not match")
assert.Equal(t, rulesetDescription, *result.Description, "Description does not match")
assert.Equal(t, 1, len(result.ExceptionRules), "Unexpected length of exception rules array")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
} ],
"type": "dimension"
},
"restoration" : {
"restorationId" : "GWBTAQwAAAA",
"startTime" : 1724793174572,
"stopTime" : 1724796774661
},
"name": "TestRule",
"description": "exception rule 1"
}
Expand Down

0 comments on commit 5391c37

Please sign in to comment.