|
|
@ -20,13 +20,13 @@ import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
"reflect"
|
|
|
|
|
|
|
|
"sort"
|
|
|
|
"sort"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/go-kit/log"
|
|
|
|
"github.com/go-kit/log"
|
|
|
|
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
|
|
"github.com/grafana/regexp"
|
|
|
|
"github.com/grafana/regexp"
|
|
|
|
"github.com/nsf/jsondiff"
|
|
|
|
"github.com/nsf/jsondiff"
|
|
|
|
"github.com/prometheus/common/model"
|
|
|
|
"github.com/prometheus/common/model"
|
|
|
@ -340,7 +340,7 @@ func (tg *testGroup) test(evalInterval time.Duration, groupOrderMap map[string]i
|
|
|
|
sort.Sort(gotAlerts)
|
|
|
|
sort.Sort(gotAlerts)
|
|
|
|
sort.Sort(expAlerts)
|
|
|
|
sort.Sort(expAlerts)
|
|
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(expAlerts, gotAlerts) {
|
|
|
|
if !cmp.Equal(expAlerts, gotAlerts, cmp.Comparer(labels.Equal)) {
|
|
|
|
var testName string
|
|
|
|
var testName string
|
|
|
|
if tg.TestGroupName != "" {
|
|
|
|
if tg.TestGroupName != "" {
|
|
|
|
testName = fmt.Sprintf(" name: %s,\n", tg.TestGroupName)
|
|
|
|
testName = fmt.Sprintf(" name: %s,\n", tg.TestGroupName)
|
|
|
@ -448,7 +448,7 @@ Outer:
|
|
|
|
sort.Slice(gotSamples, func(i, j int) bool {
|
|
|
|
sort.Slice(gotSamples, func(i, j int) bool {
|
|
|
|
return labels.Compare(gotSamples[i].Labels, gotSamples[j].Labels) <= 0
|
|
|
|
return labels.Compare(gotSamples[i].Labels, gotSamples[j].Labels) <= 0
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if !reflect.DeepEqual(expSamples, gotSamples) {
|
|
|
|
if !cmp.Equal(expSamples, gotSamples, cmp.Comparer(labels.Equal)) {
|
|
|
|
errs = append(errs, fmt.Errorf(" expr: %q, time: %s,\n exp: %v\n got: %v", testCase.Expr,
|
|
|
|
errs = append(errs, fmt.Errorf(" expr: %q, time: %s,\n exp: %v\n got: %v", testCase.Expr,
|
|
|
|
testCase.EvalTime.String(), parsedSamplesString(expSamples), parsedSamplesString(gotSamples)))
|
|
|
|
testCase.EvalTime.String(), parsedSamplesString(expSamples), parsedSamplesString(gotSamples)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|