Merge pull request #12296 from rsc/loopvar

scrape: fix two loop variable scoping bugs in test
This commit is contained in:
Julien Pivotto 2023-04-27 11:24:04 +02:00 committed by GitHub
commit 24d7e5bd49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -190,8 +190,9 @@ func TestScrapePoolStop(t *testing.T) {
labels: labels.FromStrings(model.AddressLabel, fmt.Sprintf("example.com:%d", i)),
}
l := &testLoop{}
d := time.Duration((i+1)*20) * time.Millisecond
l.stopFunc = func() {
time.Sleep(time.Duration(i*20) * time.Millisecond)
time.Sleep(d)
mtx.Lock()
stopped[t.hash()] = true
@ -273,8 +274,9 @@ func TestScrapePoolReload(t *testing.T) {
discoveredLabels: labels,
}
l := &testLoop{}
d := time.Duration((i+1)*20) * time.Millisecond
l.stopFunc = func() {
time.Sleep(time.Duration(i*20) * time.Millisecond)
time.Sleep(d)
mtx.Lock()
stopped[t.hash()] = true