Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add restoration stopTime #224

Merged
merged 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
echoi-splk marked this conversation as resolved.
Show resolved Hide resolved
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
Loading