From 9c9f8092c410ea6e6b4bf732e648f92288ff3ee8 Mon Sep 17 00:00:00 2001 From: Gary Brown Date: Mon, 3 Dec 2018 12:26:46 +0000 Subject: [PATCH] Configure sampling strategies (#139) * Configure sampling strategies Signed-off-by: Gary Brown * Add example sampling config Signed-off-by: Gary Brown * Move sampling example to separate file, and add text to README.adoc Signed-off-by: Gary Brown * Fix production test Signed-off-by: Gary Brown * Update following review comments Signed-off-by: Gary Brown * Further test fix Signed-off-by: Gary Brown --- README.adoc | 25 +++++ deploy/examples/with-sampling.yaml | 11 ++ pkg/apis/io/v1alpha1/jaeger_types.go | 6 ++ pkg/apis/io/v1alpha1/zz_generated.deepcopy.go | 18 ++++ pkg/config/sampling/sampling.go | 100 ++++++++++++++++++ pkg/config/sampling/sampling_test.go | 81 ++++++++++++++ pkg/deployment/all-in-one.go | 2 + pkg/deployment/all-in-one_test.go | 14 ++- pkg/deployment/collector.go | 9 +- pkg/deployment/collector_test.go | 14 ++- pkg/strategy/all-in-one.go | 9 +- pkg/strategy/all-in-one_test.go | 2 +- pkg/strategy/controller_test.go | 2 +- pkg/strategy/production.go | 7 ++ pkg/strategy/production_test.go | 16 ++- 15 files changed, 298 insertions(+), 18 deletions(-) create mode 100644 deploy/examples/with-sampling.yaml create mode 100644 pkg/config/sampling/sampling.go create mode 100644 pkg/config/sampling/sampling_test.go diff --git a/README.adoc b/README.adoc index 4ba582e36..e0b2ee648 100644 --- a/README.adoc +++ b/README.adoc @@ -288,6 +288,31 @@ The secrets are available as environment variables in the (Collector/Query/All-I The secret itself would be managed outside of the `jaeger-operator` CR. +== Define sampling strategies + +The operator can be used to define sampling strategies that will be supplied to tracers that have been configured +to use a remote sampler: + +[source,yaml] +---- +apiVersion: io.jaegertracing/v1alpha1 +kind: Jaeger +metadata: + name: with-sampling +spec: + strategy: allInOne + sampling: + options: + default_strategy: + type: probabilistic + param: 50 +---- + +This example defines a default sampling strategy that is probabilistic, with a 50% chance of the trace instances being +sampled. + +Refer to the Jaeger documentation on link:https://www.jaegertracing.io/docs/1.8/sampling/#collector-sampling-configuration[Collector Sampling Configuration] to see how service and endpoint sampling can be configured. The JSON representation described in that documentation can be used in the operator by converting to YAML. + == Schema migration === Cassandra diff --git a/deploy/examples/with-sampling.yaml b/deploy/examples/with-sampling.yaml new file mode 100644 index 000000000..328bf6d75 --- /dev/null +++ b/deploy/examples/with-sampling.yaml @@ -0,0 +1,11 @@ +apiVersion: io.jaegertracing/v1alpha1 +kind: Jaeger +metadata: + name: with-sampling +spec: + strategy: allInOne + sampling: + options: + default_strategy: + type: probabilistic + param: 50 diff --git a/pkg/apis/io/v1alpha1/jaeger_types.go b/pkg/apis/io/v1alpha1/jaeger_types.go index 37fb050bc..b45dea788 100644 --- a/pkg/apis/io/v1alpha1/jaeger_types.go +++ b/pkg/apis/io/v1alpha1/jaeger_types.go @@ -52,6 +52,7 @@ type JaegerSpec struct { Collector JaegerCollectorSpec `json:"collector"` Agent JaegerAgentSpec `json:"agent"` UI JaegerUISpec `json:"ui"` + Sampling JaegerSamplingSpec `json:"sampling"` Storage JaegerStorageSpec `json:"storage"` Ingress JaegerIngressSpec `json:"ingress"` JaegerCommonSpec @@ -83,6 +84,11 @@ type JaegerUISpec struct { Options FreeForm `json:"options"` } +// JaegerSamplingSpec defines the options to be used to configure the UI +type JaegerSamplingSpec struct { + Options FreeForm `json:"options"` +} + // JaegerIngressSpec defines the options to be used when deploying the query ingress type JaegerIngressSpec struct { Enabled *bool `json:"enabled"` diff --git a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go index c623090ab..b45b9bbb6 100644 --- a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go @@ -260,6 +260,23 @@ func (in *JaegerQuerySpec) DeepCopy() *JaegerQuerySpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *JaegerSamplingSpec) DeepCopyInto(out *JaegerSamplingSpec) { + *out = *in + in.Options.DeepCopyInto(&out.Options) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JaegerSamplingSpec. +func (in *JaegerSamplingSpec) DeepCopy() *JaegerSamplingSpec { + if in == nil { + return nil + } + out := new(JaegerSamplingSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *JaegerSpec) DeepCopyInto(out *JaegerSpec) { *out = *in @@ -268,6 +285,7 @@ func (in *JaegerSpec) DeepCopyInto(out *JaegerSpec) { in.Collector.DeepCopyInto(&out.Collector) in.Agent.DeepCopyInto(&out.Agent) in.UI.DeepCopyInto(&out.UI) + in.Sampling.DeepCopyInto(&out.Sampling) in.Storage.DeepCopyInto(&out.Storage) in.Ingress.DeepCopyInto(&out.Ingress) in.JaegerCommonSpec.DeepCopyInto(&out.JaegerCommonSpec) diff --git a/pkg/config/sampling/sampling.go b/pkg/config/sampling/sampling.go new file mode 100644 index 000000000..b148b3c47 --- /dev/null +++ b/pkg/config/sampling/sampling.go @@ -0,0 +1,100 @@ +package sampling + +import ( + "fmt" + + "github.com/sirupsen/logrus" + "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" +) + +const ( + defaultSamplingStrategy = "{\"default_strategy\":{\"param\":1,\"type\":\"probabilistic\"}}" +) + +// Config represents a sampling configmap +type Config struct { + jaeger *v1alpha1.Jaeger +} + +// NewConfig builds a new Config struct based on the given spec +func NewConfig(jaeger *v1alpha1.Jaeger) *Config { + return &Config{jaeger: jaeger} +} + +// Get returns a configmap specification for the current instance +func (u *Config) Get() *v1.ConfigMap { + var jsonObject []byte + var err error + + // Check for empty map + if u.jaeger.Spec.Sampling.Options.IsEmpty() { + jsonObject = []byte(defaultSamplingStrategy) + } else { + jsonObject, err = u.jaeger.Spec.Sampling.Options.MarshalJSON() + } + + if err != nil { + return nil + } + + logrus.WithField("instance", u.jaeger.Name).Debug("Assembling the Sampling configmap") + trueVar := true + + data := map[string]string{ + "sampling": string(jsonObject), + } + + return &v1.ConfigMap{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "v1", + Kind: "ConfigMap", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("%s-sampling-configuration", u.jaeger.Name), + Namespace: u.jaeger.Namespace, + OwnerReferences: []metav1.OwnerReference{ + metav1.OwnerReference{ + APIVersion: u.jaeger.APIVersion, + Kind: u.jaeger.Kind, + Name: u.jaeger.Name, + UID: u.jaeger.UID, + Controller: &trueVar, + }, + }, + }, + Data: data, + } +} + +// Update will modify the supplied common spec and options to include +// support for the Sampling configmap. +func Update(jaeger *v1alpha1.Jaeger, commonSpec *v1alpha1.JaegerCommonSpec, options *[]string) { + + volume := v1.Volume{ + Name: fmt.Sprintf("%s-sampling-configuration-volume", jaeger.Name), + VolumeSource: v1.VolumeSource{ + ConfigMap: &v1.ConfigMapVolumeSource{ + LocalObjectReference: v1.LocalObjectReference{ + Name: fmt.Sprintf("%s-sampling-configuration", jaeger.Name), + }, + Items: []v1.KeyToPath{ + v1.KeyToPath{ + Key: "sampling", + Path: "sampling.json", + }, + }, + }, + }, + } + volumeMount := v1.VolumeMount{ + Name: fmt.Sprintf("%s-sampling-configuration-volume", jaeger.Name), + MountPath: "/etc/jaeger/sampling", + ReadOnly: true, + } + commonSpec.Volumes = append(commonSpec.Volumes, volume) + commonSpec.VolumeMounts = append(commonSpec.VolumeMounts, volumeMount) + *options = append(*options, "--sampling.strategies-file=/etc/jaeger/sampling/sampling.json") +} diff --git a/pkg/config/sampling/sampling_test.go b/pkg/config/sampling/sampling_test.go new file mode 100644 index 000000000..796e8debf --- /dev/null +++ b/pkg/config/sampling/sampling_test.go @@ -0,0 +1,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) + cm := config.Get() + assert.NotNil(t, cm) + assert.Equal(t, defaultSamplingStrategy, cm.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) + cm := config.Get() + assert.NotNil(t, cm) + assert.Equal(t, defaultSamplingStrategy, cm.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) + cm := config.Get() + assert.Equal(t, json, cm.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]) +} diff --git a/pkg/deployment/all-in-one.go b/pkg/deployment/all-in-one.go index a018be3e7..e4d09c38d 100644 --- a/pkg/deployment/all-in-one.go +++ b/pkg/deployment/all-in-one.go @@ -11,6 +11,7 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" + "github.com/jaegertracing/jaeger-operator/pkg/config/sampling" "github.com/jaegertracing/jaeger-operator/pkg/configmap" "github.com/jaegertracing/jaeger-operator/pkg/service" "github.com/jaegertracing/jaeger-operator/pkg/storage" @@ -51,6 +52,7 @@ func (a *AllInOne) Get() *appsv1.Deployment { a.jaeger.Spec.Storage.Options.Filter(storage.OptionsPrefix(a.jaeger.Spec.Storage.Type))) configmap.Update(a.jaeger, commonSpec, &options) + sampling.Update(a.jaeger, commonSpec, &options) var envFromSource []v1.EnvFromSource if len(a.jaeger.Spec.Storage.SecretName) > 0 { diff --git a/pkg/deployment/all-in-one_test.go b/pkg/deployment/all-in-one_test.go index 77396d265..1641f59ea 100644 --- a/pkg/deployment/all-in-one_test.go +++ b/pkg/deployment/all-in-one_test.go @@ -112,8 +112,9 @@ func TestAllInOneVolumeMountsWithVolumes(t *testing.T) { jaeger.Spec.AllInOne.VolumeMounts = allInOneVolumeMounts podSpec := NewAllInOne(jaeger).Get().Spec.Template.Spec - assert.Len(t, podSpec.Volumes, len(append(allInOneVolumes, globalVolumes...))) - assert.Len(t, podSpec.Containers[0].VolumeMounts, len(append(allInOneVolumeMounts, globalVolumeMounts...))) + // Additional 1 is sampling configmap + assert.Len(t, podSpec.Volumes, len(append(allInOneVolumes, globalVolumes...))+1) + assert.Len(t, podSpec.Containers[0].VolumeMounts, len(append(allInOneVolumeMounts, globalVolumeMounts...))+1) // AllInOne is first while global is second assert.Equal(t, "allInOneVolume", podSpec.Volumes[0].Name) @@ -155,7 +156,8 @@ func TestAllInOneMountGlobalVolumes(t *testing.T) { jaeger.Spec.AllInOne.VolumeMounts = allInOneVolumeMounts podSpec := NewAllInOne(jaeger).Get().Spec.Template.Spec - assert.Len(t, podSpec.Containers[0].VolumeMounts, 1) + // Count includes the sampling configmap + assert.Len(t, podSpec.Containers[0].VolumeMounts, 2) // allInOne volume is mounted assert.Equal(t, podSpec.Containers[0].VolumeMounts[0].Name, "globalVolume") } @@ -182,7 +184,8 @@ func TestAllInOneVolumeMountsWithSameName(t *testing.T) { jaeger.Spec.AllInOne.VolumeMounts = allInOneVolumeMounts podSpec := NewAllInOne(jaeger).Get().Spec.Template.Spec - assert.Len(t, podSpec.Containers[0].VolumeMounts, 1) + // Count includes the sampling configmap + assert.Len(t, podSpec.Containers[0].VolumeMounts, 2) // allInOne volume is mounted assert.Equal(t, podSpec.Containers[0].VolumeMounts[0].ReadOnly, false) } @@ -209,7 +212,8 @@ func TestAllInOneVolumeWithSameName(t *testing.T) { jaeger.Spec.AllInOne.Volumes = allInOneVolumes podSpec := NewAllInOne(jaeger).Get().Spec.Template.Spec - assert.Len(t, podSpec.Volumes, 1) + // Count includes the sampling configmap + assert.Len(t, podSpec.Volumes, 2) // allInOne volume is mounted assert.Equal(t, podSpec.Volumes[0].VolumeSource.HostPath.Path, "/data2") } diff --git a/pkg/deployment/collector.go b/pkg/deployment/collector.go index b774a52ee..c6a4edf4c 100644 --- a/pkg/deployment/collector.go +++ b/pkg/deployment/collector.go @@ -11,6 +11,7 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" + "github.com/jaegertracing/jaeger-operator/pkg/config/sampling" "github.com/jaegertracing/jaeger-operator/pkg/service" "github.com/jaegertracing/jaeger-operator/pkg/storage" "github.com/jaegertracing/jaeger-operator/pkg/util" @@ -63,6 +64,11 @@ func (c *Collector) Get() *appsv1.Deployment { }) } + options := allArgs(c.jaeger.Spec.Collector.Options, + c.jaeger.Spec.Storage.Options.Filter(storage.OptionsPrefix(c.jaeger.Spec.Storage.Type))) + + sampling.Update(c.jaeger, commonSpec, &options) + return &appsv1.Deployment{ TypeMeta: metav1.TypeMeta{ APIVersion: "apps/v1", @@ -95,8 +101,7 @@ func (c *Collector) Get() *appsv1.Deployment { Containers: []v1.Container{{ Image: c.jaeger.Spec.Collector.Image, Name: "jaeger-collector", - Args: allArgs(c.jaeger.Spec.Collector.Options, - c.jaeger.Spec.Storage.Options.Filter(storage.OptionsPrefix(c.jaeger.Spec.Storage.Type))), + Args: options, Env: []v1.EnvVar{ v1.EnvVar{ Name: "SPAN_STORAGE_TYPE", diff --git a/pkg/deployment/collector_test.go b/pkg/deployment/collector_test.go index bbc806c6a..7cc99cff2 100644 --- a/pkg/deployment/collector_test.go +++ b/pkg/deployment/collector_test.go @@ -138,8 +138,9 @@ func TestCollectorVolumeMountsWithVolumes(t *testing.T) { jaeger.Spec.Collector.VolumeMounts = collectorVolumeMounts podSpec := NewCollector(jaeger).Get().Spec.Template.Spec - assert.Len(t, podSpec.Volumes, len(append(collectorVolumes, globalVolumes...))) - assert.Len(t, podSpec.Containers[0].VolumeMounts, len(append(collectorVolumeMounts, globalVolumeMounts...))) + // Additional 1 is sampling configmap + assert.Len(t, podSpec.Volumes, len(append(collectorVolumes, globalVolumes...))+1) + assert.Len(t, podSpec.Containers[0].VolumeMounts, len(append(collectorVolumeMounts, globalVolumeMounts...))+1) // collector is first while global is second assert.Equal(t, "collectorVolume", podSpec.Volumes[0].Name) @@ -170,7 +171,8 @@ func TestCollectorMountGlobalVolumes(t *testing.T) { jaeger.Spec.Collector.VolumeMounts = collectorVolumeMounts podSpec := NewCollector(jaeger).Get().Spec.Template.Spec - assert.Len(t, podSpec.Containers[0].VolumeMounts, 1) + // Count includes the sampling configmap + assert.Len(t, podSpec.Containers[0].VolumeMounts, 2) // collector volume is mounted assert.Equal(t, podSpec.Containers[0].VolumeMounts[0].Name, "globalVolume") } @@ -197,7 +199,8 @@ func TestCollectorVolumeMountsWithSameName(t *testing.T) { jaeger.Spec.Collector.VolumeMounts = collectorVolumeMounts podSpec := NewCollector(jaeger).Get().Spec.Template.Spec - assert.Len(t, podSpec.Containers[0].VolumeMounts, 1) + // Count includes the sampling configmap + assert.Len(t, podSpec.Containers[0].VolumeMounts, 2) // collector volume is mounted assert.Equal(t, podSpec.Containers[0].VolumeMounts[0].ReadOnly, false) } @@ -224,7 +227,8 @@ func TestCollectorVolumeWithSameName(t *testing.T) { jaeger.Spec.Collector.Volumes = collectorVolumes podSpec := NewCollector(jaeger).Get().Spec.Template.Spec - assert.Len(t, podSpec.Volumes, 1) + // Count includes the sampling configmap + assert.Len(t, podSpec.Volumes, 2) // collector volume is mounted assert.Equal(t, podSpec.Volumes[0].VolumeSource.HostPath.Path, "/data2") } diff --git a/pkg/strategy/all-in-one.go b/pkg/strategy/all-in-one.go index a6a77209a..d5840d7aa 100644 --- a/pkg/strategy/all-in-one.go +++ b/pkg/strategy/all-in-one.go @@ -10,6 +10,7 @@ import ( "github.com/jaegertracing/jaeger-operator/pkg/account" "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" + "github.com/jaegertracing/jaeger-operator/pkg/config/sampling" "github.com/jaegertracing/jaeger-operator/pkg/configmap" "github.com/jaegertracing/jaeger-operator/pkg/deployment" "github.com/jaegertracing/jaeger-operator/pkg/ingress" @@ -41,12 +42,18 @@ func (c *allInOneStrategy) Create() []runtime.Object { os = append(os, acc) } - // add the config map + // add the UI config map cm := configmap.NewUIConfig(c.jaeger).Get() if nil != cm { os = append(os, cm) } + // add the Sampling config map + scmp := sampling.NewConfig(c.jaeger).Get() + if nil != scmp { + os = append(os, scmp) + } + // add the deployments os = append(os, inject.OAuthProxy(c.jaeger, dep.Get())) diff --git a/pkg/strategy/all-in-one_test.go b/pkg/strategy/all-in-one_test.go index baa266d45..6f7b6178a 100644 --- a/pkg/strategy/all-in-one_test.go +++ b/pkg/strategy/all-in-one_test.go @@ -79,7 +79,7 @@ func TestDelegateAllInOneDepedencies(t *testing.T) { func assertDeploymentsAndServicesForAllInOne(t *testing.T, name string, objs []runtime.Object, hasDaemonSet bool, hasOAuthProxy bool, hasConfigMap bool) { // TODO(jpkroehling): this func deserves a refactoring already - expectedNumObjs := 5 + expectedNumObjs := 6 if hasDaemonSet { expectedNumObjs++ diff --git a/pkg/strategy/controller_test.go b/pkg/strategy/controller_test.go index 87e90c819..53ad21ee0 100644 --- a/pkg/strategy/controller_test.go +++ b/pkg/strategy/controller_test.go @@ -46,7 +46,7 @@ func TestNewControllerForProduction(t *testing.T) { ctrl := For(context.TODO(), jaeger) ds := ctrl.Create() - assert.Len(t, ds, 5) + assert.Len(t, ds, 6) } func TestUnknownStorage(t *testing.T) { diff --git a/pkg/strategy/production.go b/pkg/strategy/production.go index 8042e7e68..4e668e9e2 100644 --- a/pkg/strategy/production.go +++ b/pkg/strategy/production.go @@ -10,6 +10,7 @@ import ( "github.com/jaegertracing/jaeger-operator/pkg/account" "github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1" + "github.com/jaegertracing/jaeger-operator/pkg/config/sampling" "github.com/jaegertracing/jaeger-operator/pkg/configmap" "github.com/jaegertracing/jaeger-operator/pkg/deployment" "github.com/jaegertracing/jaeger-operator/pkg/ingress" @@ -47,6 +48,12 @@ func (c *productionStrategy) Create() []runtime.Object { os = append(os, cm) } + // add the Sampling config map + scmp := sampling.NewConfig(c.jaeger).Get() + if nil != scmp { + os = append(os, scmp) + } + // add the deployments os = append(os, collector.Get(), diff --git a/pkg/strategy/production_test.go b/pkg/strategy/production_test.go index eb8c74a7f..d477caba3 100644 --- a/pkg/strategy/production_test.go +++ b/pkg/strategy/production_test.go @@ -3,6 +3,7 @@ package strategy import ( "context" "fmt" + "strings" "testing" "github.com/spf13/viper" @@ -99,10 +100,19 @@ func TestOptionsArePassed(t *testing.T) { deployments := getDeployments(objs) for _, dep := range deployments { args := dep.Spec.Template.Spec.Containers[0].Args - assert.Len(t, args, 3) + if strings.Contains(dep.Name, "collector") { + // Including parameter for sampling config + assert.Len(t, args, 4) + } else { + assert.Len(t, args, 3) + } + var escount int for _, arg := range args { - assert.Contains(t, arg, "es.") + if strings.Contains(arg, "es.") { + escount++ + } } + assert.Equal(t, 3, escount) } } @@ -113,7 +123,7 @@ func TestDelegateProductionDepedencies(t *testing.T) { } func assertDeploymentsAndServicesForProduction(t *testing.T, name string, objs []runtime.Object, hasDaemonSet bool, hasOAuthProxy bool, hasConfigMap bool) { - expectedNumObjs := 5 + expectedNumObjs := 6 if hasDaemonSet { expectedNumObjs++