-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Expand file tree
/
Copy pathand_helper_test.go
More file actions
52 lines (45 loc) · 1.48 KB
/
and_helper_test.go
File metadata and controls
52 lines (45 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package tailsamplingprocessor
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componenttest"
"go.uber.org/zap"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor/internal/sampling"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor/pkg/samplingpolicy"
)
func TestAndHelper(t *testing.T) {
t.Run("valid", func(t *testing.T) {
actual, err := getNewAndPolicy(componenttest.NewNopTelemetrySettings(), &AndCfg{
SubPolicyCfg: []AndSubPolicyCfg{
{
sharedPolicyCfg: sharedPolicyCfg{
Name: "test-and-policy-1",
Type: Latency,
LatencyCfg: LatencyCfg{ThresholdMs: 100},
},
},
},
}, nil)
require.NoError(t, err)
expected := sampling.NewAnd(zap.NewNop(), []samplingpolicy.Evaluator{
sampling.NewLatency(componenttest.NewNopTelemetrySettings(), 100, 0),
})
assert.Equal(t, expected, actual)
})
t.Run("unsupported sampling policy type", func(t *testing.T) {
_, err := getNewAndPolicy(componenttest.NewNopTelemetrySettings(), &AndCfg{
SubPolicyCfg: []AndSubPolicyCfg{
{
sharedPolicyCfg: sharedPolicyCfg{
Name: "test-and-policy-2",
Type: And, // nested and is not allowed
},
},
},
}, nil)
require.EqualError(t, err, "unknown sampling policy type and")
})
}