storage/remote: check errors from ApplyConfig in tests

So tests do not produce obscure errors when applying configuration
fails.

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
This commit is contained in:
Mateusz Gozdek 2021-10-25 09:24:33 +02:00 committed by Julien Pivotto
parent 4ef8c7c1d8
commit 116552cc58

View File

@ -218,7 +218,7 @@ func TestWriteStorageLifecycle(t *testing.T) {
&config.DefaultRemoteWriteConfig, &config.DefaultRemoteWriteConfig,
}, },
} }
s.ApplyConfig(conf) require.NoError(t, s.ApplyConfig(conf))
require.Equal(t, 1, len(s.queues)) require.Equal(t, 1, len(s.queues))
err = s.Close() err = s.Close()
@ -243,14 +243,14 @@ func TestUpdateExternalLabels(t *testing.T) {
} }
hash, err := toHash(conf.RemoteWriteConfigs[0]) hash, err := toHash(conf.RemoteWriteConfigs[0])
require.NoError(t, err) require.NoError(t, err)
s.ApplyConfig(conf) require.NoError(t, s.ApplyConfig(conf))
require.Equal(t, 1, len(s.queues)) require.Equal(t, 1, len(s.queues))
require.Equal(t, labels.Labels(nil), s.queues[hash].externalLabels) require.Equal(t, labels.Labels(nil), s.queues[hash].externalLabels)
conf.GlobalConfig.ExternalLabels = externalLabels conf.GlobalConfig.ExternalLabels = externalLabels
hash, err = toHash(conf.RemoteWriteConfigs[0]) hash, err = toHash(conf.RemoteWriteConfigs[0])
require.NoError(t, err) require.NoError(t, err)
s.ApplyConfig(conf) require.NoError(t, s.ApplyConfig(conf))
require.Equal(t, 1, len(s.queues)) require.Equal(t, 1, len(s.queues))
require.Equal(t, externalLabels, s.queues[hash].externalLabels) require.Equal(t, externalLabels, s.queues[hash].externalLabels)
@ -282,10 +282,10 @@ func TestWriteStorageApplyConfigsIdempotent(t *testing.T) {
hash, err := toHash(conf.RemoteWriteConfigs[0]) hash, err := toHash(conf.RemoteWriteConfigs[0])
require.NoError(t, err) require.NoError(t, err)
s.ApplyConfig(conf) require.NoError(t, s.ApplyConfig(conf))
require.Equal(t, 1, len(s.queues)) require.Equal(t, 1, len(s.queues))
s.ApplyConfig(conf) require.NoError(t, s.ApplyConfig(conf))
require.Equal(t, 1, len(s.queues)) require.Equal(t, 1, len(s.queues))
_, hashExists := s.queues[hash] _, hashExists := s.queues[hash]
require.True(t, hashExists, "Queue pointer should have remained the same") require.True(t, hashExists, "Queue pointer should have remained the same")
@ -391,7 +391,7 @@ func TestWriteStorageApplyConfigsPartialUpdate(t *testing.T) {
GlobalConfig: config.GlobalConfig{}, GlobalConfig: config.GlobalConfig{},
RemoteWriteConfigs: []*config.RemoteWriteConfig{c1, c2}, RemoteWriteConfigs: []*config.RemoteWriteConfig{c1, c2},
} }
s.ApplyConfig(conf) require.NoError(t, s.ApplyConfig(conf))
require.Equal(t, 2, len(s.queues)) require.Equal(t, 2, len(s.queues))
_, hashExists = s.queues[hashes[0]] _, hashExists = s.queues[hashes[0]]