diff --git a/storage/remote/write_test.go b/storage/remote/write_test.go index e041496b1f..f2545337b8 100644 --- a/storage/remote/write_test.go +++ b/storage/remote/write_test.go @@ -30,15 +30,17 @@ import ( "github.com/prometheus/prometheus/model/relabel" ) -var cfg = config.RemoteWriteConfig{ - Name: "dev", - URL: &common_config.URL{ - URL: &url.URL{ - Scheme: "http", - Host: "localhost", +func testRemoteWriteConfig() *config.RemoteWriteConfig { + return &config.RemoteWriteConfig{ + Name: "dev", + URL: &common_config.URL{ + URL: &url.URL{ + Scheme: "http", + Host: "localhost", + }, }, - }, - QueueConfig: config.DefaultQueueConfig, + QueueConfig: config.DefaultQueueConfig, + } } func TestNoDuplicateWriteConfigs(t *testing.T) { @@ -136,14 +138,17 @@ func TestRestartOnNameChange(t *testing.T) { require.NoError(t, os.RemoveAll(dir)) }() + cfg := testRemoteWriteConfig() + hash, err := toHash(cfg) require.NoError(t, err) s := NewWriteStorage(nil, nil, dir, time.Millisecond, nil) + conf := &config.Config{ GlobalConfig: config.DefaultGlobalConfig, RemoteWriteConfigs: []*config.RemoteWriteConfig{ - &cfg, + cfg, }, } require.NoError(t, s.ApplyConfig(conf)) @@ -238,7 +243,7 @@ func TestUpdateExternalLabels(t *testing.T) { conf := &config.Config{ GlobalConfig: config.GlobalConfig{}, RemoteWriteConfigs: []*config.RemoteWriteConfig{ - &cfg, + testRemoteWriteConfig(), }, } hash, err := toHash(conf.RemoteWriteConfigs[0]) @@ -270,13 +275,18 @@ func TestWriteStorageApplyConfigsIdempotent(t *testing.T) { conf := &config.Config{ GlobalConfig: config.GlobalConfig{}, RemoteWriteConfigs: []*config.RemoteWriteConfig{ - &config.DefaultRemoteWriteConfig, - }, - } - // We need to set URL's so that metric creation doesn't panic. - conf.RemoteWriteConfigs[0].URL = &common_config.URL{ - URL: &url.URL{ - Host: "http://test-storage.com", + { + RemoteTimeout: config.DefaultRemoteWriteConfig.RemoteTimeout, + QueueConfig: config.DefaultRemoteWriteConfig.QueueConfig, + MetadataConfig: config.DefaultRemoteWriteConfig.MetadataConfig, + HTTPClientConfig: config.DefaultRemoteWriteConfig.HTTPClientConfig, + // We need to set URL's so that metric creation doesn't panic. + URL: &common_config.URL{ + URL: &url.URL{ + Host: "http://test-storage.com", + }, + }, + }, }, } hash, err := toHash(conf.RemoteWriteConfigs[0])