2019-07-23 22:35:19 +00:00
|
|
|
package rule_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/influxdata/influxdb/mock"
|
2019-12-31 23:44:27 +00:00
|
|
|
"github.com/influxdata/influxdb/pkg/testing/assert"
|
2019-07-23 22:35:19 +00:00
|
|
|
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
|
|
"github.com/influxdata/influxdb/notification"
|
|
|
|
|
|
|
|
"github.com/influxdata/influxdb"
|
|
|
|
"github.com/influxdata/influxdb/notification/rule"
|
|
|
|
influxTesting "github.com/influxdata/influxdb/testing"
|
|
|
|
)
|
|
|
|
|
2019-08-30 00:46:00 +00:00
|
|
|
func lvlPtr(l notification.CheckLevel) *notification.CheckLevel {
|
|
|
|
return &l
|
|
|
|
}
|
|
|
|
|
2019-07-23 22:35:19 +00:00
|
|
|
const (
|
|
|
|
id1 = "020f755c3c082000"
|
|
|
|
id2 = "020f755c3c082001"
|
|
|
|
id3 = "020f755c3c082002"
|
|
|
|
)
|
|
|
|
|
|
|
|
var goodBase = rule.Base{
|
2019-08-16 19:43:15 +00:00
|
|
|
ID: influxTesting.MustIDBase16(id1),
|
|
|
|
Name: "name1",
|
|
|
|
OwnerID: influxTesting.MustIDBase16(id2),
|
|
|
|
OrgID: influxTesting.MustIDBase16(id3),
|
|
|
|
EndpointID: 1,
|
2019-07-23 22:35:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestValidRule(t *testing.T) {
|
|
|
|
cases := []struct {
|
|
|
|
name string
|
|
|
|
src influxdb.NotificationRule
|
|
|
|
err error
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "invalid rule id",
|
|
|
|
src: &rule.Slack{},
|
|
|
|
err: &influxdb.Error{
|
|
|
|
Code: influxdb.EInvalid,
|
|
|
|
Msg: "Notification Rule ID is invalid",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty name",
|
2019-08-15 23:24:22 +00:00
|
|
|
src: &rule.PagerDuty{
|
2019-07-23 22:35:19 +00:00
|
|
|
Base: rule.Base{
|
|
|
|
ID: influxTesting.MustIDBase16(id1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
err: &influxdb.Error{
|
|
|
|
Code: influxdb.EInvalid,
|
|
|
|
Msg: "Notification Rule Name can't be empty",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invalid auth id",
|
2019-08-15 23:24:22 +00:00
|
|
|
src: &rule.PagerDuty{
|
2019-07-23 22:35:19 +00:00
|
|
|
Base: rule.Base{
|
|
|
|
ID: influxTesting.MustIDBase16(id1),
|
|
|
|
Name: "name1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
err: &influxdb.Error{
|
|
|
|
Code: influxdb.EInvalid,
|
2019-08-15 23:24:22 +00:00
|
|
|
Msg: "Notification Rule OwnerID is invalid",
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invalid org id",
|
|
|
|
src: &rule.PagerDuty{
|
|
|
|
Base: rule.Base{
|
2019-08-15 23:24:22 +00:00
|
|
|
ID: influxTesting.MustIDBase16(id1),
|
|
|
|
Name: "name1",
|
|
|
|
OwnerID: influxTesting.MustIDBase16(id2),
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
err: &influxdb.Error{
|
|
|
|
Code: influxdb.EInvalid,
|
|
|
|
Msg: "Notification Rule OrgID is invalid",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invalid org id",
|
|
|
|
src: &rule.Slack{
|
|
|
|
Base: rule.Base{
|
2019-08-15 23:24:22 +00:00
|
|
|
ID: influxTesting.MustIDBase16(id1),
|
|
|
|
Name: "name1",
|
|
|
|
OwnerID: influxTesting.MustIDBase16(id2),
|
|
|
|
OrgID: influxTesting.MustIDBase16(id3),
|
2019-08-16 19:43:15 +00:00
|
|
|
EndpointID: 0,
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
err: &influxdb.Error{
|
|
|
|
Code: influxdb.EInvalid,
|
|
|
|
Msg: "Notification Rule EndpointID is invalid",
|
|
|
|
},
|
|
|
|
},
|
2019-09-05 15:20:59 +00:00
|
|
|
{
|
|
|
|
name: "offset greater then interval",
|
|
|
|
src: &rule.Slack{
|
|
|
|
Base: rule.Base{
|
|
|
|
ID: influxTesting.MustIDBase16(id1),
|
|
|
|
Name: "name1",
|
|
|
|
OwnerID: influxTesting.MustIDBase16(id2),
|
|
|
|
OrgID: influxTesting.MustIDBase16(id3),
|
|
|
|
EndpointID: 1,
|
|
|
|
Every: mustDuration("1m"),
|
|
|
|
Offset: mustDuration("2m"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
err: &influxdb.Error{
|
|
|
|
Code: influxdb.EInvalid,
|
|
|
|
Msg: "Offset should not be equal or greater than the interval",
|
|
|
|
},
|
|
|
|
},
|
2019-07-23 22:35:19 +00:00
|
|
|
{
|
|
|
|
name: "empty slack message",
|
|
|
|
src: &rule.Slack{
|
|
|
|
Base: goodBase,
|
|
|
|
Channel: "channel1",
|
|
|
|
},
|
|
|
|
err: &influxdb.Error{
|
|
|
|
Code: influxdb.EInvalid,
|
|
|
|
Msg: "slack msg template is empty",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty pagerDuty message",
|
|
|
|
src: &rule.PagerDuty{
|
|
|
|
Base: goodBase,
|
|
|
|
},
|
|
|
|
err: &influxdb.Error{
|
|
|
|
Code: influxdb.EInvalid,
|
|
|
|
Msg: "pagerduty invalid message template",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "bad tag rule",
|
2019-08-15 23:24:22 +00:00
|
|
|
src: &rule.PagerDuty{
|
2019-07-23 22:35:19 +00:00
|
|
|
Base: rule.Base{
|
2019-08-16 19:43:15 +00:00
|
|
|
ID: influxTesting.MustIDBase16(id1),
|
|
|
|
OwnerID: influxTesting.MustIDBase16(id2),
|
|
|
|
Name: "name1",
|
|
|
|
OrgID: influxTesting.MustIDBase16(id3),
|
|
|
|
EndpointID: 1,
|
2019-07-23 22:35:19 +00:00
|
|
|
TagRules: []notification.TagRule{
|
|
|
|
{
|
2019-08-28 16:25:54 +00:00
|
|
|
Tag: influxdb.Tag{
|
2019-07-23 22:35:19 +00:00
|
|
|
Key: "k1",
|
|
|
|
Value: "v1",
|
|
|
|
},
|
2019-10-14 21:33:50 +00:00
|
|
|
Operator: -5,
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-08-27 17:29:49 +00:00
|
|
|
MessageTemplate: "body {var2}",
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
err: &influxdb.Error{
|
|
|
|
Code: influxdb.EInvalid,
|
2019-10-14 21:33:50 +00:00
|
|
|
Msg: `Operator is invalid`,
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "bad limit",
|
2019-08-15 23:24:22 +00:00
|
|
|
src: &rule.PagerDuty{
|
2019-07-23 22:35:19 +00:00
|
|
|
Base: rule.Base{
|
2019-08-16 19:43:15 +00:00
|
|
|
ID: influxTesting.MustIDBase16(id1),
|
|
|
|
OwnerID: influxTesting.MustIDBase16(id2),
|
|
|
|
OrgID: influxTesting.MustIDBase16(id3),
|
|
|
|
EndpointID: 1,
|
|
|
|
Name: "name1",
|
2019-07-23 22:35:19 +00:00
|
|
|
TagRules: []notification.TagRule{
|
|
|
|
{
|
2019-08-28 16:25:54 +00:00
|
|
|
Tag: influxdb.Tag{
|
2019-07-23 22:35:19 +00:00
|
|
|
Key: "k1",
|
|
|
|
Value: "v1",
|
|
|
|
},
|
2019-09-23 16:00:03 +00:00
|
|
|
Operator: influxdb.RegexEqual,
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Limit: &influxdb.Limit{
|
|
|
|
Rate: 3,
|
|
|
|
},
|
|
|
|
},
|
2019-08-27 17:29:49 +00:00
|
|
|
MessageTemplate: "body {var2}",
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
err: &influxdb.Error{
|
|
|
|
Code: influxdb.EInvalid,
|
|
|
|
Msg: `if limit is set, limit and limitEvery must be larger than 0`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, c := range cases {
|
2019-08-16 19:43:15 +00:00
|
|
|
t.Run(c.name, func(t *testing.T) {
|
|
|
|
got := c.src.Valid()
|
|
|
|
influxTesting.ErrorsEqual(t, got, c.err)
|
|
|
|
})
|
2019-07-23 22:35:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var timeGen1 = mock.TimeGenerator{FakeValue: time.Date(2006, time.July, 13, 4, 19, 10, 0, time.UTC)}
|
|
|
|
var timeGen2 = mock.TimeGenerator{FakeValue: time.Date(2006, time.July, 14, 5, 23, 53, 10, time.UTC)}
|
|
|
|
var time3 = time.Date(2006, time.July, 15, 5, 23, 53, 10, time.UTC)
|
|
|
|
|
|
|
|
func TestJSON(t *testing.T) {
|
|
|
|
cases := []struct {
|
|
|
|
name string
|
|
|
|
src influxdb.NotificationRule
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "simple slack",
|
|
|
|
src: &rule.Slack{
|
|
|
|
Base: rule.Base{
|
2019-08-15 23:24:22 +00:00
|
|
|
ID: influxTesting.MustIDBase16(id1),
|
|
|
|
OwnerID: influxTesting.MustIDBase16(id2),
|
|
|
|
Name: "name1",
|
|
|
|
OrgID: influxTesting.MustIDBase16(id3),
|
|
|
|
RunbookLink: "runbooklink1",
|
|
|
|
SleepUntil: &time3,
|
2019-08-16 19:43:15 +00:00
|
|
|
Every: mustDuration("1h"),
|
2019-07-23 22:35:19 +00:00
|
|
|
TagRules: []notification.TagRule{
|
|
|
|
{
|
2019-08-28 16:25:54 +00:00
|
|
|
Tag: influxdb.Tag{
|
2019-07-23 22:35:19 +00:00
|
|
|
Key: "k1",
|
|
|
|
Value: "v1",
|
|
|
|
},
|
2019-09-23 16:00:03 +00:00
|
|
|
Operator: influxdb.NotEqual,
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
{
|
2019-08-28 16:25:54 +00:00
|
|
|
Tag: influxdb.Tag{
|
2019-07-23 22:35:19 +00:00
|
|
|
Key: "k2",
|
|
|
|
Value: "v2",
|
|
|
|
},
|
2019-09-23 16:00:03 +00:00
|
|
|
Operator: influxdb.RegexEqual,
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
CRUDLog: influxdb.CRUDLog{
|
|
|
|
CreatedAt: timeGen1.Now(),
|
|
|
|
UpdatedAt: timeGen2.Now(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Channel: "channel1",
|
|
|
|
MessageTemplate: "msg1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "simple smtp",
|
2019-08-15 23:24:22 +00:00
|
|
|
src: &rule.PagerDuty{
|
2019-07-23 22:35:19 +00:00
|
|
|
Base: rule.Base{
|
2019-08-15 23:24:22 +00:00
|
|
|
ID: influxTesting.MustIDBase16(id1),
|
|
|
|
Name: "name1",
|
|
|
|
OwnerID: influxTesting.MustIDBase16(id2),
|
|
|
|
OrgID: influxTesting.MustIDBase16(id3),
|
|
|
|
RunbookLink: "runbooklink1",
|
|
|
|
SleepUntil: &time3,
|
2019-08-16 19:43:15 +00:00
|
|
|
Every: mustDuration("1h"),
|
2019-07-23 22:35:19 +00:00
|
|
|
TagRules: []notification.TagRule{
|
|
|
|
{
|
2019-08-28 16:25:54 +00:00
|
|
|
Tag: influxdb.Tag{
|
2019-07-23 22:35:19 +00:00
|
|
|
Key: "k1",
|
|
|
|
Value: "v1",
|
|
|
|
},
|
2019-09-23 16:00:03 +00:00
|
|
|
Operator: influxdb.NotEqual,
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
{
|
2019-08-28 16:25:54 +00:00
|
|
|
Tag: influxdb.Tag{
|
2019-07-23 22:35:19 +00:00
|
|
|
Key: "k2",
|
|
|
|
Value: "v2",
|
|
|
|
},
|
2019-09-23 16:00:03 +00:00
|
|
|
Operator: influxdb.RegexEqual,
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
CRUDLog: influxdb.CRUDLog{
|
|
|
|
CreatedAt: timeGen1.Now(),
|
|
|
|
UpdatedAt: timeGen2.Now(),
|
|
|
|
},
|
|
|
|
},
|
2019-08-27 17:29:49 +00:00
|
|
|
MessageTemplate: "msg1",
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "simple pagerDuty",
|
|
|
|
src: &rule.PagerDuty{
|
|
|
|
Base: rule.Base{
|
2019-08-15 23:24:22 +00:00
|
|
|
ID: influxTesting.MustIDBase16(id1),
|
|
|
|
Name: "name1",
|
|
|
|
OwnerID: influxTesting.MustIDBase16(id2),
|
|
|
|
OrgID: influxTesting.MustIDBase16(id3),
|
|
|
|
RunbookLink: "runbooklink1",
|
|
|
|
SleepUntil: &time3,
|
2019-08-16 19:43:15 +00:00
|
|
|
Every: mustDuration("1h"),
|
2019-07-23 22:35:19 +00:00
|
|
|
TagRules: []notification.TagRule{
|
|
|
|
{
|
2019-08-28 16:25:54 +00:00
|
|
|
Tag: influxdb.Tag{
|
2019-07-23 22:35:19 +00:00
|
|
|
Key: "k1",
|
|
|
|
Value: "v1",
|
|
|
|
},
|
2019-09-23 16:00:03 +00:00
|
|
|
Operator: influxdb.NotEqual,
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
StatusRules: []notification.StatusRule{
|
|
|
|
{
|
2019-08-30 00:46:00 +00:00
|
|
|
CurrentLevel: notification.Warn,
|
|
|
|
PreviousLevel: lvlPtr(notification.Critical),
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
{
|
2019-08-30 00:46:00 +00:00
|
|
|
CurrentLevel: notification.Critical,
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
CRUDLog: influxdb.CRUDLog{
|
|
|
|
CreatedAt: timeGen1.Now(),
|
|
|
|
UpdatedAt: timeGen2.Now(),
|
|
|
|
},
|
|
|
|
},
|
2019-08-27 17:29:49 +00:00
|
|
|
MessageTemplate: "msg1",
|
2019-07-23 22:35:19 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, c := range cases {
|
|
|
|
b, err := json.Marshal(c.src)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("%s marshal failed, err: %s", c.name, err.Error())
|
|
|
|
}
|
|
|
|
got, err := rule.UnmarshalJSON(b)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("%s unmarshal failed, err: %s", c.name, err.Error())
|
|
|
|
}
|
|
|
|
if diff := cmp.Diff(got, c.src); diff != "" {
|
|
|
|
t.Errorf("failed %s, notification rule are different -got/+want\ndiff %s", c.name, diff)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-31 23:44:27 +00:00
|
|
|
|
|
|
|
func TestMatchingRules(t *testing.T) {
|
|
|
|
cases := []struct {
|
|
|
|
name string
|
|
|
|
tagRules []notification.TagRule
|
|
|
|
filterTags []influxdb.Tag
|
|
|
|
exp bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "Matches when tagrules and filterTags are the same. ",
|
|
|
|
tagRules: []notification.TagRule{
|
|
|
|
{
|
|
|
|
Tag: influxdb.Tag{
|
|
|
|
Key: "a",
|
|
|
|
Value: "b",
|
|
|
|
},
|
|
|
|
Operator: influxdb.Equal,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Tag: influxdb.Tag{
|
|
|
|
Key: "c",
|
|
|
|
Value: "d",
|
|
|
|
},
|
|
|
|
Operator: influxdb.Equal,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
filterTags: []influxdb.Tag{
|
|
|
|
{Key: "a", Value: "b"},
|
|
|
|
{Key: "c", Value: "d"},
|
|
|
|
},
|
|
|
|
exp: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Matches when tagrules are subset of filterTags. ",
|
|
|
|
tagRules: []notification.TagRule{
|
|
|
|
{
|
|
|
|
Tag: influxdb.Tag{
|
|
|
|
Key: "a",
|
|
|
|
Value: "b",
|
|
|
|
},
|
|
|
|
Operator: influxdb.Equal,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Tag: influxdb.Tag{
|
|
|
|
Key: "c",
|
|
|
|
Value: "d",
|
|
|
|
},
|
|
|
|
Operator: influxdb.Equal,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
filterTags: []influxdb.Tag{
|
|
|
|
{Key: "a", Value: "b"},
|
|
|
|
{Key: "c", Value: "d"},
|
|
|
|
{Key: "e", Value: "f"},
|
|
|
|
},
|
|
|
|
exp: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Does not match when filterTags are missing tags that are in tag rules.",
|
|
|
|
tagRules: []notification.TagRule{
|
|
|
|
{
|
|
|
|
Tag: influxdb.Tag{
|
|
|
|
Key: "a",
|
|
|
|
Value: "b",
|
|
|
|
},
|
|
|
|
Operator: influxdb.Equal,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Tag: influxdb.Tag{
|
|
|
|
Key: "c",
|
|
|
|
Value: "d",
|
|
|
|
},
|
|
|
|
Operator: influxdb.Equal,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
filterTags: []influxdb.Tag{
|
|
|
|
{Key: "a", Value: "b"},
|
|
|
|
},
|
|
|
|
exp: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Does not match when tagrule has key value pair that does not match value of same key in filterTags",
|
|
|
|
tagRules: []notification.TagRule{
|
|
|
|
{
|
|
|
|
Tag: influxdb.Tag{
|
|
|
|
Key: "a",
|
|
|
|
Value: "b",
|
|
|
|
},
|
|
|
|
Operator: influxdb.Equal,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Tag: influxdb.Tag{
|
|
|
|
Key: "c",
|
|
|
|
Value: "d",
|
|
|
|
},
|
|
|
|
Operator: influxdb.Equal,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
filterTags: []influxdb.Tag{
|
|
|
|
{Key: "a", Value: "b"},
|
|
|
|
{Key: "c", Value: "X"},
|
|
|
|
},
|
|
|
|
exp: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Match when tagrule has key value pair that does not match value of same key in filterTags, if tagrule has notEqual operator",
|
|
|
|
tagRules: []notification.TagRule{
|
|
|
|
{
|
|
|
|
Tag: influxdb.Tag{
|
|
|
|
Key: "a",
|
|
|
|
Value: "b",
|
|
|
|
},
|
|
|
|
Operator: influxdb.Equal,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Tag: influxdb.Tag{
|
|
|
|
Key: "c",
|
|
|
|
Value: "d",
|
|
|
|
},
|
|
|
|
Operator: influxdb.NotEqual,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
filterTags: []influxdb.Tag{
|
|
|
|
{Key: "a", Value: "b"},
|
|
|
|
{Key: "c", Value: "X"},
|
|
|
|
},
|
|
|
|
exp: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Empty tag rule matches filterTags",
|
|
|
|
tagRules: []notification.TagRule{},
|
|
|
|
filterTags: []influxdb.Tag{
|
|
|
|
{Key: "a", Value: "b"},
|
|
|
|
{Key: "c", Value: "X"},
|
|
|
|
},
|
|
|
|
exp: true,
|
|
|
|
},
|
2020-01-02 01:01:10 +00:00
|
|
|
{
|
|
|
|
name: "Non empty tag rule matches empty filter tags",
|
|
|
|
tagRules: []notification.TagRule{
|
|
|
|
{
|
|
|
|
Tag: influxdb.Tag{
|
|
|
|
Key: "c",
|
|
|
|
Value: "d",
|
|
|
|
},
|
|
|
|
Operator: influxdb.NotEqual,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
filterTags: []influxdb.Tag{},
|
|
|
|
exp: true,
|
|
|
|
},
|
2019-12-31 23:44:27 +00:00
|
|
|
{
|
|
|
|
name: "Empty tag rule matches empty filter tags",
|
|
|
|
tagRules: []notification.TagRule{},
|
|
|
|
filterTags: []influxdb.Tag{},
|
|
|
|
exp: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, c := range cases {
|
|
|
|
t.Run(c.name, func(t *testing.T) {
|
|
|
|
|
|
|
|
r := rule.Base{TagRules: c.tagRules}
|
|
|
|
|
|
|
|
assert.Equal(t, r.MatchesTags(c.filterTags), c.exp, "expected NR tags to be subset of filterTags")
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|