Files
zeekayandHanzo Dev c16ed9fe26 Go 1.27.1, and the code it can say more simply
Modules declare go 1.27.1 and the build images follow. go fix applied the
modernizers; omitzero is not applied, since it changes what the JSON says.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-17 02:34:35 -07:00

59 lines
1.5 KiB
Go

package o11ytailsampler
import (
"path/filepath"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap/confmaptest"
"github.com/hanzoai/otel-collector/processor/o11ytailsampler/internal/metadata"
)
func TestLoadConfig(t *testing.T) {
t.Parallel()
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "tail_sampling_config.yaml"))
require.NoError(t, err)
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "").String())
require.NoError(t, err)
require.NoError(t, sub.Unmarshal(cfg))
assert.Equal(t,
cfg,
&Config{
// ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
DecisionWait: 10 * time.Second,
NumTraces: 100,
ExpectedNewTracesPerSec: 10,
PolicyCfgs: []PolicyGroupCfg{
{
Name: "test-policy-1",
Type: PolicyGroup,
Priority: 1,
SamplingPercentage: 100,
StringAttributeCfgs: []StringAttributeCfg{
{Key: "source", Values: []string{"security"}},
},
SubPolicies: []BasePolicy{
{
Name: "condition-1",
Type: PolicyGroup,
Priority: 1,
StringAttributeCfgs: []StringAttributeCfg{
{Key: "source", Values: []string{"security"}},
},
},
},
},
},
})
}