mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 00:26:36 +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:
|
||||
timeout: 2m
|
||||
|
||||
version: "2"
|
||||
linters:
|
||||
enable:
|
||||
- revive
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
- linters:
|
||||
- staticcheck
|
||||
text: "SA(4003|1019|5011):"
|
||||
include:
|
||||
- EXC0012
|
||||
- EXC0014
|
||||
|
||||
linters-settings:
|
||||
errcheck:
|
||||
exclude-functions:
|
||||
- "fmt.Fprintf"
|
||||
- "fmt.Fprint"
|
||||
- "(net/http.ResponseWriter).Write"
|
||||
settings:
|
||||
errcheck:
|
||||
exclude-functions:
|
||||
- fmt.Fprintf
|
||||
- fmt.Fprint
|
||||
- (net/http.ResponseWriter).Write
|
||||
exclusions:
|
||||
generated: lax
|
||||
presets:
|
||||
- common-false-positives
|
||||
- legacy
|
||||
- std-error-handling
|
||||
rules:
|
||||
- linters:
|
||||
- staticcheck
|
||||
text: 'SA(4003|1019|5011):'
|
||||
paths:
|
||||
- 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)'
|
||||
TAR_OWNERSHIP ?= --owner=1000 --group=1000
|
||||
|
||||
GOLANGCI_LINT_VERSION := 2.2.1
|
||||
|
||||
.PHONY: $(MAKECMDGOALS)
|
||||
|
||||
include app/*/Makefile
|
||||
@@ -612,7 +614,7 @@ golangci-lint: install-golangci-lint
|
||||
GOEXPERIMENT=synctest golangci-lint run
|
||||
|
||||
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:
|
||||
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()
|
||||
if statusCode == 409 {
|
||||
switch statusCode {
|
||||
case 409:
|
||||
logBlockRejected(block, c.sanitizedURL, resp)
|
||||
|
||||
// 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.
|
||||
// - 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
|
||||
} 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) {
|
||||
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)
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestCalculateRetryDuration(t *testing.T) {
|
||||
expectMaxDuration := helper(expectMinDuration)
|
||||
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(
|
||||
"incorrect retry duration, want (ms): [%d, %d], got (ms): %d",
|
||||
expectMinDuration.Milliseconds(), expectMaxDuration.Milliseconds(),
|
||||
|
||||
@@ -19,7 +19,6 @@ import (
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"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/notifier"
|
||||
@@ -112,7 +111,7 @@ func UnitTest(files []string, disableGroupLabel bool, externalLabels []string, e
|
||||
defer vmselect.Stop()
|
||||
disableAlertgroupLabel = disableGroupLabel
|
||||
|
||||
testfiles, err := config.ReadFromFS(files)
|
||||
testfiles, err := vmalertconfig.ReadFromFS(files)
|
||||
if err != nil {
|
||||
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 {
|
||||
if _, ok := targetMetadata[ot.Addr()]; !ok {
|
||||
// if target not exists in currentTargets, close it
|
||||
ot.Notifier.Close()
|
||||
ot.Close()
|
||||
} else {
|
||||
updatedTargets = append(updatedTargets, ot)
|
||||
delete(targetMetadata, ot.Addr())
|
||||
|
||||
@@ -459,7 +459,7 @@ func (rh *requestHandler) listNotifiers() ([]byte, error) {
|
||||
}
|
||||
for _, target := range protoTargets {
|
||||
notifier.Targets = append(notifier.Targets, &apiTarget{
|
||||
Address: target.Notifier.Addr(),
|
||||
Address: target.Addr(),
|
||||
Labels: target.Labels.ToMap(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func SplitDateRange(start, end time.Time, step string, timeReverse bool) ([][]ti
|
||||
case StepMonth:
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
}
|
||||
contentType := "application/stream+json; charset=utf-8"
|
||||
if format == "prometheus" {
|
||||
switch format {
|
||||
case "prometheus":
|
||||
contentType = "text/plain; charset=utf-8"
|
||||
writeLineFunc = func(xb *exportBlock, workerID uint) error {
|
||||
bb := sw.getBuffer(workerID)
|
||||
WriteExportPrometheusLine(bb, xb)
|
||||
return sw.maybeFlushBuffer(bb)
|
||||
}
|
||||
} else if format == "promapi" {
|
||||
case "promapi":
|
||||
WriteExportPromAPIHeader(bw)
|
||||
var firstLineOnce atomic.Bool
|
||||
var firstLineSent atomic.Bool
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
||||
at "github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/decimal"
|
||||
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.ForceMerge(t)
|
||||
|
||||
@@ -207,7 +206,7 @@ func testDeduplication(tc *at.TestCase, sut at.PrometheusWriteQuerier, deduplica
|
||||
tc.Assert(&at.AssertOptions{
|
||||
Msg: "unexpected response",
|
||||
Got: func() any {
|
||||
got := sut.PrometheusAPIV1Export(t, `{__name__=~"metric.*"}`, apptest.QueryOpts{
|
||||
got := sut.PrometheusAPIV1Export(t, `{__name__=~"metric.*"}`, at.QueryOpts{
|
||||
ReduceMemUsage: "1",
|
||||
Start: fmt.Sprintf("%d", start.UnixMilli()),
|
||||
End: fmt.Sprintf("%d", end.UnixMilli()),
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
||||
at "github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
||||
)
|
||||
|
||||
@@ -35,13 +34,13 @@ func TestSingleMetricNamesStats(t *testing.T) {
|
||||
for idx := range dataSet {
|
||||
dataSet[idx] += ingestTimestamp
|
||||
}
|
||||
tsdbMetricNameEntryCmpOpts := cmpopts.IgnoreFields(apptest.TSDBStatusResponseMetricNameEntry{}, "LastRequestTimestamp")
|
||||
tsdbMetricNameEntryCmpOpts := cmpopts.IgnoreFields(at.TSDBStatusResponseMetricNameEntry{}, "LastRequestTimestamp")
|
||||
|
||||
sut.PrometheusAPIV1ImportPrometheus(t, dataSet, at.QueryOpts{})
|
||||
sut.ForceFlush(t)
|
||||
|
||||
// verify ingest request correctly registered
|
||||
expected := apptest.MetricNamesStatsResponse{
|
||||
expected := at.MetricNamesStatsResponse{
|
||||
Records: []at.MetricNamesStatsRecord{
|
||||
{MetricName: largeMetricName},
|
||||
{MetricName: "metric_name_1"},
|
||||
@@ -56,7 +55,7 @@ func TestSingleMetricNamesStats(t *testing.T) {
|
||||
|
||||
// verify query request correctly registered
|
||||
sut.PrometheusAPIV1Query(t, `{__name__!=""}`, at.QueryOpts{Time: ingestDateTime})
|
||||
expected = apptest.MetricNamesStatsResponse{
|
||||
expected = at.MetricNamesStatsResponse{
|
||||
Records: []at.MetricNamesStatsRecord{
|
||||
{MetricName: largeMetricName, QueryRequestsCount: 1},
|
||||
{MetricName: "metric_name_1", QueryRequestsCount: 3},
|
||||
@@ -69,36 +68,36 @@ func TestSingleMetricNamesStats(t *testing.T) {
|
||||
t.Errorf("unexpected response (-want, +got):\n%s", diff)
|
||||
}
|
||||
|
||||
expectedStatsResponse := apptest.TSDBStatusResponse{
|
||||
expectedStatsResponse := at.TSDBStatusResponse{
|
||||
Data: at.TSDBStatusResponseData{
|
||||
TotalSeries: 6,
|
||||
TotalLabelValuePairs: 12,
|
||||
SeriesCountByMetricName: []apptest.TSDBStatusResponseMetricNameEntry{
|
||||
SeriesCountByMetricName: []at.TSDBStatusResponseMetricNameEntry{
|
||||
{Name: "metric_name_1", RequestsCount: 3},
|
||||
{Name: largeMetricName, RequestsCount: 1},
|
||||
{Name: "metric_name_2", RequestsCount: 1},
|
||||
{Name: "metric_name_3", RequestsCount: 1},
|
||||
},
|
||||
SeriesCountByLabelName: []apptest.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
||||
SeriesCountByFocusLabelValue: []apptest.TSDBStatusResponseEntry{},
|
||||
SeriesCountByLabelValuePair: []apptest.TSDBStatusResponseEntry{
|
||||
SeriesCountByLabelName: []at.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
||||
SeriesCountByFocusLabelValue: []at.TSDBStatusResponseEntry{},
|
||||
SeriesCountByLabelValuePair: []at.TSDBStatusResponseEntry{
|
||||
{Name: "__name__=" + largeMetricName},
|
||||
{Name: "__name__=metric_name_1"}, {Name: "label=baz"},
|
||||
{Name: "__name__=metric_name_2"}, {Name: "__name__=metric_name_3"},
|
||||
{Name: "label=bar"}, {Name: "label=foo"},
|
||||
},
|
||||
LabelValueCountByLabelName: []apptest.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
||||
LabelValueCountByLabelName: []at.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
||||
},
|
||||
}
|
||||
expectedStatsResponse.Sort()
|
||||
gotStatus := sut.APIV1StatusTSDB(t, "", date, "", apptest.QueryOpts{})
|
||||
gotStatus := sut.APIV1StatusTSDB(t, "", date, "", at.QueryOpts{})
|
||||
if diff := cmp.Diff(expectedStatsResponse, gotStatus, tsdbMetricNameEntryCmpOpts); diff != "" {
|
||||
t.Errorf("unexpected APIV1StatusTSDB response (-want, +got):\n%s", diff)
|
||||
}
|
||||
|
||||
// perform query request for single metric and check counter increase
|
||||
sut.PrometheusAPIV1Query(t, `metric_name_2`, at.QueryOpts{Time: ingestDateTime})
|
||||
expected = apptest.MetricNamesStatsResponse{
|
||||
expected = at.MetricNamesStatsResponse{
|
||||
Records: []at.MetricNamesStatsRecord{
|
||||
{MetricName: largeMetricName, QueryRequestsCount: 1},
|
||||
{MetricName: "metric_name_1", QueryRequestsCount: 3},
|
||||
@@ -112,7 +111,7 @@ func TestSingleMetricNamesStats(t *testing.T) {
|
||||
}
|
||||
|
||||
// verify le filter
|
||||
expected = apptest.MetricNamesStatsResponse{
|
||||
expected = at.MetricNamesStatsResponse{
|
||||
Records: []at.MetricNamesStatsRecord{
|
||||
{MetricName: largeMetricName, QueryRequestsCount: 1},
|
||||
{MetricName: "metric_name_2", QueryRequestsCount: 2},
|
||||
@@ -126,7 +125,7 @@ func TestSingleMetricNamesStats(t *testing.T) {
|
||||
|
||||
// reset state and check empty request response
|
||||
sut.APIV1AdminStatusMetricNamesStatsReset(t, at.QueryOpts{})
|
||||
expected = apptest.MetricNamesStatsResponse{
|
||||
expected = at.MetricNamesStatsResponse{
|
||||
Records: []at.MetricNamesStatsRecord{},
|
||||
}
|
||||
got = sut.APIV1StatusMetricNamesStats(t, "", "", "", at.QueryOpts{})
|
||||
@@ -140,7 +139,7 @@ func TestClusterMetricNamesStats(t *testing.T) {
|
||||
|
||||
os.RemoveAll(t.Name())
|
||||
|
||||
tc := apptest.NewTestCase(t)
|
||||
tc := at.NewTestCase(t)
|
||||
defer tc.Stop()
|
||||
vmstorage1 := tc.MustStartVmstorage("vmstorage-1", []string{
|
||||
"-storageDataPath=" + tc.Dir() + "/vmstorage-1",
|
||||
@@ -160,7 +159,7 @@ func TestClusterMetricNamesStats(t *testing.T) {
|
||||
fmt.Sprintf("-storageNode=%s,%s", vmstorage1.VmselectAddr(), vmstorage2.VmselectAddr()),
|
||||
})
|
||||
// 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 {
|
||||
t.Fatalf("unexpected resp Records: %d, want: %d", len(resp.Records), 0)
|
||||
}
|
||||
@@ -182,17 +181,17 @@ func TestClusterMetricNamesStats(t *testing.T) {
|
||||
dataSet[idx] += ingestTimestamp
|
||||
}
|
||||
|
||||
tsdbMetricNameEntryCmpOpts := cmpopts.IgnoreFields(apptest.TSDBStatusResponseMetricNameEntry{}, "LastRequestTimestamp")
|
||||
tsdbMetricNameEntryCmpOpts := cmpopts.IgnoreFields(at.TSDBStatusResponseMetricNameEntry{}, "LastRequestTimestamp")
|
||||
|
||||
// ingest per tenant data and verify it with search
|
||||
tenantIDs := []string{"1:1", "1:15", "15:15"}
|
||||
for _, tenantID := range tenantIDs {
|
||||
vminsert.PrometheusAPIV1ImportPrometheus(t, dataSet, apptest.QueryOpts{Tenant: tenantID})
|
||||
vminsert.PrometheusAPIV1ImportPrometheus(t, dataSet, at.QueryOpts{Tenant: tenantID})
|
||||
vmstorage1.ForceFlush(t)
|
||||
vmstorage2.ForceFlush(t)
|
||||
|
||||
// verify ingest request correctly registered
|
||||
expected := apptest.MetricNamesStatsResponse{
|
||||
expected := at.MetricNamesStatsResponse{
|
||||
Records: []at.MetricNamesStatsRecord{
|
||||
{MetricName: largeMetricName},
|
||||
{MetricName: "metric_name_1"},
|
||||
@@ -200,17 +199,17 @@ func TestClusterMetricNamesStats(t *testing.T) {
|
||||
{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 != "" {
|
||||
t.Errorf("unexpected response (-want, +got):\n%s", diff)
|
||||
}
|
||||
|
||||
// verify query request registered correctly
|
||||
vmselect.PrometheusAPIV1Query(t, `{__name__!=""}`, apptest.QueryOpts{
|
||||
vmselect.PrometheusAPIV1Query(t, `{__name__!=""}`, at.QueryOpts{
|
||||
Tenant: tenantID, Time: ingestDateTime,
|
||||
})
|
||||
|
||||
expected = apptest.MetricNamesStatsResponse{
|
||||
expected = at.MetricNamesStatsResponse{
|
||||
Records: []at.MetricNamesStatsRecord{
|
||||
{MetricName: largeMetricName, QueryRequestsCount: 1},
|
||||
{MetricName: "metric_name_2", QueryRequestsCount: 1},
|
||||
@@ -218,41 +217,41 @@ func TestClusterMetricNamesStats(t *testing.T) {
|
||||
{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 != "" {
|
||||
t.Errorf("unexpected response tenant: %s (-want, +got):\n%s", tenantID, diff)
|
||||
}
|
||||
|
||||
expectedStatsResponse := apptest.TSDBStatusResponse{
|
||||
expectedStatsResponse := at.TSDBStatusResponse{
|
||||
Data: at.TSDBStatusResponseData{
|
||||
TotalSeries: 6,
|
||||
TotalLabelValuePairs: 12,
|
||||
SeriesCountByMetricName: []apptest.TSDBStatusResponseMetricNameEntry{
|
||||
SeriesCountByMetricName: []at.TSDBStatusResponseMetricNameEntry{
|
||||
{Name: "metric_name_1", RequestsCount: 3},
|
||||
{Name: largeMetricName, RequestsCount: 1},
|
||||
{Name: "metric_name_2", RequestsCount: 1},
|
||||
{Name: "metric_name_3", RequestsCount: 1},
|
||||
},
|
||||
SeriesCountByLabelName: []apptest.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
||||
SeriesCountByFocusLabelValue: []apptest.TSDBStatusResponseEntry{},
|
||||
SeriesCountByLabelValuePair: []apptest.TSDBStatusResponseEntry{
|
||||
SeriesCountByLabelName: []at.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
||||
SeriesCountByFocusLabelValue: []at.TSDBStatusResponseEntry{},
|
||||
SeriesCountByLabelValuePair: []at.TSDBStatusResponseEntry{
|
||||
{Name: "__name__=" + largeMetricName},
|
||||
{Name: "__name__=metric_name_1"}, {Name: "label=baz"},
|
||||
{Name: "__name__=metric_name_2"}, {Name: "__name__=metric_name_3"},
|
||||
{Name: "label=bar"}, {Name: "label=foo"},
|
||||
},
|
||||
LabelValueCountByLabelName: []apptest.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
||||
LabelValueCountByLabelName: []at.TSDBStatusResponseEntry{{Name: "__name__"}, {Name: "label"}},
|
||||
},
|
||||
}
|
||||
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 != "" {
|
||||
t.Errorf("unexpected APIV1StatusTSDB response tenant: %s (-want, +got):\n%s", tenantID, diff)
|
||||
}
|
||||
}
|
||||
|
||||
// verify multitenant stats
|
||||
expected := apptest.MetricNamesStatsResponse{
|
||||
expected := at.MetricNamesStatsResponse{
|
||||
Records: []at.MetricNamesStatsRecord{
|
||||
{MetricName: largeMetricName, QueryRequestsCount: 3},
|
||||
{MetricName: "metric_name_2", QueryRequestsCount: 3},
|
||||
@@ -260,14 +259,14 @@ func TestClusterMetricNamesStats(t *testing.T) {
|
||||
{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 != "" {
|
||||
t.Errorf("unexpected response (-want, +got):\n%s", diff)
|
||||
}
|
||||
|
||||
// reset cache and check empty state
|
||||
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 {
|
||||
t.Fatalf("want 0 records, got: %d", len(resp.Records))
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
||||
at "github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
@@ -377,7 +376,7 @@ func TestClusterReplication_PartialResponse(t *testing.T) {
|
||||
IsPartial: wantPartial,
|
||||
},
|
||||
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,
|
||||
},
|
||||
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,
|
||||
},
|
||||
CmpOpts: []cmp.Option{
|
||||
cmpopts.IgnoreFields(apptest.PrometheusAPIV1QueryResponse{}, "Data"),
|
||||
cmpopts.IgnoreFields(at.PrometheusAPIV1QueryResponse{}, "Data"),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -8,13 +8,12 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
||||
at "github.com/VictoriaMetrics/VictoriaMetrics/apptest"
|
||||
)
|
||||
|
||||
// TestSingleVMAgentReloadConfigs verifies that vmagent reload new configurations on SIGHUP signal
|
||||
func TestSingleVMAgentReloadConfigs(t *testing.T) {
|
||||
tc := apptest.NewTestCase(t)
|
||||
tc := at.NewTestCase(t)
|
||||
defer tc.Stop()
|
||||
|
||||
vmsingle := tc.MustStartDefaultVmsingle()
|
||||
@@ -38,7 +37,7 @@ func TestSingleVMAgentReloadConfigs(t *testing.T) {
|
||||
|
||||
vmagent.APIV1ImportPrometheus(t, []string{
|
||||
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
||||
}, apptest.QueryOpts{})
|
||||
}, at.QueryOpts{})
|
||||
|
||||
vmsingle.ForceFlush(t)
|
||||
|
||||
@@ -69,7 +68,7 @@ func TestSingleVMAgentReloadConfigs(t *testing.T) {
|
||||
|
||||
vmagent.APIV1ImportPrometheus(t, []string{
|
||||
"bar_foo 1 1652169600001", // 2022-05-10T08:00:00Z
|
||||
}, apptest.QueryOpts{})
|
||||
}, at.QueryOpts{})
|
||||
|
||||
vmsingle.ForceFlush(t)
|
||||
|
||||
@@ -101,7 +100,7 @@ func TestSingleVMAgentSnappyRemoteWrite(t *testing.T) {
|
||||
}
|
||||
|
||||
func testSingleVMAgentRemoteWrite(t *testing.T, forcePromProto bool) {
|
||||
tc := apptest.NewTestCase(t)
|
||||
tc := at.NewTestCase(t)
|
||||
defer tc.Stop()
|
||||
|
||||
vmsingle := tc.MustStartDefaultVmsingle()
|
||||
@@ -115,7 +114,7 @@ func testSingleVMAgentRemoteWrite(t *testing.T, forcePromProto bool) {
|
||||
|
||||
vmagent.APIV1ImportPrometheus(t, []string{
|
||||
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
||||
}, apptest.QueryOpts{})
|
||||
}, at.QueryOpts{})
|
||||
|
||||
vmsingle.ForceFlush(t)
|
||||
|
||||
@@ -138,7 +137,7 @@ func testSingleVMAgentRemoteWrite(t *testing.T, forcePromProto bool) {
|
||||
// - Starts with Prometheus remote write protocol using `snappy`.
|
||||
// - Does not retry `snappy`-encoded requests if they fail; instead, they are dropped.
|
||||
func TestSingleVMAgentUnsupportedMediaTypeDropIfSnappy(t *testing.T) {
|
||||
tc := apptest.NewTestCase(t)
|
||||
tc := at.NewTestCase(t)
|
||||
defer tc.Stop()
|
||||
|
||||
var remoteWriteContentEncodingsMux sync.Mutex
|
||||
@@ -164,11 +163,11 @@ func TestSingleVMAgentUnsupportedMediaTypeDropIfSnappy(t *testing.T) {
|
||||
|
||||
vmagent.APIV1ImportPrometheusNoWaitFlush(t, []string{
|
||||
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
||||
}, apptest.QueryOpts{})
|
||||
}, at.QueryOpts{})
|
||||
|
||||
vmagent.APIV1ImportPrometheusNoWaitFlush(t, []string{
|
||||
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
||||
}, apptest.QueryOpts{})
|
||||
}, at.QueryOpts{})
|
||||
|
||||
tc.Assert(&at.AssertOptions{
|
||||
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.
|
||||
// - Sends all subsequent requests using `snappy`.
|
||||
func TestSingleVMAgentDowngradeRemoteWriteProtocol(t *testing.T) {
|
||||
tc := apptest.NewTestCase(t)
|
||||
tc := at.NewTestCase(t)
|
||||
defer tc.Stop()
|
||||
|
||||
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.
|
||||
vmagent.APIV1ImportPrometheus(t, []string{
|
||||
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
||||
}, apptest.QueryOpts{})
|
||||
}, at.QueryOpts{})
|
||||
|
||||
// Send request encoded with `snappy` immediately; it succeeds without retries.
|
||||
vmagent.APIV1ImportPrometheus(t, []string{
|
||||
"foo_bar 1 1652169600000", // 2022-05-10T08:00:00Z
|
||||
}, apptest.QueryOpts{})
|
||||
}, at.QueryOpts{})
|
||||
|
||||
tc.Assert(&at.AssertOptions{
|
||||
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) {
|
||||
continue
|
||||
}
|
||||
if v == vInfPos {
|
||||
switch v {
|
||||
case vInfPos:
|
||||
a[i] = infPos
|
||||
} else if v == vInfNeg {
|
||||
case vInfNeg:
|
||||
a[i] = infNeg
|
||||
} else {
|
||||
default:
|
||||
a[i] = StaleNaN
|
||||
}
|
||||
}
|
||||
@@ -135,11 +136,12 @@ func AppendDecimalToFloat(dst []float64, va []int64, e int16) []float64 {
|
||||
if !isSpecialValue(v) {
|
||||
continue
|
||||
}
|
||||
if v == vInfPos {
|
||||
switch v {
|
||||
case vInfPos:
|
||||
a[i] = infPos
|
||||
} else if v == vInfNeg {
|
||||
case vInfNeg:
|
||||
a[i] = infNeg
|
||||
} else {
|
||||
default:
|
||||
a[i] = StaleNaN
|
||||
}
|
||||
}
|
||||
@@ -152,11 +154,12 @@ func AppendDecimalToFloat(dst []float64, va []int64, e int16) []float64 {
|
||||
if !isSpecialValue(v) {
|
||||
continue
|
||||
}
|
||||
if v == vInfPos {
|
||||
switch v {
|
||||
case vInfPos:
|
||||
a[i] = infPos
|
||||
} else if v == vInfNeg {
|
||||
case vInfNeg:
|
||||
a[i] = infNeg
|
||||
} else {
|
||||
default:
|
||||
a[i] = StaleNaN
|
||||
}
|
||||
}
|
||||
|
||||
@@ -943,7 +943,7 @@ func (uw *urlWatcher) removeObjectLocked(key string) {
|
||||
func (uw *urlWatcher) maybeUpdateDependedScrapeWorksLocked() {
|
||||
role := uw.role
|
||||
attachNodeMetadata := uw.gw.attachNodeMetadata
|
||||
if !(role == "pod" || role == "service" || (attachNodeMetadata && role == "node")) {
|
||||
if role != "pod" && role != "service" && (!attachNodeMetadata || role != "node") {
|
||||
// Nothing to update
|
||||
return
|
||||
}
|
||||
|
||||
@@ -19,14 +19,13 @@ func getAuthHeaders(cfg *apiConfig, headers http.Header, endpoint, path string)
|
||||
headers.Add("X-Ovh-Consumer", cfg.consumerKey)
|
||||
|
||||
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.consumerKey,
|
||||
"GET",
|
||||
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)))
|
||||
return headers, nil
|
||||
}
|
||||
|
||||
@@ -599,7 +599,7 @@ func TestScrapeWorkScrapeInternalStreamConcurrency(t *testing.T) {
|
||||
// see https://github.com/VictoriaMetrics/VictoriaMetrics/pull/8515#issuecomment-2741063155
|
||||
lowerExpectedDelta := pushedTimeseries.Load() - timeseriesExpectedDelta
|
||||
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)",
|
||||
pushedTimeseries.Load(),
|
||||
lowerExpectedDelta,
|
||||
|
||||
Reference in New Issue
Block a user