mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34: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"
|
"github.com/prometheus/prometheus/model/relabel"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cfg = config.RemoteWriteConfig{
|
func testRemoteWriteConfig() *config.RemoteWriteConfig {
|
||||||
Name: "dev",
|
return &config.RemoteWriteConfig{
|
||||||
URL: &common_config.URL{
|
Name: "dev",
|
||||||
URL: &url.URL{
|
URL: &common_config.URL{
|
||||||
Scheme: "http",
|
URL: &url.URL{
|
||||||
Host: "localhost",
|
Scheme: "http",
|
||||||
|
Host: "localhost",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
QueueConfig: config.DefaultQueueConfig,
|
||||||
QueueConfig: config.DefaultQueueConfig,
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNoDuplicateWriteConfigs(t *testing.T) {
|
func TestNoDuplicateWriteConfigs(t *testing.T) {
|
||||||
|
@ -136,14 +138,17 @@ func TestRestartOnNameChange(t *testing.T) {
|
||||||
require.NoError(t, os.RemoveAll(dir))
|
require.NoError(t, os.RemoveAll(dir))
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
cfg := testRemoteWriteConfig()
|
||||||
|
|
||||||
hash, err := toHash(cfg)
|
hash, err := toHash(cfg)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s := NewWriteStorage(nil, nil, dir, time.Millisecond, nil)
|
s := NewWriteStorage(nil, nil, dir, time.Millisecond, nil)
|
||||||
|
|
||||||
conf := &config.Config{
|
conf := &config.Config{
|
||||||
GlobalConfig: config.DefaultGlobalConfig,
|
GlobalConfig: config.DefaultGlobalConfig,
|
||||||
RemoteWriteConfigs: []*config.RemoteWriteConfig{
|
RemoteWriteConfigs: []*config.RemoteWriteConfig{
|
||||||
&cfg,
|
cfg,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
require.NoError(t, s.ApplyConfig(conf))
|
require.NoError(t, s.ApplyConfig(conf))
|
||||||
|
@ -238,7 +243,7 @@ func TestUpdateExternalLabels(t *testing.T) {
|
||||||
conf := &config.Config{
|
conf := &config.Config{
|
||||||
GlobalConfig: config.GlobalConfig{},
|
GlobalConfig: config.GlobalConfig{},
|
||||||
RemoteWriteConfigs: []*config.RemoteWriteConfig{
|
RemoteWriteConfigs: []*config.RemoteWriteConfig{
|
||||||
&cfg,
|
testRemoteWriteConfig(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
hash, err := toHash(conf.RemoteWriteConfigs[0])
|
hash, err := toHash(conf.RemoteWriteConfigs[0])
|
||||||
|
@ -270,13 +275,18 @@ func TestWriteStorageApplyConfigsIdempotent(t *testing.T) {
|
||||||
conf := &config.Config{
|
conf := &config.Config{
|
||||||
GlobalConfig: config.GlobalConfig{},
|
GlobalConfig: config.GlobalConfig{},
|
||||||
RemoteWriteConfigs: []*config.RemoteWriteConfig{
|
RemoteWriteConfigs: []*config.RemoteWriteConfig{
|
||||||
&config.DefaultRemoteWriteConfig,
|
{
|
||||||
},
|
RemoteTimeout: config.DefaultRemoteWriteConfig.RemoteTimeout,
|
||||||
}
|
QueueConfig: config.DefaultRemoteWriteConfig.QueueConfig,
|
||||||
// We need to set URL's so that metric creation doesn't panic.
|
MetadataConfig: config.DefaultRemoteWriteConfig.MetadataConfig,
|
||||||
conf.RemoteWriteConfigs[0].URL = &common_config.URL{
|
HTTPClientConfig: config.DefaultRemoteWriteConfig.HTTPClientConfig,
|
||||||
URL: &url.URL{
|
// We need to set URL's so that metric creation doesn't panic.
|
||||||
Host: "http://test-storage.com",
|
URL: &common_config.URL{
|
||||||
|
URL: &url.URL{
|
||||||
|
Host: "http://test-storage.com",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
hash, err := toHash(conf.RemoteWriteConfigs[0])
|
hash, err := toHash(conf.RemoteWriteConfigs[0])
|
||||||
|
|
Loading…
Reference in a new issue