Skip to content

Commit

Permalink
Test defalt
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaslak92 committed Jan 4, 2021
1 parent ae41b93 commit b579675
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions charts/pega/templates/_pega_hpa.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
maxReplicas: 5
{{- end }}
metrics:
{{- if not .hpa.disableCPUTarget }}
{{- if (default .hpa.enableCPUTarget true) }}
- type: Resource
resource:
name: cpu
Expand All @@ -32,7 +32,7 @@ spec:
targetAverageUtilization: 70
{{- end }}
{{- end }}
{{- if not .hpa.disableMemoryTarget }}
{{- if (default .hpa.enableMemoryTarget true) }}
- type: Resource
resource:
name: memory
Expand Down
6 changes: 4 additions & 2 deletions terratest/src/test/pega/data/values_hpa_disabletarget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ global:
- name: "web"
hpa:
enabled: true
disableCPUTarget: true
enableCPUTarget: false
enableMemoryTarget: true
- name: "batch"
hpa:
enabled: true
disableMemoryTarget: true
#enableCPUTarget: true
enableMemoryTarget: false
10 changes: 4 additions & 6 deletions terratest/src/test/pega/pega-tier-hpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,20 @@ func VerifyPegaHPAs(t *testing.T, yamlContent string, options *helm.Options) {
if index >= 0 && index <= 1 {
UnmarshalK8SYaml(t, hpaInfo, &pegaHpaObj)
if index == 0 {
VerifyPegaHpa(t, &pegaHpaObj, hpa{"pega-web-hpa", "pega-web", "Deployment", "apps/v1"}, true, true)
VerifyPegaHpa(t, &pegaHpaObj, hpa{"pega-web-hpa", "pega-web", "Deployment", "apps/v1"}, true)
} else {
VerifyPegaHpa(t, &pegaHpaObj, hpa{"pega-batch-hpa", "pega-batch", "Deployment", "apps/v1"}, true, false)
VerifyPegaHpa(t, &pegaHpaObj, hpa{"pega-batch-hpa", "pega-batch", "Deployment", "apps/v1"}, false)
}
}
}
}

// VerifyPegaHpa - Performs Pega HPA assertions with the values as provided in default values.yaml
func VerifyPegaHpa(t *testing.T, hpaObj *autoscaling.HorizontalPodAutoscaler, expectedHpa hpa, shouldHaveCpuTarget bool, shouldHaveMemoryTarget bool) {
func VerifyPegaHpa(t *testing.T, hpaObj *autoscaling.HorizontalPodAutoscaler, expectedHpa hpa, shouldHaveMemoryTarget bool) {
require.Equal(t, hpaObj.Spec.ScaleTargetRef.Name, expectedHpa.targetRefName)
require.Equal(t, hpaObj.Spec.ScaleTargetRef.Kind, expectedHpa.kind)
require.Equal(t, hpaObj.Spec.ScaleTargetRef.APIVersion, expectedHpa.apiversion)
if shouldHaveCpuTarget {
require.Equal(t, hpaObj.Spec.Metrics[0].Resource.Name, api.ResourceName("cpu"))
}
require.Equal(t, hpaObj.Spec.Metrics[0].Resource.Name, api.ResourceName("cpu"))
if shouldHaveMemoryTarget {
require.Equal(t, hpaObj.Spec.Metrics[1].Resource.Name, api.ResourceName("memory"))
}
Expand Down

0 comments on commit b579675

Please sign in to comment.