mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-03 16:21:14 +01:00
This commit is contained in:
parent
3e67862676
commit
cf4786f34a
@ -52,6 +52,7 @@ const (
|
||||
|
||||
const (
|
||||
tplWordTime = "{TIME}"
|
||||
tplQuotedWordTime = `"{TIME}"`
|
||||
tplQuotedWordTimeSeconds = `"{TIME_S}"`
|
||||
tplQuotedWordTimeMillis = `"{TIME_MS}"`
|
||||
)
|
||||
@ -66,6 +67,7 @@ type test struct {
|
||||
Data string `json:"data"`
|
||||
Query string `json:"query"`
|
||||
Result []Row `json:"result"`
|
||||
Issue string `json:"issue"`
|
||||
}
|
||||
|
||||
type Row struct {
|
||||
@ -239,7 +241,7 @@ func testRead(t *testing.T) {
|
||||
test := x
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
rowContains(t, httpRead(t, testReadHTTPPath, test.Query), test.Result)
|
||||
rowContains(t, httpRead(t, testReadHTTPPath, test.Query), test.Result, test.Issue)
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -258,6 +260,7 @@ func readIn(readFor string, t *testing.T, timeStr string) []test {
|
||||
s.noError(err)
|
||||
item := test{}
|
||||
s.noError(json.Unmarshal(b, &item))
|
||||
item.Data = strings.Replace(item.Data, tplQuotedWordTime, timeStr, -1)
|
||||
item.Data = strings.Replace(item.Data, tplWordTime, timeStr, -1)
|
||||
tt = append(tt, item)
|
||||
return nil
|
||||
@ -304,13 +307,16 @@ func httpRead(t *testing.T, address, query string) []Row {
|
||||
return rows
|
||||
}
|
||||
|
||||
func rowContains(t *testing.T, rows, contains []Row) {
|
||||
func rowContains(t *testing.T, rows, contains []Row, issue string) {
|
||||
t.Helper()
|
||||
for _, r := range rows {
|
||||
contains = removeIfFound(r, contains)
|
||||
}
|
||||
if len(contains) > 0 {
|
||||
t.Fatalf("result rows %+v not found in %+v", contains, rows)
|
||||
if issue != "" {
|
||||
issue = "Regression in " + issue
|
||||
}
|
||||
t.Fatalf("result rows %+v not found in %+v.%s", contains, rows, issue)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "basic_insertion",
|
||||
"data": "[{\"labels\":[{\"name\":\"__name__\",\"value\":\"prometheus.bar\"},{\"name\":\"baz\",\"value\":\"qux\"}],\"samples\":[{\"value\":100000,\"timestamp\":{TIME}}]}]",
|
||||
"query": "/api/v1/export?match={__name__!=\"\"}",
|
||||
"query": "/api/v1/export?match={__name__!=''}",
|
||||
"result": [
|
||||
{"metric":{"__name__":"prometheus.bar","baz":"qux"},"values":[100000], "timestamps": ["{TIME_MS}"]}
|
||||
]
|
||||
|
10
app/victoria-metrics/testdata/prometheus/case-sensitive-regex.json
vendored
Normal file
10
app/victoria-metrics/testdata/prometheus/case-sensitive-regex.json
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "case-sensitive-regex",
|
||||
"issue": "https://github.com/VictoriaMetrics/VictoriaMetrics/issues/161",
|
||||
"data": "[{\"labels\":[{\"name\":\"__name__\",\"value\":\"prometheus.sensitiveRegex\"},{\"name\":\"label\",\"value\":\"sensitiveRegex\"}],\"samples\":[{\"value\":2,\"timestamp\":\"{TIME}\"}]},{\"labels\":[{\"name\":\"__name__\",\"value\":\"prometheus.sensitiveRegex\"},{\"name\":\"label\",\"value\":\"SensitiveRegex\"}],\"samples\":[{\"value\":1,\"timestamp\":\"{TIME}\"}]}]",
|
||||
"query": "/api/v1/export?match={label=~'(?i)sensitiveregex'}",
|
||||
"result": [
|
||||
{"metric":{"__name__":"prometheus.sensitiveRegex","label":"sensitiveRegex"},"values":[2], "timestamps": ["{TIME_MS}"]},
|
||||
{"metric":{"__name__":"prometheus.sensitiveRegex","label":"SensitiveRegex"},"values":[1], "timestamps": ["{TIME_MS}"]}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user