|
|
|
@ -325,6 +325,40 @@ func TestScrapePoolReload(t *testing.T) {
|
|
|
|
|
require.Equal(t, numTargets, len(sp.loops), "Unexpected number of stopped loops after reload")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestScrapePoolReloadPreserveRelabeledIntervalTimeout(t *testing.T) {
|
|
|
|
|
reloadCfg := &config.ScrapeConfig{
|
|
|
|
|
ScrapeInterval: model.Duration(3 * time.Second),
|
|
|
|
|
ScrapeTimeout: model.Duration(2 * time.Second),
|
|
|
|
|
}
|
|
|
|
|
newLoop := func(opts scrapeLoopOptions) loop {
|
|
|
|
|
l := &testLoop{interval: time.Duration(opts.interval), timeout: time.Duration(opts.timeout)}
|
|
|
|
|
l.startFunc = func(interval, timeout time.Duration, errc chan<- error) {
|
|
|
|
|
require.Equal(t, 5*time.Second, interval, "Unexpected scrape interval")
|
|
|
|
|
require.Equal(t, 3*time.Second, timeout, "Unexpected scrape timeout")
|
|
|
|
|
}
|
|
|
|
|
return l
|
|
|
|
|
}
|
|
|
|
|
sp := &scrapePool{
|
|
|
|
|
appendable: &nopAppendable{},
|
|
|
|
|
activeTargets: map[uint64]*Target{
|
|
|
|
|
1: {
|
|
|
|
|
labels: labels.FromStrings(model.ScrapeIntervalLabel, "5s", model.ScrapeTimeoutLabel, "3s"),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
loops: map[uint64]loop{
|
|
|
|
|
1: noopLoop(),
|
|
|
|
|
},
|
|
|
|
|
newLoop: newLoop,
|
|
|
|
|
logger: nil,
|
|
|
|
|
client: http.DefaultClient,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err := sp.reload(reloadCfg)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("unable to reload configuration: %s", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestScrapePoolTargetLimit(t *testing.T) {
|
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
|
// On starting to run, new loops created on reload check whether their preceding
|
|
|
|
|