mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 21:24:05 -08:00
storage/remote: make tests use separate remote write configs
So tests can be run in parallel without races. Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
This commit is contained in:
parent
116552cc58
commit
d8561dbfd8
|
@ -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])
|
||||
|
|
Loading…
Reference in a new issue