Skip to content

Commit

Permalink
backport unit tests to alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
drodriguez-305 committed Jun 24, 2024
1 parent 4da3973 commit eda2631
Show file tree
Hide file tree
Showing 10 changed files with 307 additions and 0 deletions.
31 changes: 31 additions & 0 deletions charts/camunda-platform-alpha/test/unit/console/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,3 +744,34 @@ func (s *deploymentTemplateTest) TestInitContainers() {

s.Require().Contains(podContainers, expectedContainer)
}
func (s *deploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {
// given
options := &helm.Options{
SetValues: map[string]string{
"console.enabled": "true",
"console.dnsPolicy": "ClusterFirst",
"console.dnsConfig.nameservers[0]": "8.8.8.8",
"console.dnsConfig.searches[0]": "example.com",
},
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
// Check if dnsPolicy is set
require.NotEmpty(s.T(), deployment.Spec.Template.Spec.DNSPolicy, "dnsPolicy should not be empty")

// Check if dnsConfig is set
require.NotNil(s.T(), deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should not be nil")

expectedDNSConfig := &corev1.PodDNSConfig{
Nameservers: []string{"8.8.8.8"},
Searches: []string{"example.com"},
}

require.Equal(s.T(), expectedDNSConfig, deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}
Original file line number Diff line number Diff line change
Expand Up @@ -1081,3 +1081,33 @@ func (s *deploymentTemplateTest) TestContainerShouldSetExternalDatabaseExistingS
},
})
}
func (s *deploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {
// given
options := &helm.Options{
SetValues: map[string]string{
"identity.dnsPolicy": "ClusterFirst",
"identity.dnsConfig.nameservers[0]": "8.8.8.8",
"identity.dnsConfig.searches[0]": "example.com",
},
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
// Check if dnsPolicy is set
require.NotEmpty(s.T(), deployment.Spec.Template.Spec.DNSPolicy, "dnsPolicy should not be empty")

// Check if dnsConfig is set
require.NotNil(s.T(), deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should not be nil")

expectedDNSConfig := &corev1.PodDNSConfig{
Nameservers: []string{"8.8.8.8"},
Searches: []string{"example.com"},
}

require.Equal(s.T(), expectedDNSConfig, deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}
30 changes: 30 additions & 0 deletions charts/camunda-platform-alpha/test/unit/operate/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -981,3 +981,33 @@ func (s *deploymentTemplateTest) TestOperateSetsElasticsearchPasswordIfProvidedB
s.Require().Equal(camundaOperateElasticPassword.ValueFrom.SecretKeyRef.Name, "supersecret")
s.Require().Equal(camundaOperateZeebeElasticPassword.ValueFrom.SecretKeyRef.Name, "supersecret")
}
func (s *deploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {
// given
options := &helm.Options{
SetValues: map[string]string{
"operate.dnsPolicy": "ClusterFirst",
"operate.dnsConfig.nameservers[0]": "8.8.8.8",
"operate.dnsConfig.searches[0]": "example.com",
},
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
// Check if dnsPolicy is set
require.NotEmpty(s.T(), deployment.Spec.Template.Spec.DNSPolicy, "dnsPolicy should not be empty")

// Check if dnsConfig is set
require.NotNil(s.T(), deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should not be nil")

expectedDNSConfig := &corev1.PodDNSConfig{
Nameservers: []string{"8.8.8.8"},
Searches: []string{"example.com"},
}

require.Equal(s.T(), expectedDNSConfig, deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}
Original file line number Diff line number Diff line change
Expand Up @@ -898,3 +898,33 @@ func (s *deploymentTemplateTest) TestOptimizeWithLog4j2Configuration() {
s.Require().Equal("environment-config", volume.Name)
s.Require().Equal("camunda-platform-test-optimize-configuration", volume.ConfigMap.Name)
}
func (s *deploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {
// given
options := &helm.Options{
SetValues: map[string]string{
"optimize.dnsPolicy": "ClusterFirst",
"optimize.dnsConfig.nameservers[0]": "8.8.8.8",
"optimize.dnsConfig.searches[0]": "example.com",
},
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
// Check if dnsPolicy is set
require.NotEmpty(s.T(), deployment.Spec.Template.Spec.DNSPolicy, "dnsPolicy should not be empty")

// Check if dnsConfig is set
require.NotNil(s.T(), deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should not be nil")

expectedDNSConfig := &corev1.PodDNSConfig{
Nameservers: []string{"8.8.8.8"},
Searches: []string{"example.com"},
}

require.Equal(s.T(), expectedDNSConfig, deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}
Original file line number Diff line number Diff line change
Expand Up @@ -919,3 +919,33 @@ func (s *deploymentTemplateTest) TestTasklistWithLog4j2Configuration() {
s.Require().Equal("config", volume.Name)
s.Require().Equal("camunda-platform-test-tasklist-configuration", volume.ConfigMap.Name)
}
func (s *deploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {
// given
options := &helm.Options{
SetValues: map[string]string{
"tasklist.dnsPolicy": "ClusterFirst",
"tasklist.dnsConfig.nameservers[0]": "8.8.8.8",
"tasklist.dnsConfig.searches[0]": "example.com",
},
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
// Check if dnsPolicy is set
require.NotEmpty(s.T(), deployment.Spec.Template.Spec.DNSPolicy, "dnsPolicy should not be empty")

// Check if dnsConfig is set
require.NotNil(s.T(), deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should not be nil")

expectedDNSConfig := &corev1.PodDNSConfig{
Nameservers: []string{"8.8.8.8"},
Searches: []string{"example.com"},
}

require.Equal(s.T(), expectedDNSConfig, deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}
Original file line number Diff line number Diff line change
Expand Up @@ -509,3 +509,35 @@ func (s *restapiDeploymentTemplateTest) TestContainerSetInitContainer() {

s.Require().Contains(podContainers, expectedContainer)
}
func (s *restapiDeploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {
// given
options := &helm.Options{
SetValues: map[string]string{
"webModeler.enabled": "true",
"webModeler.restapi.mail.fromAddress": "[email protected]",
"webModeler.restapi.dnsPolicy": "ClusterFirst",
"webModeler.restapi.dnsConfig.nameservers[0]": "8.8.8.8",
"webModeler.restapi.dnsConfig.searches[0]": "example.com",
},
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
// Check if dnsPolicy is set
require.NotEmpty(s.T(), deployment.Spec.Template.Spec.DNSPolicy, "dnsPolicy should not be empty")

// Check if dnsConfig is set
require.NotNil(s.T(), deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should not be nil")

expectedDNSConfig := &corev1.PodDNSConfig{
Nameservers: []string{"8.8.8.8"},
Searches: []string{"example.com"},
}

require.Equal(s.T(), expectedDNSConfig, deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,35 @@ func (s *webappDeploymentTemplateTest) TestContainerSetInitContainer() {

s.Require().Contains(podContainers, expectedContainer)
}
func (s *webappDeploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {
// given
options := &helm.Options{
SetValues: map[string]string{
"webModeler.enabled": "true",
"webModeler.restapi.mail.fromAddress": "[email protected]",
"webModeler.webapp.dnsPolicy": "ClusterFirst",
"webModeler.webapp.dnsConfig.nameservers[0]": "8.8.8.8",
"webModeler.webapp.dnsConfig.searches[0]": "example.com",
},
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
// Check if dnsPolicy is set
require.NotEmpty(s.T(), deployment.Spec.Template.Spec.DNSPolicy, "dnsPolicy should not be empty")

// Check if dnsConfig is set
require.NotNil(s.T(), deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should not be nil")

expectedDNSConfig := &corev1.PodDNSConfig{
Nameservers: []string{"8.8.8.8"},
Searches: []string{"example.com"},
}

require.Equal(s.T(), expectedDNSConfig, deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,35 @@ func (s *websocketsDeploymentTemplateTest) TestContainerSetInitContainer() {

s.Require().Contains(podContainers, expectedContainer)
}
func (s *websocketsDeploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {
// given
options := &helm.Options{
SetValues: map[string]string{
"webModeler.enabled": "true",
"webModeler.restapi.mail.fromAddress": "[email protected]",
"webModeler.websockets.dnsPolicy": "ClusterFirst",
"webModeler.websockets.dnsConfig.nameservers[0]": "8.8.8.8",
"webModeler.websockets.dnsConfig.searches[0]": "example.com",
},
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
// Check if dnsPolicy is set
require.NotEmpty(s.T(), deployment.Spec.Template.Spec.DNSPolicy, "dnsPolicy should not be empty")

// Check if dnsConfig is set
require.NotNil(s.T(), deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should not be nil")

expectedDNSConfig := &corev1.PodDNSConfig{
Nameservers: []string{"8.8.8.8"},
Searches: []string{"example.com"},
}

require.Equal(s.T(), expectedDNSConfig, deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}
Original file line number Diff line number Diff line change
Expand Up @@ -796,3 +796,33 @@ func (s *deploymentTemplateTest) TestContainerSetSidecar() {

s.Require().Contains(podContainers, expectedContainer)
}
func (s *deploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {
// given
options := &helm.Options{
SetValues: map[string]string{
"zeebeGateway.dnsPolicy": "ClusterFirst",
"zeebeGateway.dnsConfig.nameservers[0]": "8.8.8.8",
"zeebeGateway.dnsConfig.searches[0]": "example.com",
},
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
// Check if dnsPolicy is set
require.NotEmpty(s.T(), deployment.Spec.Template.Spec.DNSPolicy, "dnsPolicy should not be empty")

// Check if dnsConfig is set
require.NotNil(s.T(), deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should not be nil")

expectedDNSConfig := &corev1.PodDNSConfig{
Nameservers: []string{"8.8.8.8"},
Searches: []string{"example.com"},
}

require.Equal(s.T(), expectedDNSConfig, deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}
30 changes: 30 additions & 0 deletions charts/camunda-platform-alpha/test/unit/zeebe/statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,3 +913,33 @@ func (s *statefulSetTest) TestContainerSetSidecar() {

s.Require().Contains(podContainers, expectedContainer)
}
func (s *statefulSetTest) TestSetDnsPolicyAndDnsConfig() {
// given
options := &helm.Options{
SetValues: map[string]string{
"zeebe.dnsPolicy": "ClusterFirst",
"zeebe.dnsConfig.nameservers[0]": "8.8.8.8",
"zeebe.dnsConfig.searches[0]": "example.com",
},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

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

// then
// Check if dnsPolicy is set
require.NotEmpty(s.T(), statefulSet.Spec.Template.Spec.DNSPolicy, "dnsPolicy should not be empty")

// Check if dnsConfig is set
require.NotNil(s.T(), statefulSet.Spec.Template.Spec.DNSConfig, "dnsConfig should not be nil")

expectedDNSConfig := &corev1.PodDNSConfig{
Nameservers: []string{"8.8.8.8"},
Searches: []string{"example.com"},
}

require.Equal(s.T(), expectedDNSConfig, statefulSet.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}

0 comments on commit eda2631

Please sign in to comment.