Skip to content

Commit

Permalink
Created Unit Test for new implementation and created additional contr…
Browse files Browse the repository at this point in the history
…ols on previous test in order to check backward compatibility of the new feature
  • Loading branch information
alemax22 committed Oct 2, 2024
1 parent 6c3f34e commit fd30c00
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,33 @@ func TestConstellationMessagingDeploymentWithAffinity(t *testing.T) {
require.Equal(t, "kubernetes.io/os", deploymentAffinity.NodeSelectorTerms[0].MatchExpressions[0].Key)
require.Equal(t, "In", string(deploymentAffinity.NodeSelectorTerms[0].MatchExpressions[0].Operator))
require.Equal(t, "linux", deploymentAffinity.NodeSelectorTerms[0].MatchExpressions[0].Values[0])
require.Empty(t, cllnMessagingDeploymentObj.Spec.Template.Spec.Tolerations)
}

func TestConstellationMessagingDeploymentWithTolerations(t *testing.T) {

helmChartParser := NewHelmConfigParser(
NewHelmTestFromTemplate(t, helmChartRelativePath, map[string]string{
"constellation-messaging.enabled": "true",
"constellation-messaging.name": "constellation-messaging",
"constellation-messaging.tolerations[0].key": "key1",
"constellation-messaging.tolerations[0].value": "value1",
"constellation-messaging.tolerations[0].operator": "Equal",
"constellation-messaging.tolerations[0].effect": "NotSchedule",
},
[]string{"charts/constellation-messaging/templates/messaging-deployment.yaml"}),
)

var cllnMessagingDeploymentObj appsv1.Deployment
helmChartParser.getResourceYAML(SearchResourceOption{
Name: "constellation-messaging",
Kind: "Deployment",
}, &cllnMessagingDeploymentObj)

deploymentTolerations := cllnMessagingDeploymentObj.Spec.Template.Spec.Tolerations
require.Equal(t, "key1", deploymentTolerations[0].Key)
require.Equal(t, "value1", deploymentTolerations[0].Value)
require.Equal(t, "Equal", string(deploymentTolerations[0].Operator))
require.Equal(t, "NotSchedule", string(deploymentTolerations[0].Effect))
require.Empty(t, cllnMessagingDeploymentObj.Spec.Template.Spec.Affinity)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,32 @@ func TestConstellationStaticDeploymentWithAffinity(t *testing.T) {
require.Equal(t, "kubernetes.io/os", deploymentAffinity.NodeSelectorTerms[0].MatchExpressions[0].Key)
require.Equal(t, "In", string(deploymentAffinity.NodeSelectorTerms[0].MatchExpressions[0].Operator))
require.Equal(t, "linux", deploymentAffinity.NodeSelectorTerms[0].MatchExpressions[0].Values[0])
require.Empty(t, cllnDeploymentObj.Spec.Template.Spec.Tolerations)
}

func TestConstellationStaticDeploymentWithTolerations(t *testing.T) {

helmChartParser := NewHelmConfigParser(
NewHelmTestFromTemplate(t, helmChartRelativePath, map[string]string{
"constellation.enabled": "true",
"constellation.tolerations[0].key": "key1",
"constellation.tolerations[0].value": "value1",
"constellation.tolerations[0].operator": "Equal",
"constellation.tolerations[0].effect": "NotSchedule",
},
[]string{"charts/constellation/templates/clln-deployment.yaml"}),
)

var cllnDeploymentObj appsv1.Deployment
helmChartParser.getResourceYAML(SearchResourceOption{
Name: "constellation",
Kind: "Deployment",
}, &cllnDeploymentObj)

deploymentTolerations := cllnDeploymentObj.Spec.Template.Spec.Tolerations
require.Equal(t, "key1", deploymentTolerations[0].Key)
require.Equal(t, "value1", deploymentTolerations[0].Value)
require.Equal(t, "Equal", string(deploymentTolerations[0].Operator))
require.Equal(t, "NotSchedule", string(deploymentTolerations[0].Effect))
require.Empty(t, cllnDeploymentObj.Spec.Template.Spec.Affinity)
}

0 comments on commit fd30c00

Please sign in to comment.