Skip to content

Commit

Permalink
fix: set optimize global elasticsearch prefix (#2491)
Browse files Browse the repository at this point in the history
Co-authored-by: Ahmed AbouZaid <[email protected]>
Co-authored-by: Daniel Rodriguez <[email protected]>
  • Loading branch information
3 people authored Oct 30, 2024
1 parent 22133e0 commit 2805de0
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ spec:
value: "true"
- name: CAMUNDA_OPTIMIZE_ZEEBE_PARTITION_COUNT
value: {{ .Values.optimize.partitionCount | quote }}
- name: CAMUNDA_OPTIMIZE_ZEEBE_NAME
value: {{ .Values.global.elasticsearch.prefix }}
- name: OPTIMIZE_ELASTICSEARCH_HOST
value: {{ include "camundaPlatform.elasticsearchHost" . | quote }}
- name: OPTIMIZE_ELASTICSEARCH_HTTP_PORT
Expand Down Expand Up @@ -76,6 +78,8 @@ spec:
value: "true"
- name: CAMUNDA_OPTIMIZE_ZEEBE_PARTITION_COUNT
value: {{ .Values.optimize.partitionCount | quote }}
- name: CAMUNDA_OPTIMIZE_ZEEBE_NAME
value: {{ .Values.global.elasticsearch.prefix }}
- name: OPTIMIZE_ELASTICSEARCH_HOST
value: {{ include "camundaPlatform.elasticsearchHost" . | quote }}
- name: OPTIMIZE_ELASTICSEARCH_HTTP_PORT
Expand Down
19 changes: 19 additions & 0 deletions charts/camunda-platform-8.3/test/unit/optimize/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,3 +857,22 @@ func (s *deploymentTemplateTest) TestOptimizeMultiTenancyEnabled() {
env := deployment.Spec.Template.Spec.Containers[0].Env
s.Require().Contains(env, corev1.EnvVar{Name: "CAMUNDA_OPTIMIZE_MULTITENANCY_ENABLED", Value: "true"})
}

func (s *deploymentTemplateTest) TestOptimizeCustomZeebeName() {
// given
options := &helm.Options{
SetValues: map[string]string{
"global.elasticsearch.prefix": "custom-prefix",
},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
env := deployment.Spec.Template.Spec.Containers[0].Env
s.Require().Contains(env, corev1.EnvVar{Name: "CAMUNDA_OPTIMIZE_ZEEBE_NAME", Value: "custom-prefix"})
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ spec:
value: "true"
- name: CAMUNDA_OPTIMIZE_ZEEBE_PARTITION_COUNT
value: "3"
- name: CAMUNDA_OPTIMIZE_ZEEBE_NAME
value: zeebe-record
- name: OPTIMIZE_ELASTICSEARCH_HOST
value: "camunda-platform-test-elasticsearch"
- name: OPTIMIZE_ELASTICSEARCH_HTTP_PORT
Expand All @@ -76,6 +78,8 @@ spec:
value: "true"
- name: CAMUNDA_OPTIMIZE_ZEEBE_PARTITION_COUNT
value: "3"
- name: CAMUNDA_OPTIMIZE_ZEEBE_NAME
value: zeebe-record
- name: OPTIMIZE_ELASTICSEARCH_HOST
value: "camunda-platform-test-elasticsearch"
- name: OPTIMIZE_ELASTICSEARCH_HTTP_PORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ spec:
value: "true"
- name: CAMUNDA_OPTIMIZE_ZEEBE_PARTITION_COUNT
value: {{ .Values.optimize.partitionCount | quote }}
- name: CAMUNDA_OPTIMIZE_ZEEBE_NAME
value: {{ .Values.global.elasticsearch.prefix }}
- name: OPTIMIZE_ELASTICSEARCH_HOST
value: {{ include "camundaPlatform.elasticsearchHost" . | quote }}
- name: OPTIMIZE_ELASTICSEARCH_HTTP_PORT
Expand Down Expand Up @@ -76,6 +78,8 @@ spec:
value: "true"
- name: CAMUNDA_OPTIMIZE_ZEEBE_PARTITION_COUNT
value: {{ .Values.optimize.partitionCount | quote }}
- name: CAMUNDA_OPTIMIZE_ZEEBE_NAME
value: {{ .Values.global.elasticsearch.prefix }}
- name: OPTIMIZE_ELASTICSEARCH_HOST
value: {{ include "camundaPlatform.elasticsearchHost" . | quote }}
- name: OPTIMIZE_ELASTICSEARCH_HTTP_PORT
Expand Down
19 changes: 19 additions & 0 deletions charts/camunda-platform-8.4/test/unit/optimize/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,3 +831,22 @@ func (s *deploymentTemplateTest) TestOptimizeMultiTenancyEnabled() {
env := deployment.Spec.Template.Spec.Containers[0].Env
s.Require().Contains(env, corev1.EnvVar{Name: "CAMUNDA_OPTIMIZE_MULTITENANCY_ENABLED", Value: "true"})
}

func (s *deploymentTemplateTest) TestOptimizeCustomZeebeName() {
// given
options := &helm.Options{
SetValues: map[string]string{
"global.elasticsearch.prefix": "custom-prefix",
},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
env := deployment.Spec.Template.Spec.Containers[0].Env
s.Require().Contains(env, corev1.EnvVar{Name: "CAMUNDA_OPTIMIZE_ZEEBE_NAME", Value: "custom-prefix"})
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ spec:
value: "true"
- name: CAMUNDA_OPTIMIZE_ZEEBE_PARTITION_COUNT
value: "3"
- name: CAMUNDA_OPTIMIZE_ZEEBE_NAME
value: zeebe-record
- name: OPTIMIZE_ELASTICSEARCH_HOST
value: "camunda-platform-test-elasticsearch"
- name: OPTIMIZE_ELASTICSEARCH_HTTP_PORT
Expand All @@ -76,6 +78,8 @@ spec:
value: "true"
- name: CAMUNDA_OPTIMIZE_ZEEBE_PARTITION_COUNT
value: "3"
- name: CAMUNDA_OPTIMIZE_ZEEBE_NAME
value: zeebe-record
- name: OPTIMIZE_ELASTICSEARCH_HOST
value: "camunda-platform-test-elasticsearch"
- name: OPTIMIZE_ELASTICSEARCH_HTTP_PORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ data:
zeebe:
enabled: true
partitionCount: {{ .Values.optimize.partitionCount }}
name: {{ .Values.global.elasticsearch.prefix }}
{{- if .Values.global.elasticsearch.enabled }}
es:
Expand Down
33 changes: 30 additions & 3 deletions charts/camunda-platform-8.5/test/unit/optimize/configmap_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package optimize

import (
"path/filepath"
"strings"
"testing"

"github.com/gruntwork-io/terratest/modules/helm"
"github.com/gruntwork-io/terratest/modules/k8s"
"github.com/gruntwork-io/terratest/modules/random"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"gopkg.in/yaml.v3"
corev1 "k8s.io/api/core/v1"
"path/filepath"
"strings"
"testing"
)

type configMapTemplateTest struct {
Expand Down Expand Up @@ -60,3 +61,29 @@ func (s *configMapTemplateTest) TestContainerShouldAddContextPath() {
// then
s.Require().Equal("/optimize", configmapApplication.Container.ContextPath)
}

func (s *configMapTemplateTest) TestCustomZeebeName() {
// given
options := &helm.Options{
SetValues: map[string]string{
"global.elasticsearch.prefix": "custom-prefix",
},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
ExtraArgs: map[string][]string{"install": {"--debug"}},
}

// when

output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var configmap corev1.ConfigMap
var configmapApplication OptimizeConfigYAML
helm.UnmarshalK8SYaml(s.T(), output, &configmap)

err := yaml.Unmarshal([]byte(configmap.Data["environment-config.yaml"]), &configmapApplication)
if err != nil {
s.Fail("Failed to unmarshal yaml. error=", err)
}

// then
s.Require().Equal("custom-prefix", configmapApplication.Zeebe.Name)
}
5 changes: 5 additions & 0 deletions charts/camunda-platform-8.5/test/unit/optimize/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ package optimize

type OptimizeConfigYAML struct {
Container ContainerYAML `yaml:"container"`
Zeebe ZeebeYAML `yaml:"zeebe"`
}

type ContainerYAML struct {
ContextPath string `yaml:"contextPath"`
}

type ZeebeYAML struct {
Name string `yaml:"name"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ data:
zeebe:
enabled: true
partitionCount: {{ .Values.optimize.partitionCount }}
name: {{ .Values.global.elasticsearch.prefix }}
{{- if .Values.global.elasticsearch.enabled }}
es:
Expand Down
33 changes: 30 additions & 3 deletions charts/camunda-platform-8.6/test/unit/optimize/configmap_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package optimize

import (
"path/filepath"
"strings"
"testing"

"github.com/gruntwork-io/terratest/modules/helm"
"github.com/gruntwork-io/terratest/modules/k8s"
"github.com/gruntwork-io/terratest/modules/random"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"gopkg.in/yaml.v3"
corev1 "k8s.io/api/core/v1"
"path/filepath"
"strings"
"testing"
)

type configMapTemplateTest struct {
Expand Down Expand Up @@ -60,3 +61,29 @@ func (s *configMapTemplateTest) TestContainerShouldAddContextPath() {
// then
s.Require().Equal("/optimize", configmapApplication.Container.ContextPath)
}

func (s *configMapTemplateTest) TestCustomZeebeName() {
// given
options := &helm.Options{
SetValues: map[string]string{
"global.elasticsearch.prefix": "custom-prefix",
},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
ExtraArgs: map[string][]string{"install": {"--debug"}},
}

// when

output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var configmap corev1.ConfigMap
var configmapApplication OptimizeConfigYAML
helm.UnmarshalK8SYaml(s.T(), output, &configmap)

err := yaml.Unmarshal([]byte(configmap.Data["environment-config.yaml"]), &configmapApplication)
if err != nil {
s.Fail("Failed to unmarshal yaml. error=", err)
}

// then
s.Require().Equal("custom-prefix", configmapApplication.Zeebe.Name)
}
5 changes: 5 additions & 0 deletions charts/camunda-platform-8.6/test/unit/optimize/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ package optimize

type OptimizeConfigYAML struct {
Container ContainerYAML `yaml:"container"`
Zeebe ZeebeYAML `yaml:"zeebe"`
}

type ContainerYAML struct {
ContextPath string `yaml:"contextPath"`
}

type ZeebeYAML struct {
Name string `yaml:"name"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ data:
zeebe:
enabled: true
partitionCount: {{ .Values.optimize.partitionCount }}
name: {{ .Values.global.elasticsearch.prefix }}
{{- if .Values.global.elasticsearch.enabled }}
es:
Expand Down
33 changes: 30 additions & 3 deletions charts/camunda-platform-alpha/test/unit/optimize/configmap_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package optimize

import (
"path/filepath"
"strings"
"testing"

"github.com/gruntwork-io/terratest/modules/helm"
"github.com/gruntwork-io/terratest/modules/k8s"
"github.com/gruntwork-io/terratest/modules/random"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"gopkg.in/yaml.v3"
corev1 "k8s.io/api/core/v1"
"path/filepath"
"strings"
"testing"
)

type configMapTemplateTest struct {
Expand Down Expand Up @@ -60,3 +61,29 @@ func (s *configMapTemplateTest) TestContainerShouldAddContextPath() {
// then
s.Require().Equal("/optimize", configmapApplication.Container.ContextPath)
}

func (s *configMapTemplateTest) TestCustomZeebeName() {
// given
options := &helm.Options{
SetValues: map[string]string{
"global.elasticsearch.prefix": "custom-prefix",
},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
ExtraArgs: map[string][]string{"install": {"--debug"}},
}

// when

output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var configmap corev1.ConfigMap
var configmapApplication OptimizeConfigYAML
helm.UnmarshalK8SYaml(s.T(), output, &configmap)

err := yaml.Unmarshal([]byte(configmap.Data["environment-config.yaml"]), &configmapApplication)
if err != nil {
s.Fail("Failed to unmarshal yaml. error=", err)
}

// then
s.Require().Equal("custom-prefix", configmapApplication.Zeebe.Name)
}
5 changes: 5 additions & 0 deletions charts/camunda-platform-alpha/test/unit/optimize/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ package optimize

type OptimizeConfigYAML struct {
Container ContainerYAML `yaml:"container"`
Zeebe ZeebeYAML `yaml:"zeebe"`
}

type ContainerYAML struct {
ContextPath string `yaml:"contextPath"`
}

type ZeebeYAML struct {
Name string `yaml:"name"`
}

0 comments on commit 2805de0

Please sign in to comment.