Support UTF-8 label matchers: Update compliance tests (#3569)
* Update compliance tests This commit updates compliance tests to include openmetrics escape sequences that are not valid in the UTF-8 matchers parser. Signed-off-by: George Robinson <george.robinson@grafana.com> * Add tests for openmetrics escape sequences Signed-off-by: George Robinson <george.robinson@grafana.com> --------- Signed-off-by: George Robinson <george.robinson@grafana.com>
This commit is contained in:
parent
d2501323d2
commit
8512285e54
|
@ -52,7 +52,58 @@ func TestCompliance(t *testing.T) {
|
|||
skip: true,
|
||||
},
|
||||
{
|
||||
input: "{foo=\\\"}",
|
||||
input: `{foo=\n}`,
|
||||
want: func() labels.Matchers {
|
||||
ms := labels.Matchers{}
|
||||
m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "\n")
|
||||
return append(ms, m)
|
||||
}(),
|
||||
skip: true,
|
||||
},
|
||||
{
|
||||
input: `{foo=bar\n}`,
|
||||
want: func() labels.Matchers {
|
||||
ms := labels.Matchers{}
|
||||
m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "bar\n")
|
||||
return append(ms, m)
|
||||
}(),
|
||||
skip: true,
|
||||
},
|
||||
{
|
||||
input: `{foo=\t}`,
|
||||
want: func() labels.Matchers {
|
||||
ms := labels.Matchers{}
|
||||
m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "\\t")
|
||||
return append(ms, m)
|
||||
}(),
|
||||
},
|
||||
{
|
||||
input: `{foo=bar\t}`,
|
||||
want: func() labels.Matchers {
|
||||
ms := labels.Matchers{}
|
||||
m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "bar\\t")
|
||||
return append(ms, m)
|
||||
}(),
|
||||
},
|
||||
{
|
||||
input: `{foo=bar\}`,
|
||||
want: func() labels.Matchers {
|
||||
ms := labels.Matchers{}
|
||||
m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "bar\\")
|
||||
return append(ms, m)
|
||||
}(),
|
||||
},
|
||||
{
|
||||
input: `{foo=bar\\}`,
|
||||
want: func() labels.Matchers {
|
||||
ms := labels.Matchers{}
|
||||
m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "bar\\")
|
||||
return append(ms, m)
|
||||
}(),
|
||||
skip: true,
|
||||
},
|
||||
{
|
||||
input: `{foo=\"}`,
|
||||
want: func() labels.Matchers {
|
||||
ms := labels.Matchers{}
|
||||
m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "\"")
|
||||
|
@ -60,6 +111,15 @@ func TestCompliance(t *testing.T) {
|
|||
}(),
|
||||
skip: true,
|
||||
},
|
||||
{
|
||||
input: `{foo=bar\"}`,
|
||||
want: func() labels.Matchers {
|
||||
ms := labels.Matchers{}
|
||||
m, _ := labels.NewMatcher(labels.MatchEqual, "foo", "bar\"")
|
||||
return append(ms, m)
|
||||
}(),
|
||||
skip: true,
|
||||
},
|
||||
{
|
||||
input: `{foo=bar}`,
|
||||
want: func() labels.Matchers {
|
||||
|
@ -386,7 +446,7 @@ func TestCompliance(t *testing.T) {
|
|||
t.Fatalf("expected error but got none: %v", tc.err)
|
||||
}
|
||||
if !reflect.DeepEqual(got, tc.want) {
|
||||
t.Fatalf("labels not equal:\ngot %#v\nwant %#v", got, tc.want)
|
||||
t.Fatalf("matchers not equal:\ngot %s\nwant %s", got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -298,6 +298,30 @@ func TestMatchers(t *testing.T) {
|
|||
return append(ms, m)
|
||||
}(),
|
||||
},
|
||||
{
|
||||
input: `{foo=bar\}`,
|
||||
want: func() []*Matcher {
|
||||
ms := []*Matcher{}
|
||||
m, _ := NewMatcher(MatchEqual, "foo", "bar\\")
|
||||
return append(ms, m)
|
||||
}(),
|
||||
},
|
||||
{
|
||||
input: `{foo=bar\\}`,
|
||||
want: func() []*Matcher {
|
||||
ms := []*Matcher{}
|
||||
m, _ := NewMatcher(MatchEqual, "foo", "bar\\")
|
||||
return append(ms, m)
|
||||
}(),
|
||||
},
|
||||
{
|
||||
input: `{foo=bar\"}`,
|
||||
want: func() []*Matcher {
|
||||
ms := []*Matcher{}
|
||||
m, _ := NewMatcher(MatchEqual, "foo", "bar\"")
|
||||
return append(ms, m)
|
||||
}(),
|
||||
},
|
||||
{
|
||||
input: `job=`,
|
||||
want: func() []*Matcher {
|
||||
|
|
Loading…
Reference in New Issue