From 3d6f35343055e394e7fd9e3c5fa794820fc0debc Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 11 Feb 2026 16:04:11 +0100 Subject: [PATCH] deployment/docker/Makefile: update Go builder from Go1.25.7 to Go1.26.0 See https://go.dev/doc/go1.26 --- Makefile | 26 ++--- app/vmalert/manager_test.go | 2 +- app/vmalert/rule/alerting_synctest_test.go | 106 ++++++++++++++++++ app/vmalert/rule/alerting_test.go | 93 --------------- app/vmalert/rule/test_helpers.go | 4 +- app/vmctl/opentsdb/opentsdb.go | 4 +- app/vmselect/graphite/render_api.go | 2 +- app/vmui/Dockerfile-web | 4 +- deployment/docker/Makefile | 2 +- docs/victoriametrics/changelog/CHANGELOG.md | 2 +- go.mod | 2 +- lib/bytesutil/bytebuffer_test.go | 2 +- lib/fasttime/fasttime_normal.go | 2 +- lib/fasttime/fasttime_synctest.go | 2 +- lib/storage/index_db_test.go | 4 +- lib/storage/metric_id_cache.go | 8 -- lib/storage/metric_id_cache_synctest_test.go | 10 ++ .../metricsmetadata/storage_syntest_test.go | 2 +- lib/storage/search_synctest_test.go | 4 +- lib/storage/storage_synctest_test.go | 4 +- lib/streamaggr/streamaggr_synctest_test.go | 5 +- lib/workingsetcache/cache_synctest_test.go | 2 +- 22 files changed, 154 insertions(+), 138 deletions(-) create mode 100644 app/vmalert/rule/alerting_synctest_test.go diff --git a/Makefile b/Makefile index cf1d1775de..6e9d4835dd 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ EXTRA_GO_BUILD_TAGS ?= GO_BUILDINFO = -X '$(PKG_PREFIX)/lib/buildinfo.Version=$(APP_NAME)-$(DATEINFO_TAG)-$(BUILDINFO_TAG)' TAR_OWNERSHIP ?= --owner=1000 --group=1000 -GOLANGCI_LINT_VERSION := 2.7.2 +GOLANGCI_LINT_VERSION := 2.9.0 .PHONY: $(MAKECMDGOALS) @@ -443,7 +443,7 @@ fmt: gofmt -l -w -s ./apptest vet: - GOEXPERIMENT=synctest go vet ./lib/... + go vet ./lib/... go vet ./app/... go vet ./apptest/... @@ -452,19 +452,19 @@ check-all: fmt vet golangci-lint govulncheck clean-checkers: remove-golangci-lint remove-govulncheck test: - GOEXPERIMENT=synctest go test ./lib/... ./app/... + go test -tags 'synctest' ./lib/... ./app/... test-race: - GOEXPERIMENT=synctest go test -race ./lib/... ./app/... + go test -tags 'synctest' -race ./lib/... ./app/... test-pure: - GOEXPERIMENT=synctest CGO_ENABLED=0 go test ./lib/... ./app/... + CGO_ENABLED=0 go test -tags 'synctest' ./lib/... ./app/... 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: - 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: $(MAKE) apptest @@ -490,17 +490,17 @@ integration-test-legacy: victoria-metrics vmbackup vmrestore go test ./apptest/tests -run="^TestLegacySingle.*" benchmark: - GOEXPERIMENT=synctest go test -bench=. ./lib/... - go test -bench=. ./app/... + go test -run=NO_TESTS -bench=. ./lib/... + go test -run=NO_TESTS -bench=. ./app/... benchmark-pure: - GOEXPERIMENT=synctest CGO_ENABLED=0 go test -bench=. ./lib/... - CGO_ENABLED=0 go test -bench=. ./app/... + CGO_ENABLED=0 go test -run=NO_TESTS -bench=. ./lib/... + CGO_ENABLED=0 go test -run=NO_TESTS -bench=. ./app/... vendor-update: go get -u ./lib/... go get -u ./app/... - go mod tidy -compat=1.24 + go mod tidy -compat=1.26 go mod vendor app-local: @@ -524,7 +524,7 @@ install-qtc: golangci-lint: install-golangci-lint - GOEXPERIMENT=synctest golangci-lint run + golangci-lint run 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) diff --git a/app/vmalert/manager_test.go b/app/vmalert/manager_test.go index 067d3d6ecd..6f9880df7f 100644 --- a/app/vmalert/manager_test.go +++ b/app/vmalert/manager_test.go @@ -259,7 +259,7 @@ func compareGroups(t *testing.T, a, b *rule.Group) { for i, r := range a.Rules { got, want := r, b.Rules[i] if a.CreateID() != b.CreateID() { - t.Fatalf("expected to have rule %q; got %q", want.ID(), got.ID()) + t.Fatalf("expected to have rule %d; got %d", want.ID(), got.ID()) } if err := rule.CompareRules(t, want, got); err != nil { t.Fatalf("comparison error: %s", err) diff --git a/app/vmalert/rule/alerting_synctest_test.go b/app/vmalert/rule/alerting_synctest_test.go new file mode 100644 index 0000000000..2933ae8cbf --- /dev/null +++ b/app/vmalert/rule/alerting_synctest_test.go @@ -0,0 +1,106 @@ +//go:build synctest + +package rule + +import ( + "context" + "strings" + "testing" + "testing/synctest" + "time" + + "github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/datasource" + "github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/notifier" +) + +// TestAlertingRule_ActiveAtPreservedInAnnotations ensures that the fix for +// https://github.com/VictoriaMetrics/VictoriaMetrics/issues/9543 is preserved +// while allowing query templates in labels (https://github.com/VictoriaMetrics/VictoriaMetrics/issues/9783) +func TestAlertingRule_ActiveAtPreservedInAnnotations(t *testing.T) { + // wrap into synctest because of time manipulations + synctest.Test(t, func(t *testing.T) { + fq := &datasource.FakeQuerier{} + + ar := &AlertingRule{ + Name: "TestActiveAtPreservation", + Labels: map[string]string{ + "test_query_in_label": `{{ "static_value" }}`, + }, + Annotations: map[string]string{ + "description": "Alert active since {{ $activeAt }}", + }, + alerts: make(map[uint64]*notifier.Alert), + q: fq, + state: &ruleState{ + entries: make([]StateEntry, 10), + }, + } + + // Mock query result - return empty result to make suppress_for_mass_alert = false + // (no need to add anything to fq for empty result) + + // Add a metric that should trigger the alert + fq.Add(metricWithValueAndLabels(t, 1, "instance", "server1")) + + // First execution - creates new alert + ts1 := time.Now() + _, err := ar.exec(context.TODO(), ts1, 0) + if err != nil { + t.Fatalf("unexpected error on first exec: %s", err) + } + + if len(ar.alerts) != 1 { + t.Fatalf("expected 1 alert, got %d", len(ar.alerts)) + } + + firstAlert := ar.GetAlerts()[0] + // Verify first execution: activeAt should be ts1 and annotation should reflect it + if !firstAlert.ActiveAt.Equal(ts1) { + t.Fatalf("expected activeAt to be %v, got %v", ts1, firstAlert.ActiveAt) + } + + // Extract time from annotation (format will be like "Alert active since 2025-09-30 08:55:13.638551611 -0400 EDT m=+0.002928464") + expectedTimeStr := ts1.Format("2006-01-02 15:04:05") + if !strings.Contains(firstAlert.Annotations["description"], expectedTimeStr) { + t.Fatalf("first exec annotation should contain time %s, got: %s", expectedTimeStr, firstAlert.Annotations["description"]) + } + + // Second execution - should preserve activeAt in annotation + + // Ensure different timestamp with different seconds + // sleep is non-blocking thanks to synctest + time.Sleep(2 * time.Second) + ts2 := time.Now() + _, err = ar.exec(context.TODO(), ts2, 0) + if err != nil { + t.Fatalf("unexpected error on second exec: %s", err) + } + + // Get the alert again (should be the same alert) + if len(ar.alerts) != 1 { + t.Fatalf("expected 1 alert, got %d", len(ar.alerts)) + } + secondAlert := ar.GetAlerts()[0] + + // Critical test: activeAt should still be ts1, not ts2 + if !secondAlert.ActiveAt.Equal(ts1) { + t.Fatalf("activeAt should be preserved as %v, but got %v", ts1, secondAlert.ActiveAt) + } + + // Critical test: annotation should still contain ts1 time, not ts2 + if !strings.Contains(secondAlert.Annotations["description"], expectedTimeStr) { + t.Fatalf("second exec annotation should still contain original time %s, got: %s", expectedTimeStr, secondAlert.Annotations["description"]) + } + + // Additional verification: annotation should NOT contain ts2 time + ts2TimeStr := ts2.Format("2006-01-02 15:04:05") + if strings.Contains(secondAlert.Annotations["description"], ts2TimeStr) { + t.Fatalf("annotation should NOT contain new eval time %s, got: %s", ts2TimeStr, secondAlert.Annotations["description"]) + } + + // Verify query template in labels still works (this would fail if query templates were broken) + if firstAlert.Labels["test_query_in_label"] != "static_value" { + t.Fatalf("expected test_query_in_label=static_value, got %s", firstAlert.Labels["test_query_in_label"]) + } + }) +} diff --git a/app/vmalert/rule/alerting_test.go b/app/vmalert/rule/alerting_test.go index fc5d57844b..7bf124e21b 100644 --- a/app/vmalert/rule/alerting_test.go +++ b/app/vmalert/rule/alerting_test.go @@ -10,7 +10,6 @@ import ( "strings" "sync" "testing" - "testing/synctest" "time" "github.com/VictoriaMetrics/metrics" @@ -1479,95 +1478,3 @@ func TestAlertingRule_QueryTemplateInLabels(t *testing.T) { t.Fatalf("expected 'suppress_for_mass_alert' label to be 'true' or 'false', got '%s'", suppressLabel) } } - -// TestAlertingRule_ActiveAtPreservedInAnnotations ensures that the fix for -// https://github.com/VictoriaMetrics/VictoriaMetrics/issues/9543 is preserved -// while allowing query templates in labels (https://github.com/VictoriaMetrics/VictoriaMetrics/issues/9783) -func TestAlertingRule_ActiveAtPreservedInAnnotations(t *testing.T) { - // wrap into synctest because of time manipulations - synctest.Test(t, func(t *testing.T) { - fq := &datasource.FakeQuerier{} - - ar := &AlertingRule{ - Name: "TestActiveAtPreservation", - Labels: map[string]string{ - "test_query_in_label": `{{ "static_value" }}`, - }, - Annotations: map[string]string{ - "description": "Alert active since {{ $activeAt }}", - }, - alerts: make(map[uint64]*notifier.Alert), - q: fq, - state: &ruleState{ - entries: make([]StateEntry, 10), - }, - } - - // Mock query result - return empty result to make suppress_for_mass_alert = false - // (no need to add anything to fq for empty result) - - // Add a metric that should trigger the alert - fq.Add(metricWithValueAndLabels(t, 1, "instance", "server1")) - - // First execution - creates new alert - ts1 := time.Now() - _, err := ar.exec(context.TODO(), ts1, 0) - if err != nil { - t.Fatalf("unexpected error on first exec: %s", err) - } - - if len(ar.alerts) != 1 { - t.Fatalf("expected 1 alert, got %d", len(ar.alerts)) - } - - firstAlert := ar.GetAlerts()[0] - // Verify first execution: activeAt should be ts1 and annotation should reflect it - if !firstAlert.ActiveAt.Equal(ts1) { - t.Fatalf("expected activeAt to be %v, got %v", ts1, firstAlert.ActiveAt) - } - - // Extract time from annotation (format will be like "Alert active since 2025-09-30 08:55:13.638551611 -0400 EDT m=+0.002928464") - expectedTimeStr := ts1.Format("2006-01-02 15:04:05") - if !strings.Contains(firstAlert.Annotations["description"], expectedTimeStr) { - t.Fatalf("first exec annotation should contain time %s, got: %s", expectedTimeStr, firstAlert.Annotations["description"]) - } - - // Second execution - should preserve activeAt in annotation - - // Ensure different timestamp with different seconds - // sleep is non-blocking thanks to synctest - time.Sleep(2 * time.Second) - ts2 := time.Now() - _, err = ar.exec(context.TODO(), ts2, 0) - if err != nil { - t.Fatalf("unexpected error on second exec: %s", err) - } - - // Get the alert again (should be the same alert) - if len(ar.alerts) != 1 { - t.Fatalf("expected 1 alert, got %d", len(ar.alerts)) - } - secondAlert := ar.GetAlerts()[0] - - // Critical test: activeAt should still be ts1, not ts2 - if !secondAlert.ActiveAt.Equal(ts1) { - t.Fatalf("activeAt should be preserved as %v, but got %v", ts1, secondAlert.ActiveAt) - } - - // Critical test: annotation should still contain ts1 time, not ts2 - if !strings.Contains(secondAlert.Annotations["description"], expectedTimeStr) { - t.Fatalf("second exec annotation should still contain original time %s, got: %s", expectedTimeStr, secondAlert.Annotations["description"]) - } - - // Additional verification: annotation should NOT contain ts2 time - ts2TimeStr := ts2.Format("2006-01-02 15:04:05") - if strings.Contains(secondAlert.Annotations["description"], ts2TimeStr) { - t.Fatalf("annotation should NOT contain new eval time %s, got: %s", ts2TimeStr, secondAlert.Annotations["description"]) - } - - // Verify query template in labels still works (this would fail if query templates were broken) - if firstAlert.Labels["test_query_in_label"] != "static_value" { - t.Fatalf("expected test_query_in_label=static_value, got %s", firstAlert.Labels["test_query_in_label"]) - } - }) -} diff --git a/app/vmalert/rule/test_helpers.go b/app/vmalert/rule/test_helpers.go index 647d7b4cb0..2db290dbcc 100644 --- a/app/vmalert/rule/test_helpers.go +++ b/app/vmalert/rule/test_helpers.go @@ -19,13 +19,13 @@ func CompareRules(t *testing.T, a, b Rule) error { case *AlertingRule: br, ok := b.(*AlertingRule) if !ok { - return fmt.Errorf("rule %q supposed to be of type AlertingRule", b.ID()) + return fmt.Errorf("rule %d supposed to be of type AlertingRule", b.ID()) } return compareAlertingRules(t, v, br) case *RecordingRule: br, ok := b.(*RecordingRule) if !ok { - return fmt.Errorf("rule %q supposed to be of type RecordingRule", b.ID()) + return fmt.Errorf("rule %d supposed to be of type RecordingRule", b.ID()) } return compareRecordingRules(t, v, br) default: diff --git a/app/vmctl/opentsdb/opentsdb.go b/app/vmctl/opentsdb/opentsdb.go index 22f0ab8306..6a2067e2c5 100644 --- a/app/vmctl/opentsdb/opentsdb.go +++ b/app/vmctl/opentsdb/opentsdb.go @@ -109,7 +109,7 @@ func (c Client) FindMetrics(q string) ([]string, error) { return nil, fmt.Errorf("failed to send GET request to %q: %s", q, err) } if resp.StatusCode != 200 { - return nil, fmt.Errorf("bad return from OpenTSDB: %q: %v", resp.StatusCode, resp) + return nil, fmt.Errorf("bad return from OpenTSDB: %d: %v", resp.StatusCode, resp) } defer func() { _ = resp.Body.Close() }() body, err := io.ReadAll(resp.Body) @@ -133,7 +133,7 @@ func (c Client) FindSeries(metric string) ([]Meta, error) { return nil, fmt.Errorf("failed to set GET request to %q: %s", q, err) } if resp.StatusCode != 200 { - return nil, fmt.Errorf("bad return from OpenTSDB: %q: %v", resp.StatusCode, resp) + return nil, fmt.Errorf("bad return from OpenTSDB: %d: %v", resp.StatusCode, resp) } defer func() { _ = resp.Body.Close() }() body, err := io.ReadAll(resp.Body) diff --git a/app/vmselect/graphite/render_api.go b/app/vmselect/graphite/render_api.go index fa4016af1e..2d11c31e68 100644 --- a/app/vmselect/graphite/render_api.go +++ b/app/vmselect/graphite/render_api.go @@ -82,7 +82,7 @@ func RenderHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) if s := r.FormValue("maxDataPoints"); len(s) > 0 { n, err := strconv.ParseFloat(s, 64) if err != nil { - return fmt.Errorf("cannot parse maxDataPoints=%q: %w", maxDataPoints, err) + return fmt.Errorf("cannot parse maxDataPoints=%d: %w", maxDataPoints, err) } if n <= 0 { return fmt.Errorf("maxDataPoints must be greater than 0; got %f", n) diff --git a/app/vmui/Dockerfile-web b/app/vmui/Dockerfile-web index 3d373dec18..460e82b735 100644 --- a/app/vmui/Dockerfile-web +++ b/app/vmui/Dockerfile-web @@ -1,4 +1,4 @@ -FROM golang:1.25.7 AS build-web-stage +FROM golang:1.26.0 AS build-web-stage COPY build /build WORKDIR /build @@ -6,7 +6,7 @@ COPY web/ /build/ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o web-amd64 github.com/VictoriMetrics/vmui/ && \ GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o web-windows github.com/VictoriMetrics/vmui/ -FROM alpine:3.22.2 +FROM alpine:3.23.3 USER root COPY --from=build-web-stage /build/web-amd64 /app/web diff --git a/deployment/docker/Makefile b/deployment/docker/Makefile index c16188aa24..21f0278f89 100644 --- a/deployment/docker/Makefile +++ b/deployment/docker/Makefile @@ -7,7 +7,7 @@ ROOT_IMAGE ?= alpine:3.23.3 ROOT_IMAGE_SCRATCH ?= scratch CERTS_IMAGE := alpine:3.23.3 -GO_BUILDER_IMAGE := golang:1.25.7 +GO_BUILDER_IMAGE := golang:1.26.0 BUILDER_IMAGE := local/builder:2.0.0-$(shell echo $(GO_BUILDER_IMAGE) | tr :/ __)-1 BASE_IMAGE := local/base:1.1.4-$(shell echo $(ROOT_IMAGE) | tr :/ __)-$(shell echo $(CERTS_IMAGE) | tr :/ __) diff --git a/docs/victoriametrics/changelog/CHANGELOG.md b/docs/victoriametrics/changelog/CHANGELOG.md index a54ee70873..cb9bab1e87 100644 --- a/docs/victoriametrics/changelog/CHANGELOG.md +++ b/docs/victoriametrics/changelog/CHANGELOG.md @@ -26,7 +26,7 @@ See also [LTS releases](https://docs.victoriametrics.com/victoriametrics/lts-rel ## tip -* SECURITY: upgrade Go builder from Go1.25.6 to Go1.25.7. See [the list of issues addressed in Go1.25.7](https://github.com/golang/go/issues?q=milestone%3AGo1.25.7%20label%3ACherryPickApproved). +* SECURITY: upgrade Go builder from Go1.25.6 to Go1.26.0. See [Go 1.26 release notes](https://go.dev/doc/go1.26). * SECURITY: upgrade base docker image (Alpine) from 3.23.2 to 3.23.3. See [Alpine 3.23.3 release notes](https://www.alpinelinux.org/posts/Alpine-3.20.9-3.21.6-3.22.3-3.23.3-released.html). * FEATURE: [dashboards/single](https://grafana.com/grafana/dashboards/10229), [dashboards/cluster](https://grafana.com/grafana/dashboards/11176), [dashboards/vmagent](https://grafana.com/grafana/dashboards/12683): add clickable source code links to the `Logging rate` panel in `Drilldown`. Users can use it to navigate directly to the source code location that generated those logs, making debugging and code exploration easier. See [#10406](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/10406). diff --git a/go.mod b/go.mod index dbec308cb5..43257af9eb 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/VictoriaMetrics/VictoriaMetrics -go 1.25.7 +go 1.26.0 require ( cloud.google.com/go/storage v1.59.1 diff --git a/lib/bytesutil/bytebuffer_test.go b/lib/bytesutil/bytebuffer_test.go index 4d7db1933b..2dae22641f 100644 --- a/lib/bytesutil/bytebuffer_test.go +++ b/lib/bytesutil/bytebuffer_test.go @@ -169,7 +169,7 @@ func TestByteBufferRead(t *testing.T) { } r := bb.NewReader().(*reader) if r.readOffset != 0 { - t.Fatalf("unexpected r.readOffset; got %d; want %q", r.readOffset, 0) + t.Fatalf("unexpected r.readOffset; got %d; want %d", r.readOffset, 0) } rCopy := bb.NewReader().(*reader) diff --git a/lib/fasttime/fasttime_normal.go b/lib/fasttime/fasttime_normal.go index c936394062..bf966051e3 100644 --- a/lib/fasttime/fasttime_normal.go +++ b/lib/fasttime/fasttime_normal.go @@ -1,4 +1,4 @@ -//go:build !goexperiment.synctest +//go:build !synctest package fasttime diff --git a/lib/fasttime/fasttime_synctest.go b/lib/fasttime/fasttime_synctest.go index abb90cfa42..3eb8894299 100644 --- a/lib/fasttime/fasttime_synctest.go +++ b/lib/fasttime/fasttime_synctest.go @@ -1,4 +1,4 @@ -//go:build goexperiment.synctest +//go:build synctest package fasttime diff --git a/lib/storage/index_db_test.go b/lib/storage/index_db_test.go index 3f0fafbe87..4709c11a54 100644 --- a/lib/storage/index_db_test.go +++ b/lib/storage/index_db_test.go @@ -105,14 +105,14 @@ func TestMergeTagToMetricIDsRows(t *testing.T) { }) } if !checkItemsSorted(data, itemsB) { - t.Fatalf("source items aren't sorted; items:\n%q", itemsB) + t.Fatalf("source items aren't sorted; items:\n%v", itemsB) } resultData, resultItemsB := mergeTagToMetricIDsRows(data, itemsB) if len(resultItemsB) != len(expectedItems) { t.Fatalf("unexpected len(resultItemsB); got %d; want %d", len(resultItemsB), len(expectedItems)) } if !checkItemsSorted(resultData, resultItemsB) { - t.Fatalf("result items aren't sorted; items:\n%q", resultItemsB) + t.Fatalf("result items aren't sorted; items:\n%v", resultItemsB) } buf := resultData for i, it := range resultItemsB { diff --git a/lib/storage/metric_id_cache.go b/lib/storage/metric_id_cache.go index 8f7631e1f0..bab88e7941 100644 --- a/lib/storage/metric_id_cache.go +++ b/lib/storage/metric_id_cache.go @@ -65,14 +65,6 @@ func (c *metricIDCache) MustStop() { <-c.rotationStoppedCh } -func (c *metricIDCache) numShards() uint64 { - return uint64(len(c.shards)) -} - -func (c *metricIDCache) fullRotationPeriod() time.Duration { - return time.Duration(c.rotationGroupCount) * c.rotationGroupPeriod -} - func (c *metricIDCache) Stats() metricIDCacheStats { var stats metricIDCacheStats for i := range len(c.shards) { diff --git a/lib/storage/metric_id_cache_synctest_test.go b/lib/storage/metric_id_cache_synctest_test.go index 18010d8587..e28b1befb7 100644 --- a/lib/storage/metric_id_cache_synctest_test.go +++ b/lib/storage/metric_id_cache_synctest_test.go @@ -1,3 +1,5 @@ +//go:build synctest + package storage import ( @@ -9,6 +11,14 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" ) +func (c *metricIDCache) numShards() uint64 { + return uint64(len(c.shards)) +} + +func (c *metricIDCache) fullRotationPeriod() time.Duration { + return time.Duration(c.rotationGroupCount) * c.rotationGroupPeriod +} + func TestMetricIDCache_ClearedWhenUnused(t *testing.T) { // Entries that are added to the cache but then never retrieved will be // eventually removed from it. diff --git a/lib/storage/metricsmetadata/storage_syntest_test.go b/lib/storage/metricsmetadata/storage_syntest_test.go index 2de06b6009..18b3a02c85 100644 --- a/lib/storage/metricsmetadata/storage_syntest_test.go +++ b/lib/storage/metricsmetadata/storage_syntest_test.go @@ -1,4 +1,4 @@ -//go:build goexperiment.synctest +//go:build synctest package metricsmetadata diff --git a/lib/storage/search_synctest_test.go b/lib/storage/search_synctest_test.go index cd341e204e..8804bdefc3 100644 --- a/lib/storage/search_synctest_test.go +++ b/lib/storage/search_synctest_test.go @@ -1,4 +1,4 @@ -//go:build goexperiment.synctest +//go:build synctest package storage @@ -13,7 +13,7 @@ import ( func TestSearch_metricNamesIndifferentIndexDBs(t *testing.T) { defer testRemoveAll(t) - synctest.Run(func() { + synctest.Test(t, func(t *testing.T) { const numSeries = 10 tr := TimeRange{ MinTimestamp: time.Now().UnixMilli(), diff --git a/lib/storage/storage_synctest_test.go b/lib/storage/storage_synctest_test.go index 3c68f6284e..67cc4cf67c 100644 --- a/lib/storage/storage_synctest_test.go +++ b/lib/storage/storage_synctest_test.go @@ -1,4 +1,4 @@ -//go:build goexperiment.synctest +//go:build synctest package storage @@ -289,7 +289,7 @@ func TestStorageRotateIndexDBPrefill(t *testing.T) { f := func(t *testing.T, opts OpenOptions, prefillStart time.Duration) { t.Helper() - synctest.Run(func() { + synctest.Test(t, func(t *testing.T) { // Prefill of the next partition indexDB happens during the // (nextMonth-prefillStart, nextMonth] time interval. // Advance current time right before the the beginning of that interval. diff --git a/lib/streamaggr/streamaggr_synctest_test.go b/lib/streamaggr/streamaggr_synctest_test.go index d04622dabf..6d4f86d17e 100644 --- a/lib/streamaggr/streamaggr_synctest_test.go +++ b/lib/streamaggr/streamaggr_synctest_test.go @@ -1,4 +1,4 @@ -//go:build goexperiment.synctest +//go:build synctest package streamaggr @@ -16,7 +16,8 @@ import ( func TestAggregatorsSuccess(t *testing.T) { f := func(inputMetrics []string, interval time.Duration, outputMetricsExpected, config, matchIdxsStrExpected string) { t.Helper() - synctest.Run(func() { + + synctest.Test(t, func(t *testing.T) { var matchIdxs []uint32 var tssOutput []prompb.TimeSeries var tssOutputLock sync.Mutex diff --git a/lib/workingsetcache/cache_synctest_test.go b/lib/workingsetcache/cache_synctest_test.go index edc8610d76..b6d4d905b0 100644 --- a/lib/workingsetcache/cache_synctest_test.go +++ b/lib/workingsetcache/cache_synctest_test.go @@ -1,4 +1,4 @@ -//go:build goexperiment.synctest +//go:build synctest package workingsetcache