From 79a6238e195ecc1c20937036c1e3b4e3bdaddc49 Mon Sep 17 00:00:00 2001 From: George Krajcsovits Date: Thu, 26 Sep 2024 18:35:15 +0200 Subject: [PATCH] scrape/scrape_test.go: reduce the time it takes to reload the manager (#14447) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * scrape/scrape_test.go: reduce the time it takes to reload the manager TestNativeHistogramMaxSchemaSet took over 3x5s to complete because there's a minimum reload interval. I've made the testcases run in parallel and reduced the reload interval to 10ms. Now the test runs in around 0.1-0.2 seconds. Ran test 10000 times to check if it's flaky. Signed-off-by: György Krajcsovits --------- Signed-off-by: György Krajcsovits --- scrape/scrape_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scrape/scrape_test.go b/scrape/scrape_test.go index 9e49fe8ef..04fd53601 100644 --- a/scrape/scrape_test.go +++ b/scrape/scrape_test.go @@ -3773,7 +3773,9 @@ func TestNativeHistogramMaxSchemaSet(t *testing.T) { }, } for name, tc := range testcases { + tc := tc t.Run(name, func(t *testing.T) { + t.Parallel() testNativeHistogramMaxSchemaSet(t, tc.minBucketFactor, tc.expectedSchema) }) } @@ -3816,8 +3818,8 @@ func testNativeHistogramMaxSchemaSet(t *testing.T, minBucketFactor string, expec configStr := fmt.Sprintf(` global: metric_name_validation_scheme: legacy - scrape_interval: 1s - scrape_timeout: 1s + scrape_interval: 50ms + scrape_timeout: 25ms scrape_configs: - job_name: test %s @@ -3830,7 +3832,7 @@ scrape_configs: s.DB.EnableNativeHistograms() reg := prometheus.NewRegistry() - mng, err := NewManager(&Options{EnableNativeHistogramsIngestion: true}, nil, nil, s, reg) + mng, err := NewManager(&Options{DiscoveryReloadInterval: model.Duration(10 * time.Millisecond), EnableNativeHistogramsIngestion: true}, nil, nil, s, reg) require.NoError(t, err) cfg, err := config.Load(configStr, false, log.NewNopLogger()) require.NoError(t, err) @@ -3861,7 +3863,7 @@ scrape_configs: countSeries++ } return countSeries > 0 - }, 15*time.Second, 100*time.Millisecond) + }, 5*time.Second, 100*time.Millisecond) // Check that native histogram schema is as expected. q, err := s.Querier(0, math.MaxInt64)