mirror of
https://github.com/hanzoai/metrics.git
synced 2026-10-30 20:03:39 +00:00
### Describe Your Changes This PR continues the implementation of integration tests (#7199). It adds the support for vm-single: - A vmsingle app wrapper has been added - Sample vmsingle tests that test the VM documentation related to querying data (#7435) - The tests use the go-cmp/{cmp,/cmpopts} packages, therefore they have been added to ./vendor - Minor refactoring: data objects have been moved to model.go Advice on porting things to cluster branch: - The build rule must include tests that start with TestVmsingle (similarly to how TestCluster tests are skipped in master branch) - The build rule must depend on `vmstorage vminsert vmselect` instead of `victoria-metrics` - The query_test.go can actually be implemented for cluster as well. To do this the tests need to be renamed to start with TestCluster and the tests must instantiace vm{storage,insert,select} instead of vmsingle. ### Checklist The following checks are **mandatory**: - [x] My change adheres [VictoriaMetrics contributing guidelines](https://docs.victoriametrics.com/contributing/). --------- Signed-off-by: Artem Fetishev <[email protected]> Signed-off-by: hagen1778 <[email protected]> Co-authored-by: hagen1778 <[email protected]>
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
// Copyright 2018, The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package cmpopts
|
|
|
|
import (
|
|
"github.com/google/go-cmp/cmp"
|
|
)
|
|
|
|
type xformFilter struct{ xform cmp.Option }
|
|
|
|
func (xf xformFilter) filter(p cmp.Path) bool {
|
|
for _, ps := range p {
|
|
if t, ok := ps.(cmp.Transform); ok && t.Option() == xf.xform {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
// AcyclicTransformer returns a [cmp.Transformer] with a filter applied that ensures
|
|
// that the transformer cannot be recursively applied upon its own output.
|
|
//
|
|
// An example use case is a transformer that splits a string by lines:
|
|
//
|
|
// AcyclicTransformer("SplitLines", func(s string) []string{
|
|
// return strings.Split(s, "\n")
|
|
// })
|
|
//
|
|
// Had this been an unfiltered [cmp.Transformer] instead, this would result in an
|
|
// infinite cycle converting a string to []string to [][]string and so on.
|
|
func AcyclicTransformer(name string, xformFunc interface{}) cmp.Option {
|
|
xf := xformFilter{cmp.Transformer(name, xformFunc)}
|
|
return cmp.FilterPath(xf.filter, xf.xform)
|
|
}
|