diff --git a/pkg/rules/rulespb/custom_test.go b/pkg/rules/rulespb/custom_test.go index eacbd4df3c..836075f4df 100644 --- a/pkg/rules/rulespb/custom_test.go +++ b/pkg/rules/rulespb/custom_test.go @@ -57,6 +57,7 @@ func TestJSONUnmarshalMarshal(t *testing.T) { Interval: 2442, LastEvaluation: now, EvaluationDurationSeconds: 2.1, + Limit: 0, PartialResponseStrategy: storepb.PartialResponseStrategy_ABORT, Rules: []*Rule{}, }, @@ -78,7 +79,7 @@ func TestJSONUnmarshalMarshal(t *testing.T) { }, }, // Different than input due to default enum fields. - expectedJSONOutput: `{"groups":[{"name":"","file":"","rules":[],"interval":0,"evaluationTime":0,"lastEvaluation":"0001-01-01T00:00:00Z","partialResponseStrategy":"ABORT"}]}`, + expectedJSONOutput: `{"groups":[{"name":"","file":"","rules":[],"interval":0,"evaluationTime":0,"lastEvaluation":"0001-01-01T00:00:00Z","limit":0,"partialResponseStrategy":"ABORT"}]}`, }, { name: "one valid group, with 1 with no rule type", @@ -230,7 +231,7 @@ func TestJSONUnmarshalMarshal(t *testing.T) { }, }, // Different than input due to the alerts slice being initialized to a zero-length slice instead of nil. - expectedJSONOutput: `{"groups":[{"name":"group1","file":"file1.yml","rules":[{"state":"pending","name":"alert1","query":"up == 0","duration":60,"labels":{"a2":"b2","c2":"d2"},"annotations":{"ann1":"ann44","ann2":"ann33"},"alerts":[],"health":"health2","lastError":"1","evaluationTime":1.1,"lastEvaluation":"0001-01-01T00:00:00Z","type":"alerting"}],"interval":2442,"evaluationTime":2.1,"lastEvaluation":"0001-01-01T00:00:00Z","partialResponseStrategy":"ABORT"}]}`, + expectedJSONOutput: `{"groups":[{"name":"group1","file":"file1.yml","rules":[{"state":"pending","name":"alert1","query":"up == 0","duration":60,"labels":{"a2":"b2","c2":"d2"},"annotations":{"ann1":"ann44","ann2":"ann33"},"alerts":[],"health":"health2","lastError":"1","evaluationTime":1.1,"lastEvaluation":"0001-01-01T00:00:00Z","type":"alerting"}],"interval":2442,"evaluationTime":2.1,"lastEvaluation":"0001-01-01T00:00:00Z","limit":0,"partialResponseStrategy":"ABORT"}]}`, }, { name: "one valid group, with 1 rule and alert each and second empty group.", diff --git a/pkg/testutil/testpromcompatibility/api_compatibility.go b/pkg/testutil/testpromcompatibility/api_compatibility.go index ecf357f8bb..5dde3b53b0 100644 --- a/pkg/testutil/testpromcompatibility/api_compatibility.go +++ b/pkg/testutil/testpromcompatibility/api_compatibility.go @@ -24,6 +24,7 @@ type RuleGroup struct { Interval float64 `json:"interval"` EvaluationTime float64 `json:"evaluationTime"` LastEvaluation time.Time `json:"lastEvaluation"` + Limit int `json:"limit"` PartialResponseStrategy string `json:"partialResponseStrategy"` }