Skip to content

Commit

Permalink
Use proto rules API instead of struct; Moved as much as possible to p…
Browse files Browse the repository at this point in the history
…romclient; Added rulesAPI RPC to sidecar. (#2291)

* rules_custom_test: fix asserting labels

Signed-off-by: Sergiusz Urbaniak <sergiusz.urbaniak@gmail.com>

* TestPrometheusStore_Rules_e2e: fix test fixture

Signed-off-by: Sergiusz Urbaniak <sergiusz.urbaniak@gmail.com>
  • Loading branch information
s-urbaniak authored Mar 19, 2020
1 parent 1227553 commit b5f814d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions pkg/store/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,83 +398,83 @@ rule_files:
expected: []storepb.RuleGroup{
{
Name: "thanos-bucket-replicate.rules",
File: "/home/bwplotka/Repos/thanos/pkg/store/../../examples/alerts/alerts.yaml",
File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr),
Rules: []*storepb.Rule{someAlert, someAlert, someAlert},
Interval: 60,
DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN,
},
{
Name: "thanos-compact.rules",
File: "/home/bwplotka/Repos/thanos/pkg/store/../../examples/alerts/alerts.yaml",
File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr),
Rules: []*storepb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert},
Interval: 60,
DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN,
},
{
Name: "thanos-component-absent.rules",
File: "/home/bwplotka/Repos/thanos/pkg/store/../../examples/alerts/alerts.yaml",
File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr),
Rules: []*storepb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert, someAlert},
Interval: 60,
DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN,
},
{
Name: "thanos-query.rules",
File: "/home/bwplotka/Repos/thanos/pkg/store/../../examples/alerts/alerts.yaml",
File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr),
Rules: []*storepb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert, someAlert, someAlert},
Interval: 60,
DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN,
},
{
Name: "thanos-receive.rules",
File: "/home/bwplotka/Repos/thanos/pkg/store/../../examples/alerts/alerts.yaml",
File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr),
Rules: []*storepb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert},
Interval: 60,
DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN,
},
{
Name: "thanos-rule.rules",
File: "/home/bwplotka/Repos/thanos/pkg/store/../../examples/alerts/alerts.yaml",
File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr),
Rules: []*storepb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert, someAlert, someAlert, someAlert, someAlert},
Interval: 60,
DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN,
},
{
Name: "thanos-sidecar.rules",
File: "/home/bwplotka/Repos/thanos/pkg/store/../../examples/alerts/alerts.yaml",
File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr),
Rules: []*storepb.Rule{someAlert, someAlert},
Interval: 60,
DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN,
},
{
Name: "thanos-store.rules",
File: "/home/bwplotka/Repos/thanos/pkg/store/../../examples/alerts/alerts.yaml",
File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr),
Rules: []*storepb.Rule{someAlert, someAlert, someAlert, someAlert},
Interval: 60,
DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN,
},
{
Name: "thanos-bucket-replicate.rules",
File: "/home/bwplotka/Repos/thanos/pkg/store/../../examples/alerts/rules.yaml",
File: fmt.Sprintf("%s/../../examples/alerts/rules.yaml", curr),
Rules: []*storepb.Rule{},
Interval: 60,
DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN,
},
{
Name: "thanos-query.rules",
File: "/home/bwplotka/Repos/thanos/pkg/store/../../examples/alerts/rules.yaml",
File: fmt.Sprintf("%s/../../examples/alerts/rules.yaml", curr),
Rules: []*storepb.Rule{someRecording, someRecording, someRecording, someRecording, someRecording},
Interval: 60,
DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN,
},
{
Name: "thanos-receive.rules", File: "/home/bwplotka/Repos/thanos/pkg/store/../../examples/alerts/rules.yaml",
Name: "thanos-receive.rules", File: fmt.Sprintf("%s/../../examples/alerts/rules.yaml", curr),
Rules: []*storepb.Rule{someRecording, someRecording, someRecording, someRecording, someRecording, someRecording},
Interval: 60,
DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN,
},
{
Name: "thanos-store.rules",
File: "/home/bwplotka/Repos/thanos/pkg/store/../../examples/alerts/rules.yaml",
File: fmt.Sprintf("%s/../../examples/alerts/rules.yaml", curr),
Rules: []*storepb.Rule{someRecording, someRecording, someRecording, someRecording},
Interval: 60,
DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN,
Expand Down
4 changes: 2 additions & 2 deletions pkg/store/storepb/rules_custom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestJSONUnmarshalMarshal(t *testing.T) {
},
},
},
expectedErr: errors.New("rule: no type field provided: {\"name\":\"recording1\",\"query\":\"\",\"health\":\"\",\"evaluationTime\":0,\"lastEvaluation\":\"0001-01-01T00:00:00Z\",\"type\":\"\"}"),
expectedErr: errors.New("rule: no type field provided: {\"name\":\"recording1\",\"query\":\"\",\"labels\":{},\"health\":\"\",\"evaluationTime\":0,\"lastEvaluation\":\"0001-01-01T00:00:00Z\",\"type\":\"\"}"),
},
{
name: "one valid group, with 1 rule with invalid rule type",
Expand All @@ -121,7 +121,7 @@ func TestJSONUnmarshalMarshal(t *testing.T) {
},
},
},
expectedErr: errors.New("rule: unknown type field provided wrong; {\"name\":\"recording1\",\"query\":\"\",\"health\":\"\",\"evaluationTime\":0,\"lastEvaluation\":\"0001-01-01T00:00:00Z\",\"type\":\"wrong\"}"),
expectedErr: errors.New("rule: unknown type field provided wrong; {\"name\":\"recording1\",\"query\":\"\",\"labels\":{},\"health\":\"\",\"evaluationTime\":0,\"lastEvaluation\":\"0001-01-01T00:00:00Z\",\"type\":\"wrong\"}"),
},
{
name: "one valid group, with 1 rule with invalid alert state",
Expand Down

0 comments on commit b5f814d

Please sign in to comment.