Skip to content

Commit

Permalink
fix: enable skipped tests for notification rules and fixup issue in t…
Browse files Browse the repository at this point in the history
…ag matcher
  • Loading branch information
jsteenb2 committed Jan 2, 2020
1 parent 219d73b commit 62c75ce
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,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

Expand Down
4 changes: 1 addition & 3 deletions kv/notification_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion kv/notification_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
)

func TestBoltNotificationRuleStore(t *testing.T) {
t.Skip("https://github.com/influxdata/influxdb/issues/14799")
influxdbtesting.NotificationRuleStore(initBoltNotificationRuleStore, t)
}

Expand Down
28 changes: 14 additions & 14 deletions notification/rule/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,28 +337,28 @@ func (b *Base) ClearPrivateData() {

// MatchesTags returns true if the Rule matches all of the tags
func (b *Base) MatchesTags(tags []influxdb.Tag) bool {

// for each tag in NR
// if there exists
// a key value match with operator == equal in tags
// or
// a key match with a value mismatch with operator == notequal in tags
// then true

for _, NRtag := range b.TagRules {
isNRTagInFilterTags := false

for _, filterTag := range tags {
if NRtag.Key == filterTag.Key {
if NRtag.Operator == influxdb.Equal && NRtag.Value == filterTag.Value {
isNRTagInFilterTags = true
}
if NRtag.Operator == influxdb.NotEqual && NRtag.Value != filterTag.Value {
isNRTagInFilterTags = true
}
}
// TODO(jsteenb2): understand the comment above
mTagRules := make(map[string]notification.TagRule)
for _, tag := range b.TagRules {
mTagRules[tag.Key] = tag
}

for _, tag := range tags {
nTag, ok := mTagRules[tag.Key]
if !ok {
return false
}
if nTag.Operator == influxdb.Equal && nTag.Value != tag.Value {
return false
}
if !isNRTagInFilterTags {
if nTag.Operator == influxdb.NotEqual && nTag.Value == tag.Value {
return false
}
}
Expand Down

0 comments on commit 62c75ce

Please sign in to comment.