fix: Make policy test non-flaky (#16158)

pull/16166/head
Dylan Guedes 10 months ago committed by GitHub
parent 7e7782e8fd
commit 41d9c8b5ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      pkg/validation/ingestion_policies_test.go

@ -31,7 +31,7 @@ func Test_PolicyStreamMapping_PolicyFor(t *testing.T) {
"policy3": []*PriorityStream{ "policy3": []*PriorityStream{
{ {
Selector: `{qyx="qzx", qox="qox"}`, Selector: `{qyx="qzx", qox="qox"}`,
Priority: 1, Priority: 2,
Matchers: []*labels.Matcher{ Matchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "qyx", "qzx"), labels.MustNewMatcher(labels.MatchEqual, "qyx", "qzx"),
labels.MustNewMatcher(labels.MatchEqual, "qox", "qox"), labels.MustNewMatcher(labels.MatchEqual, "qox", "qox"),
@ -51,7 +51,7 @@ func Test_PolicyStreamMapping_PolicyFor(t *testing.T) {
"policy5": []*PriorityStream{ "policy5": []*PriorityStream{
{ {
Selector: `{qab=~"qzx.*"}`, Selector: `{qab=~"qzx.*"}`,
Priority: 1, Priority: 2,
Matchers: []*labels.Matcher{ Matchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchRegexp, "qab", "qzx.*"), labels.MustNewMatcher(labels.MatchRegexp, "qab", "qzx.*"),
}, },
@ -94,7 +94,7 @@ func Test_PolicyStreamMapping_PolicyFor(t *testing.T) {
require.Equal(t, "policy1", mapping.PolicyFor(labels.FromStrings("foo", "bar"))) require.Equal(t, "policy1", mapping.PolicyFor(labels.FromStrings("foo", "bar")))
// matches both policy2 and policy1 but policy1 has higher priority. // matches both policy2 and policy1 but policy1 has higher priority.
require.Equal(t, "policy1", mapping.PolicyFor(labels.FromStrings("foo", "bar", "daz", "baz"))) require.Equal(t, "policy1", mapping.PolicyFor(labels.FromStrings("foo", "bar", "daz", "baz")))
// matches policy3 and policy4 but policy3 appears first. // matches policy3 and policy4 but policy3 has higher priority..
require.Equal(t, "policy3", mapping.PolicyFor(labels.FromStrings("qyx", "qzx", "qox", "qox"))) require.Equal(t, "policy3", mapping.PolicyFor(labels.FromStrings("qyx", "qzx", "qox", "qox")))
// matches no policy. // matches no policy.
require.Equal(t, "", mapping.PolicyFor(labels.FromStrings("foo", "fooz", "daz", "qux", "quux", "corge"))) require.Equal(t, "", mapping.PolicyFor(labels.FromStrings("foo", "fooz", "daz", "qux", "quux", "corge")))

Loading…
Cancel
Save