-
Notifications
You must be signed in to change notification settings - Fork 344
/
sampling_test.go
81 lines (66 loc) · 2.59 KB
/
sampling_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package sampling
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1"
)
func TestNoSamplingConfig(t *testing.T) {
jaeger := v1alpha1.NewJaeger("TestNoSamplingConfig")
config := NewConfig(jaeger)
dep := config.Get()
assert.NotNil(t, dep)
assert.Equal(t, defaultSamplingStrategy, dep.Data["sampling"])
}
func TestWithEmptySamplingConfig(t *testing.T) {
uiconfig := v1alpha1.NewFreeForm(map[string]interface{}{})
jaeger := v1alpha1.NewJaeger("TestWithEmptySamplingConfig")
jaeger.Spec.UI.Options = uiconfig
config := NewConfig(jaeger)
dep := config.Get()
assert.NotNil(t, dep)
assert.Equal(t, defaultSamplingStrategy, dep.Data["sampling"])
}
func TestWithSamplingConfig(t *testing.T) {
samplingconfig := v1alpha1.NewFreeForm(map[string]interface{}{
"default_strategy": map[string]interface{}{
"type": "probabilistic",
"param": "20",
},
})
json := `{"default_strategy":{"param":"20","type":"probabilistic"}}`
jaeger := v1alpha1.NewJaeger("TestWithSamplingConfig")
jaeger.Spec.Sampling.Options = samplingconfig
config := NewConfig(jaeger)
dep := config.Get()
assert.Equal(t, json, dep.Data["sampling"])
}
func TestUpdateNoSamplingConfig(t *testing.T) {
jaeger := v1alpha1.NewJaeger("TestUpdateNoSamplingConfig")
commonSpec := v1alpha1.JaegerCommonSpec{}
options := []string{}
Update(jaeger, &commonSpec, &options)
assert.Len(t, commonSpec.Volumes, 1)
assert.Equal(t, "TestUpdateNoSamplingConfig-sampling-configuration-volume", commonSpec.Volumes[0].Name)
assert.Len(t, commonSpec.VolumeMounts, 1)
assert.Equal(t, "TestUpdateNoSamplingConfig-sampling-configuration-volume", commonSpec.VolumeMounts[0].Name)
assert.Len(t, options, 1)
assert.Equal(t, "--sampling.strategies-file=/etc/jaeger/sampling/sampling.json", options[0])
}
func TestUpdateWithSamplingConfig(t *testing.T) {
uiconfig := v1alpha1.NewFreeForm(map[string]interface{}{
"tracking": map[string]interface{}{
"gaID": "UA-000000-2",
},
})
jaeger := v1alpha1.NewJaeger("TestUpdateWithSamplingConfig")
jaeger.Spec.UI.Options = uiconfig
commonSpec := v1alpha1.JaegerCommonSpec{}
options := []string{}
Update(jaeger, &commonSpec, &options)
assert.Len(t, commonSpec.Volumes, 1)
assert.Equal(t, "TestUpdateWithSamplingConfig-sampling-configuration-volume", commonSpec.Volumes[0].Name)
assert.Len(t, commonSpec.VolumeMounts, 1)
assert.Equal(t, "TestUpdateWithSamplingConfig-sampling-configuration-volume", commonSpec.VolumeMounts[0].Name)
assert.Len(t, options, 1)
assert.Equal(t, "--sampling.strategies-file=/etc/jaeger/sampling/sampling.json", options[0])
}