mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* o7 compactor Signed-off-by: Joe Elliott <[email protected]> * wip: o7 v2 Signed-off-by: Joe Elliott <[email protected]> * test cleanup Signed-off-by: Joe Elliott <[email protected]> * remove compactor from jsonnet Signed-off-by: Joe Elliott <[email protected]> * changelog Signed-off-by: Joe Elliott <[email protected]> * gen manifest Signed-off-by: Joe Elliott <[email protected]> * config cleanup Signed-off-by: Joe Elliott <[email protected]> * docs Signed-off-by: Joe Elliott <[email protected]> * jsonnet Signed-off-by: Joe Elliott <[email protected]> * remove encoding Signed-off-by: Joe Elliott <[email protected]> * remove data encoding Signed-off-by: Joe Elliott <[email protected]> * lint and cleanup Signed-off-by: Joe Elliott <[email protected]> * unflake TestWorker\? Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]>
171 lines
4.1 KiB
Go
171 lines
4.1 KiB
Go
package tempodb
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/grafana/tempo/tempodb/encoding/common"
|
|
"github.com/grafana/tempo/tempodb/encoding/vparquet3"
|
|
"github.com/grafana/tempo/tempodb/encoding/vparquet5"
|
|
"github.com/grafana/tempo/tempodb/wal"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestApplyToOptions(t *testing.T) {
|
|
opts := common.DefaultSearchOptions()
|
|
cfg := SearchConfig{}
|
|
|
|
// test defaults
|
|
cfg.ApplyToOptions(&opts)
|
|
require.Equal(t, opts.PrefetchTraceCount, DefaultPrefetchTraceCount)
|
|
require.Equal(t, opts.ChunkSizeBytes, uint32(DefaultSearchChunkSizeBytes))
|
|
require.Equal(t, opts.ReadBufferCount, DefaultReadBufferCount)
|
|
require.Equal(t, opts.ReadBufferSize, DefaultReadBufferSize)
|
|
|
|
// test parameter fields are left alone
|
|
opts.StartPage = 1
|
|
opts.TotalPages = 2
|
|
opts.MaxBytes = 3
|
|
cfg.ApplyToOptions(&opts)
|
|
require.Equal(t, opts.StartPage, 1)
|
|
require.Equal(t, opts.TotalPages, 2)
|
|
require.Equal(t, opts.MaxBytes, 3)
|
|
|
|
// test non defaults
|
|
cfg.ChunkSizeBytes = 4
|
|
cfg.PrefetchTraceCount = 5
|
|
cfg.ReadBufferCount = 6
|
|
cfg.ReadBufferSizeBytes = 7
|
|
cfg.ApplyToOptions(&opts)
|
|
require.Equal(t, cfg.ChunkSizeBytes, uint32(4))
|
|
require.Equal(t, cfg.PrefetchTraceCount, 5)
|
|
require.Equal(t, cfg.ReadBufferCount, 6)
|
|
require.Equal(t, cfg.ReadBufferSizeBytes, 7)
|
|
}
|
|
|
|
func TestValidateConfig(t *testing.T) {
|
|
tests := []struct {
|
|
cfg *Config
|
|
expectedConfig *Config
|
|
err error
|
|
}{
|
|
// nil config fails
|
|
{
|
|
err: errors.New("config should be non-nil"),
|
|
},
|
|
// nil wal fails
|
|
{
|
|
cfg: &Config{},
|
|
err: errors.New("wal config should be non-nil"),
|
|
},
|
|
// nil block fails
|
|
{
|
|
cfg: &Config{
|
|
WAL: &wal.Config{},
|
|
},
|
|
err: errors.New("block config should be non-nil"),
|
|
},
|
|
// block version copied to wal if empty
|
|
{
|
|
cfg: &Config{
|
|
WAL: &wal.Config{},
|
|
Block: &common.BlockConfig{
|
|
BloomFP: 0.01,
|
|
BloomShardSizeBytes: 1,
|
|
Version: vparquet5.VersionString,
|
|
},
|
|
},
|
|
expectedConfig: &Config{
|
|
WAL: &wal.Config{
|
|
Version: vparquet5.VersionString,
|
|
},
|
|
Block: &common.BlockConfig{
|
|
BloomFP: 0.01,
|
|
BloomShardSizeBytes: 1,
|
|
Version: vparquet5.VersionString,
|
|
},
|
|
},
|
|
},
|
|
// block version not copied to wal if populated
|
|
{
|
|
cfg: &Config{
|
|
WAL: &wal.Config{
|
|
Version: vparquet3.VersionString,
|
|
},
|
|
Block: &common.BlockConfig{
|
|
BloomFP: 0.01,
|
|
BloomShardSizeBytes: 1,
|
|
Version: vparquet5.VersionString,
|
|
},
|
|
},
|
|
expectedConfig: &Config{
|
|
WAL: &wal.Config{
|
|
Version: vparquet3.VersionString,
|
|
},
|
|
Block: &common.BlockConfig{
|
|
BloomFP: 0.01,
|
|
BloomShardSizeBytes: 1,
|
|
Version: vparquet5.VersionString,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
err := validateConfig(test.cfg)
|
|
require.Equal(t, test.err, err)
|
|
|
|
if test.expectedConfig != nil {
|
|
require.Equal(t, test.expectedConfig, test.cfg)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestDeprecatedVersions(t *testing.T) {
|
|
tests := []struct {
|
|
cfg *Config
|
|
expectedConfig *Config
|
|
err string
|
|
}{
|
|
// block version not copied to wal if populated
|
|
{
|
|
cfg: &Config{
|
|
WAL: &wal.Config{
|
|
Version: "vParquet5-preview1", // Turned into unsupported
|
|
},
|
|
Block: &common.BlockConfig{
|
|
BloomFP: 0.01,
|
|
BloomShardSizeBytes: 1,
|
|
Version: "vParquet4",
|
|
},
|
|
},
|
|
err: "wal config validation failed: failed to validate block version vParquet5-preview1: vParquet5-preview1 is not a valid block version for creating blocks",
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
err := validateConfig(test.cfg)
|
|
if test.err == "" {
|
|
require.Equal(t, nil, err)
|
|
} else {
|
|
assert.Contains(t, err.Error(), test.err)
|
|
}
|
|
|
|
if test.expectedConfig != nil {
|
|
require.Equal(t, test.expectedConfig, test.cfg)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestValidateCompactorConfig(t *testing.T) {
|
|
compactorConfig := CompactorConfig{
|
|
MaxCompactionRange: 0,
|
|
}
|
|
|
|
expected := errors.New("compaction window can't be 0")
|
|
actual := compactorConfig.validate()
|
|
|
|
require.Equal(t, expected, actual)
|
|
}
|