Use only one scrapeMetrics object per test. (#13051)
The scrape loop and scrape cache should use the same instance. This brings the tests' behavior more in line with production. Signed-off-by: Paulin Todev <paulin.todev@gmail.com>
This commit is contained in:
parent
2329fba0e5
commit
0102425af1
|
@ -794,6 +794,7 @@ func TestScrapeLoopRun(t *testing.T) {
|
||||||
|
|
||||||
scraper = &testScraper{}
|
scraper = &testScraper{}
|
||||||
app = func(ctx context.Context) storage.Appender { return &nopAppender{} }
|
app = func(ctx context.Context) storage.Appender { return &nopAppender{} }
|
||||||
|
scrapeMetrics = newTestScrapeMetrics(t)
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
@ -817,7 +818,7 @@ func TestScrapeLoopRun(t *testing.T) {
|
||||||
false,
|
false,
|
||||||
nil,
|
nil,
|
||||||
false,
|
false,
|
||||||
newTestScrapeMetrics(t),
|
scrapeMetrics,
|
||||||
)
|
)
|
||||||
|
|
||||||
// The loop must terminate during the initial offset if the context
|
// The loop must terminate during the initial offset if the context
|
||||||
|
@ -876,7 +877,7 @@ func TestScrapeLoopRun(t *testing.T) {
|
||||||
false,
|
false,
|
||||||
nil,
|
nil,
|
||||||
false,
|
false,
|
||||||
newTestScrapeMetrics(t),
|
scrapeMetrics,
|
||||||
)
|
)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -976,7 +977,8 @@ func TestScrapeLoopMetadata(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
signal = make(chan struct{})
|
signal = make(chan struct{})
|
||||||
scraper = &testScraper{}
|
scraper = &testScraper{}
|
||||||
cache = newScrapeCache(newTestScrapeMetrics(t))
|
scrapeMetrics = newTestScrapeMetrics(t)
|
||||||
|
cache = newScrapeCache(scrapeMetrics)
|
||||||
)
|
)
|
||||||
defer close(signal)
|
defer close(signal)
|
||||||
|
|
||||||
|
@ -1001,7 +1003,7 @@ func TestScrapeLoopMetadata(t *testing.T) {
|
||||||
false,
|
false,
|
||||||
nil,
|
nil,
|
||||||
false,
|
false,
|
||||||
newTestScrapeMetrics(t),
|
scrapeMetrics,
|
||||||
)
|
)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue