web: prepare TestFederation_NotReady test for parallel execution

Later on in the test we override fields of handler, so we need a handler
per sub-test, rather than a global one.

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
This commit is contained in:
Mateusz Gozdek 2021-10-25 09:18:26 +02:00 committed by Julien Pivotto
parent b2c933e317
commit 2cf7479622
1 changed files with 11 additions and 10 deletions

View File

@ -253,18 +253,19 @@ func (notReadyReadStorage) Stats(string) (*tsdb.Stats, error) {
// Regression test for https://github.com/prometheus/prometheus/issues/7181.
func TestFederation_NotReady(t *testing.T) {
h := &Handler{
localStorage: notReadyReadStorage{},
lookbackDelta: 5 * time.Minute,
now: func() model.Time { return 101 * 60 * 1000 }, // 101min after epoch.
config: &config.Config{
GlobalConfig: config.GlobalConfig{},
},
}
for name, scenario := range scenarios {
t.Run(name, func(t *testing.T) {
h.config.GlobalConfig.ExternalLabels = scenario.externalLabels
h := &Handler{
localStorage: notReadyReadStorage{},
lookbackDelta: 5 * time.Minute,
now: func() model.Time { return 101 * 60 * 1000 }, // 101min after epoch.
config: &config.Config{
GlobalConfig: config.GlobalConfig{
ExternalLabels: scenario.externalLabels,
},
},
}
req := httptest.NewRequest("GET", "http://example.org/federate?"+scenario.params, nil)
res := httptest.NewRecorder()