mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 08:36:55 +03:00
ci: golangci-lint 1.6.x -> 2.2.1
This commit is contained in:
committed by
Max Kotliar
parent
336e4abc5c
commit
db39f045e1
@@ -1,22 +1,29 @@
|
|||||||
run:
|
version: "2"
|
||||||
timeout: 2m
|
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
enable:
|
settings:
|
||||||
- revive
|
errcheck:
|
||||||
|
exclude-functions:
|
||||||
issues:
|
- fmt.Fprintf
|
||||||
exclude-rules:
|
- fmt.Fprint
|
||||||
- linters:
|
- (net/http.ResponseWriter).Write
|
||||||
- staticcheck
|
exclusions:
|
||||||
text: "SA(4003|1019|5011):"
|
generated: lax
|
||||||
include:
|
presets:
|
||||||
- EXC0012
|
- common-false-positives
|
||||||
- EXC0014
|
- legacy
|
||||||
|
- std-error-handling
|
||||||
linters-settings:
|
rules:
|
||||||
errcheck:
|
- linters:
|
||||||
exclude-functions:
|
- staticcheck
|
||||||
- "fmt.Fprintf"
|
text: 'SA(4003|1019|5011):'
|
||||||
- "fmt.Fprint"
|
paths:
|
||||||
- "(net/http.ResponseWriter).Write"
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
formatters:
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -16,6 +16,8 @@ EXTRA_DOCKER_TAG_SUFFIX ?= EXTRA_DOCKER_TAG_SUFFIX
|
|||||||
GO_BUILDINFO = -X '$(PKG_PREFIX)/lib/buildinfo.Version=$(APP_NAME)-$(DATEINFO_TAG)-$(BUILDINFO_TAG)'
|
GO_BUILDINFO = -X '$(PKG_PREFIX)/lib/buildinfo.Version=$(APP_NAME)-$(DATEINFO_TAG)-$(BUILDINFO_TAG)'
|
||||||
TAR_OWNERSHIP ?= --owner=1000 --group=1000
|
TAR_OWNERSHIP ?= --owner=1000 --group=1000
|
||||||
|
|
||||||
|
GOLANGCI_LINT_VERSION := 2.2.1
|
||||||
|
|
||||||
.PHONY: $(MAKECMDGOALS)
|
.PHONY: $(MAKECMDGOALS)
|
||||||
|
|
||||||
include app/*/Makefile
|
include app/*/Makefile
|
||||||
@@ -612,7 +614,7 @@ golangci-lint: install-golangci-lint
|
|||||||
GOEXPERIMENT=synctest golangci-lint run
|
GOEXPERIMENT=synctest golangci-lint run
|
||||||
|
|
||||||
install-golangci-lint:
|
install-golangci-lint:
|
||||||
which golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.64.7
|
which golangci-lint && (golangci-lint --version | grep -q $(GOLANGCI_LINT_VERSION)) || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v$(GOLANGCI_LINT_VERSION)
|
||||||
|
|
||||||
remove-golangci-lint:
|
remove-golangci-lint:
|
||||||
rm -rf `which golangci-lint`
|
rm -rf `which golangci-lint`
|
||||||
|
|||||||
@@ -448,7 +448,8 @@ again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
metrics.GetOrCreateCounter(fmt.Sprintf(`vmagent_remotewrite_requests_total{url=%q, status_code="%d"}`, c.sanitizedURL, statusCode)).Inc()
|
metrics.GetOrCreateCounter(fmt.Sprintf(`vmagent_remotewrite_requests_total{url=%q, status_code="%d"}`, c.sanitizedURL, statusCode)).Inc()
|
||||||
if statusCode == 409 {
|
switch statusCode {
|
||||||
|
case 409:
|
||||||
logBlockRejected(block, c.sanitizedURL, resp)
|
logBlockRejected(block, c.sanitizedURL, resp)
|
||||||
|
|
||||||
// Just drop block on 409 status code like Prometheus does.
|
// Just drop block on 409 status code like Prometheus does.
|
||||||
@@ -461,7 +462,13 @@ again:
|
|||||||
// - Remote Write v2 specification explicitly specifies a `415 Unsupported Media Type` for unsupported encodings.
|
// - Remote Write v2 specification explicitly specifies a `415 Unsupported Media Type` for unsupported encodings.
|
||||||
// - Real-world implementations of v1 use both 400 and 415 status codes.
|
// - Real-world implementations of v1 use both 400 and 415 status codes.
|
||||||
// See more in research: https://github.com/VictoriaMetrics/VictoriaMetrics/pull/8462#issuecomment-2786918054
|
// See more in research: https://github.com/VictoriaMetrics/VictoriaMetrics/pull/8462#issuecomment-2786918054
|
||||||
} else if statusCode == 415 || statusCode == 400 {
|
case 415, 400:
|
||||||
|
if c.canDowngradeVMProto.Swap(false) {
|
||||||
|
logger.Infof("received unsupported media type or bad request from remote storage at %q. Downgrading protocol from VictoriaMetrics to Prometheus remote write for all future requests. "+
|
||||||
|
"See https://docs.victoriametrics.com/victoriametrics/vmagent/#victoriametrics-remote-write-protocol", c.sanitizedURL)
|
||||||
|
c.useVMProto.Store(false)
|
||||||
|
}
|
||||||
|
|
||||||
if encoding.IsZstd(block) {
|
if encoding.IsZstd(block) {
|
||||||
logger.Infof("received unsupported media type or bad request from remote storage at %q. Re-packing the block to Prometheus remote write and retrying."+
|
logger.Infof("received unsupported media type or bad request from remote storage at %q. Re-packing the block to Prometheus remote write and retrying."+
|
||||||
"See https://docs.victoriametrics.com/victoriametrics/vmagent/#victoriametrics-remote-write-protocol", c.sanitizedURL)
|
"See https://docs.victoriametrics.com/victoriametrics/vmagent/#victoriametrics-remote-write-protocol", c.sanitizedURL)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func TestCalculateRetryDuration(t *testing.T) {
|
|||||||
expectMaxDuration := helper(expectMinDuration)
|
expectMaxDuration := helper(expectMinDuration)
|
||||||
expectMinDuration = expectMinDuration - (1000 * time.Millisecond) // Avoid edge case when calculating time.Until(now)
|
expectMinDuration = expectMinDuration - (1000 * time.Millisecond) // Avoid edge case when calculating time.Until(now)
|
||||||
|
|
||||||
if !(retryDuration >= expectMinDuration && retryDuration <= expectMaxDuration) {
|
if retryDuration < expectMinDuration || retryDuration > expectMaxDuration {
|
||||||
t.Fatalf(
|
t.Fatalf(
|
||||||
"incorrect retry duration, want (ms): [%d, %d], got (ms): %d",
|
"incorrect retry duration, want (ms): [%d, %d], got (ms): %d",
|
||||||
expectMinDuration.Milliseconds(), expectMaxDuration.Milliseconds(),
|
expectMinDuration.Milliseconds(), expectMaxDuration.Milliseconds(),
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import (
|
|||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/config"
|
|
||||||
vmalertconfig "github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/config"
|
vmalertconfig "github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/config"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/datasource"
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/datasource"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/notifier"
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/notifier"
|
||||||
@@ -112,7 +111,7 @@ func UnitTest(files []string, disableGroupLabel bool, externalLabels []string, e
|
|||||||
defer vmselect.Stop()
|
defer vmselect.Stop()
|
||||||
disableAlertgroupLabel = disableGroupLabel
|
disableAlertgroupLabel = disableGroupLabel
|
||||||
|
|
||||||
testfiles, err := config.ReadFromFS(files)
|
testfiles, err := vmalertconfig.ReadFromFS(files)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Fatalf("failed to load test files %q: %v", files, err)
|
logger.Fatalf("failed to load test files %q: %v", files, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ func (cw *configWatcher) updateTargets(key TargetType, targetMetadata map[string
|
|||||||
for _, ot := range oldTargets {
|
for _, ot := range oldTargets {
|
||||||
if _, ok := targetMetadata[ot.Addr()]; !ok {
|
if _, ok := targetMetadata[ot.Addr()]; !ok {
|
||||||
// if target not exists in currentTargets, close it
|
// if target not exists in currentTargets, close it
|
||||||
ot.Notifier.Close()
|
ot.Close()
|
||||||
} else {
|
} else {
|
||||||
updatedTargets = append(updatedTargets, ot)
|
updatedTargets = append(updatedTargets, ot)
|
||||||
delete(targetMetadata, ot.Addr())
|
delete(targetMetadata, ot.Addr())
|
||||||
|
|||||||
@@ -459,7 +459,7 @@ func (rh *requestHandler) listNotifiers() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
for _, target := range protoTargets {
|
for _, target := range protoTargets {
|
||||||
notifier.Targets = append(notifier.Targets, &apiTarget{
|
notifier.Targets = append(notifier.Targets, &apiTarget{
|
||||||
Address: target.Notifier.Addr(),
|
Address: target.Addr(),
|
||||||
Labels: target.Labels.ToMap(),
|
Labels: target.Labels.ToMap(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ func SplitDateRange(start, end time.Time, step string, timeReverse bool) ([][]ti
|
|||||||
case StepMonth:
|
case StepMonth:
|
||||||
nextStep = func(t time.Time) (time.Time, time.Time) {
|
nextStep = func(t time.Time) (time.Time, time.Time) {
|
||||||
endOfMonth := time.Date(t.Year(), t.Month()+1, 1, 0, 0, 0, 0, t.Location()).Add(-1 * time.Nanosecond)
|
endOfMonth := time.Date(t.Year(), t.Month()+1, 1, 0, 0, 0, 0, t.Location()).Add(-1 * time.Nanosecond)
|
||||||
if t == endOfMonth {
|
if t.Equal(endOfMonth) {
|
||||||
endOfMonth = time.Date(t.Year(), t.Month()+2, 1, 0, 0, 0, 0, t.Location()).Add(-1 * time.Nanosecond)
|
endOfMonth = time.Date(t.Year(), t.Month()+2, 1, 0, 0, 0, 0, t.Location()).Add(-1 * time.Nanosecond)
|
||||||
t = time.Date(t.Year(), t.Month()+1, 1, 0, 0, 0, 0, t.Location())
|
t = time.Date(t.Year(), t.Month()+1, 1, 0, 0, 0, 0, t.Location())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -331,14 +331,15 @@ func exportHandler(qt *querytracer.Tracer, w http.ResponseWriter, cp *commonPara
|
|||||||
return sw.maybeFlushBuffer(bb)
|
return sw.maybeFlushBuffer(bb)
|
||||||
}
|
}
|
||||||
contentType := "application/stream+json; charset=utf-8"
|
contentType := "application/stream+json; charset=utf-8"
|
||||||
if format == "prometheus" {
|
switch format {
|
||||||
|
case "prometheus":
|
||||||
contentType = "text/plain; charset=utf-8"
|
contentType = "text/plain; charset=utf-8"
|
||||||
writeLineFunc = func(xb *exportBlock, workerID uint) error {
|
writeLineFunc = func(xb *exportBlock, workerID uint) error {
|
||||||
bb := sw.getBuffer(workerID)
|
bb := sw.getBuffer(workerID)
|
||||||
WriteExportPrometheusLine(bb, xb)
|
WriteExportPrometheusLine(bb, xb)
|
||||||
return sw.maybeFlushBuffer(bb)
|
return sw.maybeFlushBuffer(bb)
|
||||||
}
|
}
|
||||||
} else if format == "promapi" {
|
case "promapi":
|
||||||
WriteExportPromAPIHeader(bw)
|
WriteExportPromAPIHeader(bw)
|
||||||
var firstLineOnce atomic.Bool
|
var firstLineOnce atomic.Bool
|
||||||
var firstLineSent atomic.Bool
|
var firstLineSent atomic.Bool
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
|
||||||
at "github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
at "github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/decimal"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/decimal"
|
||||||
pb "github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal"
|
pb "github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal"
|
||||||
@@ -134,7 +133,7 @@ func testDeduplication(tc *at.TestCase, sut at.PrometheusWriteQuerier, deduplica
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
sut.PrometheusAPIV1Write(t, data, apptest.QueryOpts{})
|
sut.PrometheusAPIV1Write(t, data, at.QueryOpts{})
|
||||||
sut.ForceFlush(t)
|
sut.ForceFlush(t)
|
||||||
sut.ForceMerge(t)
|
sut.ForceMerge(t)
|
||||||
|
|
||||||
@@ -207,7 +206,7 @@ func testDeduplication(tc *at.TestCase, sut at.PrometheusWriteQuerier, deduplica
|
|||||||
tc.Assert(&at.AssertOptions{
|
tc.Assert(&at.AssertOptions{
|
||||||
Msg: "unexpected response",
|
Msg: "unexpected response",
|
||||||
Got: func() any {
|
Got: func() any {
|
||||||
got := sut.PrometheusAPIV1Export(t, `{__name__=~"metric.*"}`, apptest.QueryOpts{
|
got := sut.PrometheusAPIV1Export(t, `{__name__=~"metric.*"}`, at.QueryOpts{
|
||||||
ReduceMemUsage: "1",
|
ReduceMemUsage: "1",
|
||||||
Start: fmt.Sprintf("%d", start.UnixMilli()),
|
Start: fmt.Sprintf("%d", start.UnixMilli()),
|
||||||
End: fmt.Sprintf("%d", end.UnixMilli()),
|
End: fmt.Sprintf("%d", end.UnixMilli()),
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/google/go-cmp/cmp/cmpopts"
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
|
||||||
at "github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
at "github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,13 +34,13 @@ func TestSingleMetricNamesStats(t *testing.T) {
|
|||||||
for idx := range dataSet {
|
for idx := range dataSet {
|
||||||
dataSet[idx] += ingestTimestamp
|
dataSet[idx] += ingestTimestamp
|
||||||
}
|
}
|
||||||
tsdbMetricNameEntryCmpOpts := cmpopts.IgnoreFields(apptest.TSDBStatusResponseMetricNameEntry{}, "LastRequestTimestamp")
|
tsdbMetricNameEntryCmpOpts := cmpopts.IgnoreFields(at.TSDBStatusResponseMetricNameEntry{}, "LastRequestTimestamp")
|
||||||
|
|
||||||
sut.PrometheusAPIV1ImportPrometheus(t, dataSet, at.QueryOpts{})
|
sut.PrometheusAPIV1ImportPrometheus(t, dataSet, at.QueryOpts{})
|
||||||
sut.ForceFlush(t)
|
sut.ForceFlush(t)
|
||||||
|
|
||||||
// verify ingest request correctly registered
|
// verify ingest request correctly registered
|
||||||
expected := apptest.MetricNamesStatsResponse{
|
expected := at.MetricNamesStatsResponse{
|
||||||
Records: []at.MetricNamesStatsRecord{
|
Records: []at.MetricNamesStatsRecord{
|
||||||
{MetricName: largeMetricName},
|
{MetricName: largeMetricName},
|
||||||
{MetricName: "metric_name_1"},
|
{MetricName: "metric_name_1"},
|
||||||
@@ -56,7 +55,7 @@ func TestSingleMetricNamesStats(t *testing.T) {
|
|||||||
|
|
||||||
// verify query request correctly registered
|
// verify query request correctly registered
|
||||||
sut.PrometheusAPIV1Query(t, `{__name__!=""}`, at.QueryOpts{Time: ingestDateTime})
|
sut.PrometheusAPIV1Query(t, `{__name__!=""}`, at.QueryOpts{Time: ingestDateTime})
|
||||||
expected = apptest.MetricNamesStatsResponse{
|
expected = at.MetricNamesStatsResponse{
|
||||||
Records: []at.MetricNamesStatsRecord{
|
Records: []at.MetricNamesStatsRecord{
|
||||||
{MetricName: largeMetricName, QueryRequestsCount: 1},
|
{MetricName: largeMetricName, QueryRequestsCount: 1},
|
||||||
{MetricName: "metric_name_1", QueryRequestsCount: 3},
|
{MetricName: "metric_name_1", QueryRequestsCount: 3},
|
||||||
@@ -69,36 +68,36 @@ func TestSingleMetricNamesStats(t *testing.T) {
|
|||||||
t.Errorf("unexpected response (-want, +got):\n%s", diff)
|
t.Errorf("unexpected response (-want, +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedStatsResponse := apptest.TSDBStatusResponse{
|
expectedStatsResponse := at.TSDBStatusResponse{
|
||||||
Data: at.TSDBStatusResponseData{
|
Data: at.TSDBStatusResponseData{
|
||||||
TotalSeries: 6,
|
TotalSeries: 6,
|
||||||
TotalLabelValuePairs: 12,
|
TotalLabelValuePairs: 12,
|
||||||
SeriesCountByMetricName: []apptest.TSDBStatusResponseMetricNameEntry{
|
SeriesCountByMetricName: []at.TSDBStatusResponseMetricNameEntry{
|
||||||
{Name: "metric_name_1", RequestsCount: 3},
|
{Name: "metric_name_1", RequestsCount: 3},
|
||||||
{Name: largeMetricName, RequestsCount: 1},
|
{Name: largeMetricName, RequestsCount: 1},
|
||||||
{Name: "metric_name_2", RequestsCount: 1},
|
{Name: "metric_name_2", RequestsCount: 1},
|
||||||
{Name: "metric_name_3", RequestsCount: 1},
|
{Name: "metric_name_3", RequestsCount: 1},
|
||||||
},
|
},
|
||||||
SeriesCountByLabelName: []apptest.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
SeriesCountByLabelName: []at.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
||||||
SeriesCountByFocusLabelValue: []apptest.TSDBStatusResponseEntry{},
|
SeriesCountByFocusLabelValue: []at.TSDBStatusResponseEntry{},
|
||||||
SeriesCountByLabelValuePair: []apptest.TSDBStatusResponseEntry{
|
SeriesCountByLabelValuePair: []at.TSDBStatusResponseEntry{
|
||||||
{Name: "__name__=" + largeMetricName},
|
{Name: "__name__=" + largeMetricName},
|
||||||
{Name: "__name__=metric_name_1"}, {Name: "label=baz"},
|
{Name: "__name__=metric_name_1"}, {Name: "label=baz"},
|
||||||
{Name: "__name__=metric_name_2"}, {Name: "__name__=metric_name_3"},
|
{Name: "__name__=metric_name_2"}, {Name: "__name__=metric_name_3"},
|
||||||
{Name: "label=bar"}, {Name: "label=foo"},
|
{Name: "label=bar"}, {Name: "label=foo"},
|
||||||
},
|
},
|
||||||
LabelValueCountByLabelName: []apptest.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
LabelValueCountByLabelName: []at.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
expectedStatsResponse.Sort()
|
expectedStatsResponse.Sort()
|
||||||
gotStatus := sut.APIV1StatusTSDB(t, "", date, "", apptest.QueryOpts{})
|
gotStatus := sut.APIV1StatusTSDB(t, "", date, "", at.QueryOpts{})
|
||||||
if diff := cmp.Diff(expectedStatsResponse, gotStatus, tsdbMetricNameEntryCmpOpts); diff != "" {
|
if diff := cmp.Diff(expectedStatsResponse, gotStatus, tsdbMetricNameEntryCmpOpts); diff != "" {
|
||||||
t.Errorf("unexpected APIV1StatusTSDB response (-want, +got):\n%s", diff)
|
t.Errorf("unexpected APIV1StatusTSDB response (-want, +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
// perform query request for single metric and check counter increase
|
// perform query request for single metric and check counter increase
|
||||||
sut.PrometheusAPIV1Query(t, `metric_name_2`, at.QueryOpts{Time: ingestDateTime})
|
sut.PrometheusAPIV1Query(t, `metric_name_2`, at.QueryOpts{Time: ingestDateTime})
|
||||||
expected = apptest.MetricNamesStatsResponse{
|
expected = at.MetricNamesStatsResponse{
|
||||||
Records: []at.MetricNamesStatsRecord{
|
Records: []at.MetricNamesStatsRecord{
|
||||||
{MetricName: largeMetricName, QueryRequestsCount: 1},
|
{MetricName: largeMetricName, QueryRequestsCount: 1},
|
||||||
{MetricName: "metric_name_1", QueryRequestsCount: 3},
|
{MetricName: "metric_name_1", QueryRequestsCount: 3},
|
||||||
@@ -112,7 +111,7 @@ func TestSingleMetricNamesStats(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// verify le filter
|
// verify le filter
|
||||||
expected = apptest.MetricNamesStatsResponse{
|
expected = at.MetricNamesStatsResponse{
|
||||||
Records: []at.MetricNamesStatsRecord{
|
Records: []at.MetricNamesStatsRecord{
|
||||||
{MetricName: largeMetricName, QueryRequestsCount: 1},
|
{MetricName: largeMetricName, QueryRequestsCount: 1},
|
||||||
{MetricName: "metric_name_2", QueryRequestsCount: 2},
|
{MetricName: "metric_name_2", QueryRequestsCount: 2},
|
||||||
@@ -126,7 +125,7 @@ func TestSingleMetricNamesStats(t *testing.T) {
|
|||||||
|
|
||||||
// reset state and check empty request response
|
// reset state and check empty request response
|
||||||
sut.APIV1AdminStatusMetricNamesStatsReset(t, at.QueryOpts{})
|
sut.APIV1AdminStatusMetricNamesStatsReset(t, at.QueryOpts{})
|
||||||
expected = apptest.MetricNamesStatsResponse{
|
expected = at.MetricNamesStatsResponse{
|
||||||
Records: []at.MetricNamesStatsRecord{},
|
Records: []at.MetricNamesStatsRecord{},
|
||||||
}
|
}
|
||||||
got = sut.APIV1StatusMetricNamesStats(t, "", "", "", at.QueryOpts{})
|
got = sut.APIV1StatusMetricNamesStats(t, "", "", "", at.QueryOpts{})
|
||||||
@@ -140,7 +139,7 @@ func TestClusterMetricNamesStats(t *testing.T) {
|
|||||||
|
|
||||||
os.RemoveAll(t.Name())
|
os.RemoveAll(t.Name())
|
||||||
|
|
||||||
tc := apptest.NewTestCase(t)
|
tc := at.NewTestCase(t)
|
||||||
defer tc.Stop()
|
defer tc.Stop()
|
||||||
vmstorage1 := tc.MustStartVmstorage("vmstorage-1", []string{
|
vmstorage1 := tc.MustStartVmstorage("vmstorage-1", []string{
|
||||||
"-storageDataPath=" + tc.Dir() + "/vmstorage-1",
|
"-storageDataPath=" + tc.Dir() + "/vmstorage-1",
|
||||||
@@ -160,7 +159,7 @@ func TestClusterMetricNamesStats(t *testing.T) {
|
|||||||
fmt.Sprintf("-storageNode=%s,%s", vmstorage1.VmselectAddr(), vmstorage2.VmselectAddr()),
|
fmt.Sprintf("-storageNode=%s,%s", vmstorage1.VmselectAddr(), vmstorage2.VmselectAddr()),
|
||||||
})
|
})
|
||||||
// verify empty stats
|
// verify empty stats
|
||||||
resp := vmselect.MetricNamesStats(t, "", "", "", apptest.QueryOpts{Tenant: "0:0"})
|
resp := vmselect.MetricNamesStats(t, "", "", "", at.QueryOpts{Tenant: "0:0"})
|
||||||
if len(resp.Records) != 0 {
|
if len(resp.Records) != 0 {
|
||||||
t.Fatalf("unexpected resp Records: %d, want: %d", len(resp.Records), 0)
|
t.Fatalf("unexpected resp Records: %d, want: %d", len(resp.Records), 0)
|
||||||
}
|
}
|
||||||
@@ -182,17 +181,17 @@ func TestClusterMetricNamesStats(t *testing.T) {
|
|||||||
dataSet[idx] += ingestTimestamp
|
dataSet[idx] += ingestTimestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbMetricNameEntryCmpOpts := cmpopts.IgnoreFields(apptest.TSDBStatusResponseMetricNameEntry{}, "LastRequestTimestamp")
|
tsdbMetricNameEntryCmpOpts := cmpopts.IgnoreFields(at.TSDBStatusResponseMetricNameEntry{}, "LastRequestTimestamp")
|
||||||
|
|
||||||
// ingest per tenant data and verify it with search
|
// ingest per tenant data and verify it with search
|
||||||
tenantIDs := []string{"1:1", "1:15", "15:15"}
|
tenantIDs := []string{"1:1", "1:15", "15:15"}
|
||||||
for _, tenantID := range tenantIDs {
|
for _, tenantID := range tenantIDs {
|
||||||
vminsert.PrometheusAPIV1ImportPrometheus(t, dataSet, apptest.QueryOpts{Tenant: tenantID})
|
vminsert.PrometheusAPIV1ImportPrometheus(t, dataSet, at.QueryOpts{Tenant: tenantID})
|
||||||
vmstorage1.ForceFlush(t)
|
vmstorage1.ForceFlush(t)
|
||||||
vmstorage2.ForceFlush(t)
|
vmstorage2.ForceFlush(t)
|
||||||
|
|
||||||
// verify ingest request correctly registered
|
// verify ingest request correctly registered
|
||||||
expected := apptest.MetricNamesStatsResponse{
|
expected := at.MetricNamesStatsResponse{
|
||||||
Records: []at.MetricNamesStatsRecord{
|
Records: []at.MetricNamesStatsRecord{
|
||||||
{MetricName: largeMetricName},
|
{MetricName: largeMetricName},
|
||||||
{MetricName: "metric_name_1"},
|
{MetricName: "metric_name_1"},
|
||||||
@@ -200,17 +199,17 @@ func TestClusterMetricNamesStats(t *testing.T) {
|
|||||||
{MetricName: "metric_name_3"},
|
{MetricName: "metric_name_3"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
gotStats := vmselect.MetricNamesStats(t, "", "", "", apptest.QueryOpts{Tenant: tenantID})
|
gotStats := vmselect.MetricNamesStats(t, "", "", "", at.QueryOpts{Tenant: tenantID})
|
||||||
if diff := cmp.Diff(expected, gotStats); diff != "" {
|
if diff := cmp.Diff(expected, gotStats); diff != "" {
|
||||||
t.Errorf("unexpected response (-want, +got):\n%s", diff)
|
t.Errorf("unexpected response (-want, +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify query request registered correctly
|
// verify query request registered correctly
|
||||||
vmselect.PrometheusAPIV1Query(t, `{__name__!=""}`, apptest.QueryOpts{
|
vmselect.PrometheusAPIV1Query(t, `{__name__!=""}`, at.QueryOpts{
|
||||||
Tenant: tenantID, Time: ingestDateTime,
|
Tenant: tenantID, Time: ingestDateTime,
|
||||||
})
|
})
|
||||||
|
|
||||||
expected = apptest.MetricNamesStatsResponse{
|
expected = at.MetricNamesStatsResponse{
|
||||||
Records: []at.MetricNamesStatsRecord{
|
Records: []at.MetricNamesStatsRecord{
|
||||||
{MetricName: largeMetricName, QueryRequestsCount: 1},
|
{MetricName: largeMetricName, QueryRequestsCount: 1},
|
||||||
{MetricName: "metric_name_2", QueryRequestsCount: 1},
|
{MetricName: "metric_name_2", QueryRequestsCount: 1},
|
||||||
@@ -218,41 +217,41 @@ func TestClusterMetricNamesStats(t *testing.T) {
|
|||||||
{MetricName: "metric_name_1", QueryRequestsCount: 3},
|
{MetricName: "metric_name_1", QueryRequestsCount: 3},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
gotStats = vmselect.MetricNamesStats(t, "", "", "", apptest.QueryOpts{Tenant: tenantID})
|
gotStats = vmselect.MetricNamesStats(t, "", "", "", at.QueryOpts{Tenant: tenantID})
|
||||||
if diff := cmp.Diff(expected, gotStats); diff != "" {
|
if diff := cmp.Diff(expected, gotStats); diff != "" {
|
||||||
t.Errorf("unexpected response tenant: %s (-want, +got):\n%s", tenantID, diff)
|
t.Errorf("unexpected response tenant: %s (-want, +got):\n%s", tenantID, diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedStatsResponse := apptest.TSDBStatusResponse{
|
expectedStatsResponse := at.TSDBStatusResponse{
|
||||||
Data: at.TSDBStatusResponseData{
|
Data: at.TSDBStatusResponseData{
|
||||||
TotalSeries: 6,
|
TotalSeries: 6,
|
||||||
TotalLabelValuePairs: 12,
|
TotalLabelValuePairs: 12,
|
||||||
SeriesCountByMetricName: []apptest.TSDBStatusResponseMetricNameEntry{
|
SeriesCountByMetricName: []at.TSDBStatusResponseMetricNameEntry{
|
||||||
{Name: "metric_name_1", RequestsCount: 3},
|
{Name: "metric_name_1", RequestsCount: 3},
|
||||||
{Name: largeMetricName, RequestsCount: 1},
|
{Name: largeMetricName, RequestsCount: 1},
|
||||||
{Name: "metric_name_2", RequestsCount: 1},
|
{Name: "metric_name_2", RequestsCount: 1},
|
||||||
{Name: "metric_name_3", RequestsCount: 1},
|
{Name: "metric_name_3", RequestsCount: 1},
|
||||||
},
|
},
|
||||||
SeriesCountByLabelName: []apptest.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
SeriesCountByLabelName: []at.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
||||||
SeriesCountByFocusLabelValue: []apptest.TSDBStatusResponseEntry{},
|
SeriesCountByFocusLabelValue: []at.TSDBStatusResponseEntry{},
|
||||||
SeriesCountByLabelValuePair: []apptest.TSDBStatusResponseEntry{
|
SeriesCountByLabelValuePair: []at.TSDBStatusResponseEntry{
|
||||||
{Name: "__name__=" + largeMetricName},
|
{Name: "__name__=" + largeMetricName},
|
||||||
{Name: "__name__=metric_name_1"}, {Name: "label=baz"},
|
{Name: "__name__=metric_name_1"}, {Name: "label=baz"},
|
||||||
{Name: "__name__=metric_name_2"}, {Name: "__name__=metric_name_3"},
|
{Name: "__name__=metric_name_2"}, {Name: "__name__=metric_name_3"},
|
||||||
{Name: "label=bar"}, {Name: "label=foo"},
|
{Name: "label=bar"}, {Name: "label=foo"},
|
||||||
},
|
},
|
||||||
LabelValueCountByLabelName: []apptest.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
LabelValueCountByLabelName: []at.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
expectedStatsResponse.Sort()
|
expectedStatsResponse.Sort()
|
||||||
gotStatus := vmselect.APIV1StatusTSDB(t, "", date, "", apptest.QueryOpts{Tenant: tenantID})
|
gotStatus := vmselect.APIV1StatusTSDB(t, "", date, "", at.QueryOpts{Tenant: tenantID})
|
||||||
if diff := cmp.Diff(expectedStatsResponse, gotStatus, tsdbMetricNameEntryCmpOpts); diff != "" {
|
if diff := cmp.Diff(expectedStatsResponse, gotStatus, tsdbMetricNameEntryCmpOpts); diff != "" {
|
||||||
t.Errorf("unexpected APIV1StatusTSDB response tenant: %s (-want, +got):\n%s", tenantID, diff)
|
t.Errorf("unexpected APIV1StatusTSDB response tenant: %s (-want, +got):\n%s", tenantID, diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify multitenant stats
|
// verify multitenant stats
|
||||||
expected := apptest.MetricNamesStatsResponse{
|
expected := at.MetricNamesStatsResponse{
|
||||||
Records: []at.MetricNamesStatsRecord{
|
Records: []at.MetricNamesStatsRecord{
|
||||||
{MetricName: largeMetricName, QueryRequestsCount: 3},
|
{MetricName: largeMetricName, QueryRequestsCount: 3},
|
||||||
{MetricName: "metric_name_2", QueryRequestsCount: 3},
|
{MetricName: "metric_name_2", QueryRequestsCount: 3},
|
||||||
@@ -260,14 +259,14 @@ func TestClusterMetricNamesStats(t *testing.T) {
|
|||||||
{MetricName: "metric_name_1", QueryRequestsCount: 9},
|
{MetricName: "metric_name_1", QueryRequestsCount: 9},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
gotStats := vmselect.MetricNamesStats(t, "", "", "", apptest.QueryOpts{Tenant: "multitenant"})
|
gotStats := vmselect.MetricNamesStats(t, "", "", "", at.QueryOpts{Tenant: "multitenant"})
|
||||||
if diff := cmp.Diff(expected, gotStats); diff != "" {
|
if diff := cmp.Diff(expected, gotStats); diff != "" {
|
||||||
t.Errorf("unexpected response (-want, +got):\n%s", diff)
|
t.Errorf("unexpected response (-want, +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset cache and check empty state
|
// reset cache and check empty state
|
||||||
vmselect.MetricNamesStatsReset(t, at.QueryOpts{})
|
vmselect.MetricNamesStatsReset(t, at.QueryOpts{})
|
||||||
resp = vmselect.MetricNamesStats(t, "", "", "", apptest.QueryOpts{Tenant: "multitenant"})
|
resp = vmselect.MetricNamesStats(t, "", "", "", at.QueryOpts{Tenant: "multitenant"})
|
||||||
if len(resp.Records) != 0 {
|
if len(resp.Records) != 0 {
|
||||||
t.Fatalf("want 0 records, got: %d", len(resp.Records))
|
t.Fatalf("want 0 records, got: %d", len(resp.Records))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
|
||||||
at "github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
at "github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/google/go-cmp/cmp/cmpopts"
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
@@ -377,7 +376,7 @@ func TestClusterReplication_PartialResponse(t *testing.T) {
|
|||||||
IsPartial: wantPartial,
|
IsPartial: wantPartial,
|
||||||
},
|
},
|
||||||
CmpOpts: []cmp.Option{
|
CmpOpts: []cmp.Option{
|
||||||
cmpopts.IgnoreFields(apptest.PrometheusAPIV1SeriesResponse{}, "Data"),
|
cmpopts.IgnoreFields(at.PrometheusAPIV1SeriesResponse{}, "Data"),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1030,7 +1029,7 @@ func testGroupPartialResponse(tc *at.TestCase, opts *testGroupReplicationOpts) {
|
|||||||
IsPartial: wantPartial,
|
IsPartial: wantPartial,
|
||||||
},
|
},
|
||||||
CmpOpts: []cmp.Option{
|
CmpOpts: []cmp.Option{
|
||||||
cmpopts.IgnoreFields(apptest.PrometheusAPIV1SeriesResponse{}, "Data"),
|
cmpopts.IgnoreFields(at.PrometheusAPIV1SeriesResponse{}, "Data"),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1151,7 +1150,7 @@ func TestClusterReplication_PartialResponseMultitenant(t *testing.T) {
|
|||||||
IsPartial: wantPartial,
|
IsPartial: wantPartial,
|
||||||
},
|
},
|
||||||
CmpOpts: []cmp.Option{
|
CmpOpts: []cmp.Option{
|
||||||
cmpopts.IgnoreFields(apptest.PrometheusAPIV1QueryResponse{}, "Data"),
|
cmpopts.IgnoreFields(at.PrometheusAPIV1QueryResponse{}, "Data"),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,12 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
|
||||||
at "github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
at "github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestSingleVMAgentReloadConfigs verifies that vmagent reload new configurations on SIGHUP signal
|
// TestSingleVMAgentReloadConfigs verifies that vmagent reload new configurations on SIGHUP signal
|
||||||
func TestSingleVMAgentReloadConfigs(t *testing.T) {
|
func TestSingleVMAgentReloadConfigs(t *testing.T) {
|
||||||
tc := apptest.NewTestCase(t)
|
tc := at.NewTestCase(t)
|
||||||
defer tc.Stop()
|
defer tc.Stop()
|
||||||
|
|
||||||
vmsingle := tc.MustStartDefaultVmsingle()
|
vmsingle := tc.MustStartDefaultVmsingle()
|
||||||
@@ -38,7 +37,7 @@ func TestSingleVMAgentReloadConfigs(t *testing.T) {
|
|||||||
|
|
||||||
vmagent.APIV1ImportPrometheus(t, []string{
|
vmagent.APIV1ImportPrometheus(t, []string{
|
||||||
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
||||||
}, apptest.QueryOpts{})
|
}, at.QueryOpts{})
|
||||||
|
|
||||||
vmsingle.ForceFlush(t)
|
vmsingle.ForceFlush(t)
|
||||||
|
|
||||||
@@ -69,7 +68,7 @@ func TestSingleVMAgentReloadConfigs(t *testing.T) {
|
|||||||
|
|
||||||
vmagent.APIV1ImportPrometheus(t, []string{
|
vmagent.APIV1ImportPrometheus(t, []string{
|
||||||
"bar_foo 1 1652169600001", // 2022-05-10T08:00:00Z
|
"bar_foo 1 1652169600001", // 2022-05-10T08:00:00Z
|
||||||
}, apptest.QueryOpts{})
|
}, at.QueryOpts{})
|
||||||
|
|
||||||
vmsingle.ForceFlush(t)
|
vmsingle.ForceFlush(t)
|
||||||
|
|
||||||
@@ -101,7 +100,7 @@ func TestSingleVMAgentSnappyRemoteWrite(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testSingleVMAgentRemoteWrite(t *testing.T, forcePromProto bool) {
|
func testSingleVMAgentRemoteWrite(t *testing.T, forcePromProto bool) {
|
||||||
tc := apptest.NewTestCase(t)
|
tc := at.NewTestCase(t)
|
||||||
defer tc.Stop()
|
defer tc.Stop()
|
||||||
|
|
||||||
vmsingle := tc.MustStartDefaultVmsingle()
|
vmsingle := tc.MustStartDefaultVmsingle()
|
||||||
@@ -115,7 +114,7 @@ func testSingleVMAgentRemoteWrite(t *testing.T, forcePromProto bool) {
|
|||||||
|
|
||||||
vmagent.APIV1ImportPrometheus(t, []string{
|
vmagent.APIV1ImportPrometheus(t, []string{
|
||||||
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
||||||
}, apptest.QueryOpts{})
|
}, at.QueryOpts{})
|
||||||
|
|
||||||
vmsingle.ForceFlush(t)
|
vmsingle.ForceFlush(t)
|
||||||
|
|
||||||
@@ -138,7 +137,7 @@ func testSingleVMAgentRemoteWrite(t *testing.T, forcePromProto bool) {
|
|||||||
// - Starts with Prometheus remote write protocol using `snappy`.
|
// - Starts with Prometheus remote write protocol using `snappy`.
|
||||||
// - Does not retry `snappy`-encoded requests if they fail; instead, they are dropped.
|
// - Does not retry `snappy`-encoded requests if they fail; instead, they are dropped.
|
||||||
func TestSingleVMAgentUnsupportedMediaTypeDropIfSnappy(t *testing.T) {
|
func TestSingleVMAgentUnsupportedMediaTypeDropIfSnappy(t *testing.T) {
|
||||||
tc := apptest.NewTestCase(t)
|
tc := at.NewTestCase(t)
|
||||||
defer tc.Stop()
|
defer tc.Stop()
|
||||||
|
|
||||||
var remoteWriteContentEncodingsMux sync.Mutex
|
var remoteWriteContentEncodingsMux sync.Mutex
|
||||||
@@ -164,11 +163,11 @@ func TestSingleVMAgentUnsupportedMediaTypeDropIfSnappy(t *testing.T) {
|
|||||||
|
|
||||||
vmagent.APIV1ImportPrometheusNoWaitFlush(t, []string{
|
vmagent.APIV1ImportPrometheusNoWaitFlush(t, []string{
|
||||||
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
||||||
}, apptest.QueryOpts{})
|
}, at.QueryOpts{})
|
||||||
|
|
||||||
vmagent.APIV1ImportPrometheusNoWaitFlush(t, []string{
|
vmagent.APIV1ImportPrometheusNoWaitFlush(t, []string{
|
||||||
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
||||||
}, apptest.QueryOpts{})
|
}, at.QueryOpts{})
|
||||||
|
|
||||||
tc.Assert(&at.AssertOptions{
|
tc.Assert(&at.AssertOptions{
|
||||||
Msg: `unexpected content encoding headers sent to remote write server; expected zstd`,
|
Msg: `unexpected content encoding headers sent to remote write server; expected zstd`,
|
||||||
@@ -197,7 +196,7 @@ func TestSingleVMAgentUnsupportedMediaTypeDropIfSnappy(t *testing.T) {
|
|||||||
// - Re-packs and retries failed requests.
|
// - Re-packs and retries failed requests.
|
||||||
// - Sends all subsequent requests using `snappy`.
|
// - Sends all subsequent requests using `snappy`.
|
||||||
func TestSingleVMAgentDowngradeRemoteWriteProtocol(t *testing.T) {
|
func TestSingleVMAgentDowngradeRemoteWriteProtocol(t *testing.T) {
|
||||||
tc := apptest.NewTestCase(t)
|
tc := at.NewTestCase(t)
|
||||||
defer tc.Stop()
|
defer tc.Stop()
|
||||||
|
|
||||||
var remoteWriteContentEncodings []string
|
var remoteWriteContentEncodings []string
|
||||||
@@ -228,12 +227,12 @@ func TestSingleVMAgentDowngradeRemoteWriteProtocol(t *testing.T) {
|
|||||||
// Send request encoded with `zstd`; it fails, gets repacked as `snappy`, and retries successfully.
|
// Send request encoded with `zstd`; it fails, gets repacked as `snappy`, and retries successfully.
|
||||||
vmagent.APIV1ImportPrometheus(t, []string{
|
vmagent.APIV1ImportPrometheus(t, []string{
|
||||||
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
||||||
}, apptest.QueryOpts{})
|
}, at.QueryOpts{})
|
||||||
|
|
||||||
// Send request encoded with `snappy` immediately; it succeeds without retries.
|
// Send request encoded with `snappy` immediately; it succeeds without retries.
|
||||||
vmagent.APIV1ImportPrometheus(t, []string{
|
vmagent.APIV1ImportPrometheus(t, []string{
|
||||||
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
||||||
}, apptest.QueryOpts{})
|
}, at.QueryOpts{})
|
||||||
|
|
||||||
tc.Assert(&at.AssertOptions{
|
tc.Assert(&at.AssertOptions{
|
||||||
Msg: `unexpected content encoding headers sent to remote write server`,
|
Msg: `unexpected content encoding headers sent to remote write server`,
|
||||||
|
|||||||
@@ -115,11 +115,12 @@ func AppendDecimalToFloat(dst []float64, va []int64, e int16) []float64 {
|
|||||||
if !isSpecialValue(v) {
|
if !isSpecialValue(v) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if v == vInfPos {
|
switch v {
|
||||||
|
case vInfPos:
|
||||||
a[i] = infPos
|
a[i] = infPos
|
||||||
} else if v == vInfNeg {
|
case vInfNeg:
|
||||||
a[i] = infNeg
|
a[i] = infNeg
|
||||||
} else {
|
default:
|
||||||
a[i] = StaleNaN
|
a[i] = StaleNaN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,11 +136,12 @@ func AppendDecimalToFloat(dst []float64, va []int64, e int16) []float64 {
|
|||||||
if !isSpecialValue(v) {
|
if !isSpecialValue(v) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if v == vInfPos {
|
switch v {
|
||||||
|
case vInfPos:
|
||||||
a[i] = infPos
|
a[i] = infPos
|
||||||
} else if v == vInfNeg {
|
case vInfNeg:
|
||||||
a[i] = infNeg
|
a[i] = infNeg
|
||||||
} else {
|
default:
|
||||||
a[i] = StaleNaN
|
a[i] = StaleNaN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,11 +154,12 @@ func AppendDecimalToFloat(dst []float64, va []int64, e int16) []float64 {
|
|||||||
if !isSpecialValue(v) {
|
if !isSpecialValue(v) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if v == vInfPos {
|
switch v {
|
||||||
|
case vInfPos:
|
||||||
a[i] = infPos
|
a[i] = infPos
|
||||||
} else if v == vInfNeg {
|
case vInfNeg:
|
||||||
a[i] = infNeg
|
a[i] = infNeg
|
||||||
} else {
|
default:
|
||||||
a[i] = StaleNaN
|
a[i] = StaleNaN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -943,7 +943,7 @@ func (uw *urlWatcher) removeObjectLocked(key string) {
|
|||||||
func (uw *urlWatcher) maybeUpdateDependedScrapeWorksLocked() {
|
func (uw *urlWatcher) maybeUpdateDependedScrapeWorksLocked() {
|
||||||
role := uw.role
|
role := uw.role
|
||||||
attachNodeMetadata := uw.gw.attachNodeMetadata
|
attachNodeMetadata := uw.gw.attachNodeMetadata
|
||||||
if !(role == "pod" || role == "service" || (attachNodeMetadata && role == "node")) {
|
if role != "pod" && role != "service" && (!attachNodeMetadata || role != "node") {
|
||||||
// Nothing to update
|
// Nothing to update
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,14 +19,13 @@ func getAuthHeaders(cfg *apiConfig, headers http.Header, endpoint, path string)
|
|||||||
headers.Add("X-Ovh-Consumer", cfg.consumerKey)
|
headers.Add("X-Ovh-Consumer", cfg.consumerKey)
|
||||||
|
|
||||||
h := sha1.New()
|
h := sha1.New()
|
||||||
h.Write([]byte(fmt.Sprintf("%s+%s+%s+%s+%s+%d",
|
fmt.Fprintf(h, "%s+%s+%s+%s+%s+%d",
|
||||||
cfg.applicationSecret,
|
cfg.applicationSecret,
|
||||||
cfg.consumerKey,
|
cfg.consumerKey,
|
||||||
"GET",
|
"GET",
|
||||||
endpoint+path,
|
endpoint+path,
|
||||||
"", // no body contained in any service discovery request, so it's set to empty by default
|
"",
|
||||||
timestamp,
|
timestamp)
|
||||||
)))
|
|
||||||
headers.Set("X-Ovh-Signature", fmt.Sprintf("$1$%x", h.Sum(nil)))
|
headers.Set("X-Ovh-Signature", fmt.Sprintf("$1$%x", h.Sum(nil)))
|
||||||
return headers, nil
|
return headers, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -599,7 +599,7 @@ func TestScrapeWorkScrapeInternalStreamConcurrency(t *testing.T) {
|
|||||||
// see https://github.com/VictoriaMetrics/VictoriaMetrics/pull/8515#issuecomment-2741063155
|
// see https://github.com/VictoriaMetrics/VictoriaMetrics/pull/8515#issuecomment-2741063155
|
||||||
lowerExpectedDelta := pushedTimeseries.Load() - timeseriesExpectedDelta
|
lowerExpectedDelta := pushedTimeseries.Load() - timeseriesExpectedDelta
|
||||||
upperExpectedDelta := pushedTimeseries.Load() + timeseriesExpectedDelta + 1
|
upperExpectedDelta := pushedTimeseries.Load() + timeseriesExpectedDelta + 1
|
||||||
if !(timeseriesExpected >= lowerExpectedDelta && timeseriesExpected < upperExpectedDelta) {
|
if timeseriesExpected < lowerExpectedDelta || timeseriesExpected >= upperExpectedDelta {
|
||||||
t.Fatalf("unexpected number of pushed timeseries; got %d; want within range [%d, %d)",
|
t.Fatalf("unexpected number of pushed timeseries; got %d; want within range [%d, %d)",
|
||||||
pushedTimeseries.Load(),
|
pushedTimeseries.Load(),
|
||||||
lowerExpectedDelta,
|
lowerExpectedDelta,
|
||||||
|
|||||||
Reference in New Issue
Block a user