-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathand_helper_test.go
51 lines (44 loc) · 1.36 KB
/
and_helper_test.go
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
// 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"
)
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},
},
},
},
})
require.NoError(t, err)
expected := sampling.NewAnd(zap.NewNop(), []sampling.PolicyEvaluator{
sampling.NewLatency(componenttest.NewNopTelemetrySettings(), 100),
})
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
},
},
},
})
require.EqualError(t, err, "unknown sampling policy type and")
})
}