From 77dd06bc5ef9ae82495283f1af9b42bdae9bffee Mon Sep 17 00:00:00 2001 From: Johnny Steenbergen Date: Wed, 1 Jan 2020 17:01:10 -0800 Subject: [PATCH] =?UTF-8?q?fix:=20enable=20skipped=20tests=20for=20notific?= =?UTF-8?q?ation=20rules=20and=20fixup=20issue=20in=20t=EF=9C=88ag=20match?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + kv/notification_rule.go | 4 +--- kv/notification_rule_test.go | 1 - notification/rule/rule.go | 4 +++- notification/rule/rule_test.go | 14 ++++++++++++++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e37a6db7a..b8be99326f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ 1. [16268](https://github.com/influxdata/influxdb/pull/16268): Fixed test flakiness that stemmed from multiple flush/signins being called in the same test suite 1. [16346](https://github.com/influxdata/influxdb/pull/16346): Update pkger task export to only trim out option task and not all vars provided 1. [16374](https://github.com/influxdata/influxdb/pull/16374): Update influx CLI, only show "see help" message, instead of the whole usage. +1. [16380](https://github.com/influxdata/influxdb/pull/16380): Fix notification tag matching rules and enable tests to verify ### UI Improvements diff --git a/kv/notification_rule.go b/kv/notification_rule.go index d4c3f4a06f..deadfb7b22 100644 --- a/kv/notification_rule.go +++ b/kv/notification_rule.go @@ -435,9 +435,7 @@ func (s *Service) forEachNotificationRule(ctx context.Context, tx Tx, descending return nil } -func filterNotificationRulesFn( - idMap map[influxdb.ID]bool, - filter influxdb.NotificationRuleFilter) func(nr influxdb.NotificationRule) bool { +func filterNotificationRulesFn(idMap map[influxdb.ID]bool, filter influxdb.NotificationRuleFilter) func(nr influxdb.NotificationRule) bool { if filter.OrgID != nil { return func(nr influxdb.NotificationRule) bool { if !nr.MatchesTags(filter.Tags) { diff --git a/kv/notification_rule_test.go b/kv/notification_rule_test.go index 870d578fe2..667e83cc87 100644 --- a/kv/notification_rule_test.go +++ b/kv/notification_rule_test.go @@ -11,7 +11,6 @@ import ( ) func TestBoltNotificationRuleStore(t *testing.T) { - t.Skip("https://github.com/influxdata/influxdb/issues/14799") influxdbtesting.NotificationRuleStore(initBoltNotificationRuleStore, t) } diff --git a/notification/rule/rule.go b/notification/rule/rule.go index ae892cff37..488005e428 100644 --- a/notification/rule/rule.go +++ b/notification/rule/rule.go @@ -337,7 +337,9 @@ func (b *Base) ClearPrivateData() { // MatchesTags returns true if the Rule matches all of the tags func (b *Base) MatchesTags(tags []influxdb.Tag) bool { - + if len(tags) == 0 { + return true + } // for each tag in NR // if there exists // a key value match with operator == equal in tags diff --git a/notification/rule/rule_test.go b/notification/rule/rule_test.go index 4c927c6d26..479a9d1257 100644 --- a/notification/rule/rule_test.go +++ b/notification/rule/rule_test.go @@ -475,6 +475,20 @@ func TestMatchingRules(t *testing.T) { }, exp: true, }, + { + 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, + }, { name: "Empty tag rule matches empty filter tags", tagRules: []notification.TagRule{},