Compare commits

...

1 Commits

Author SHA1 Message Date
Artem Fetishev
ce3db4f99e Makefile: fix synctest tests
The `synctest` experiment has been removed in go 1.26. This causes the test
build targets to fail. To fix that, this commit removes the
`GOEXPERIMENT=synctest` env var from the build rule recipes.

This forces the go tests to expect different synctest method names and function
signatures. Thus, the synctest tests also have been fixed.

VictoriaMetrics code uses `lib/fasttime` to get the current time. This does not
work with synctest tests since they require `time.Now()` to properly override
the current time. On the other hand, the rest of the tests (and especially
benchmarks) want to continue using `lib/fasttime`. Therefore the `synctest`
build label is used to link modified version of `lib/fasttime` when the synctest
tests need to be run.

Signed-off-by: Artem Fetishev <rtm@victoriametrics.com>
2026-02-11 17:00:38 +01:00
7 changed files with 18 additions and 18 deletions

View File

@@ -443,7 +443,7 @@ fmt:
gofmt -l -w -s ./apptest gofmt -l -w -s ./apptest
vet: vet:
GOEXPERIMENT=synctest go vet ./lib/... go vet -tags=synctest ./lib/...
go vet ./app/... go vet ./app/...
go vet ./apptest/... go vet ./apptest/...
@@ -452,19 +452,19 @@ check-all: fmt vet golangci-lint govulncheck
clean-checkers: remove-golangci-lint remove-govulncheck clean-checkers: remove-golangci-lint remove-govulncheck
test: test:
GOEXPERIMENT=synctest go test ./lib/... ./app/... go test -tags=synctest ./lib/... ./app/...
test-race: test-race:
GOEXPERIMENT=synctest go test -race ./lib/... ./app/... go test -tags=synctest -race ./lib/... ./app/...
test-pure: test-pure:
GOEXPERIMENT=synctest CGO_ENABLED=0 go test ./lib/... ./app/... CGO_ENABLED=0 go test -tags=synctest ./lib/... ./app/...
test-full: test-full:
GOEXPERIMENT=synctest go test -coverprofile=coverage.txt -covermode=atomic ./lib/... ./app/... go test -tags=synctest -coverprofile=coverage.txt -covermode=atomic ./lib/... ./app/...
test-full-386: test-full-386:
GOEXPERIMENT=synctest GOARCH=386 go test -coverprofile=coverage.txt -covermode=atomic ./lib/... ./app/... GOARCH=386 go test -tags=synctest -coverprofile=coverage.txt -covermode=atomic ./lib/... ./app/...
integration-test: integration-test:
$(MAKE) apptest $(MAKE) apptest
@@ -490,11 +490,11 @@ integration-test-legacy: victoria-metrics vmbackup vmrestore
go test ./apptest/tests -run="^TestLegacySingle.*" go test ./apptest/tests -run="^TestLegacySingle.*"
benchmark: benchmark:
GOEXPERIMENT=synctest go test -bench=. ./lib/... go test -bench=. ./lib/...
go test -bench=. ./app/... go test -bench=. ./app/...
benchmark-pure: benchmark-pure:
GOEXPERIMENT=synctest CGO_ENABLED=0 go test -bench=. ./lib/... CGO_ENABLED=0 go test -bench=. ./lib/...
CGO_ENABLED=0 go test -bench=. ./app/... CGO_ENABLED=0 go test -bench=. ./app/...
vendor-update: vendor-update:
@@ -524,7 +524,7 @@ install-qtc:
golangci-lint: install-golangci-lint golangci-lint: install-golangci-lint
GOEXPERIMENT=synctest golangci-lint run golangci-lint run --build-tags=synctest
install-golangci-lint: install-golangci-lint:
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) 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)

View File

@@ -1,4 +1,4 @@
//go:build !goexperiment.synctest //go:build !synctest
package fasttime package fasttime

View File

@@ -1,4 +1,4 @@
//go:build goexperiment.synctest //go:build synctest
package fasttime package fasttime

View File

@@ -1,4 +1,4 @@
//go:build goexperiment.synctest //go:build synctest
package storage package storage
@@ -13,7 +13,7 @@ import (
func TestSearch_metricNamesIndifferentIndexDBs(t *testing.T) { func TestSearch_metricNamesIndifferentIndexDBs(t *testing.T) {
defer testRemoveAll(t) defer testRemoveAll(t)
synctest.Run(func() { synctest.Test(t, func(t *testing.T) {
const numSeries = 10 const numSeries = 10
tr := TimeRange{ tr := TimeRange{
MinTimestamp: time.Now().UnixMilli(), MinTimestamp: time.Now().UnixMilli(),

View File

@@ -1,4 +1,4 @@
//go:build goexperiment.synctest //go:build synctest
package storage package storage
@@ -289,7 +289,7 @@ func TestStorageRotateIndexDBPrefill(t *testing.T) {
f := func(t *testing.T, opts OpenOptions, prefillStart time.Duration) { f := func(t *testing.T, opts OpenOptions, prefillStart time.Duration) {
t.Helper() t.Helper()
synctest.Run(func() { synctest.Test(t, func(t *testing.T) {
// Prefill of the next partition indexDB happens during the // Prefill of the next partition indexDB happens during the
// (nextMonth-prefillStart, nextMonth] time interval. // (nextMonth-prefillStart, nextMonth] time interval.
// Advance current time right before the the beginning of that interval. // Advance current time right before the the beginning of that interval.

View File

@@ -1,4 +1,4 @@
//go:build goexperiment.synctest //go:build synctest
package streamaggr package streamaggr
@@ -16,7 +16,7 @@ import (
func TestAggregatorsSuccess(t *testing.T) { func TestAggregatorsSuccess(t *testing.T) {
f := func(inputMetrics []string, interval time.Duration, outputMetricsExpected, config, matchIdxsStrExpected string) { f := func(inputMetrics []string, interval time.Duration, outputMetricsExpected, config, matchIdxsStrExpected string) {
t.Helper() t.Helper()
synctest.Run(func() { synctest.Test(t, func(t *testing.T) {
var matchIdxs []uint32 var matchIdxs []uint32
var tssOutput []prompb.TimeSeries var tssOutput []prompb.TimeSeries
var tssOutputLock sync.Mutex var tssOutputLock sync.Mutex

View File

@@ -1,4 +1,4 @@
//go:build goexperiment.synctest //go:build synctest
package workingsetcache package workingsetcache