Skip to content

Commit

Permalink
US-392813 Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaslak92 committed Dec 21, 2020
1 parent 800c145 commit a0f9d1c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions terratest/src/test/pega/pega-tier-hpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,25 @@ 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"})
VerifyPegaHpa(t, &pegaHpaObj, hpa{"pega-web-hpa", "pega-web", "Deployment", "apps/v1"}, true, true)
} else {
VerifyPegaHpa(t, &pegaHpaObj, hpa{"pega-batch-hpa", "pega-batch", "Deployment", "apps/v1"})
VerifyPegaHpa(t, &pegaHpaObj, hpa{"pega-batch-hpa", "pega-batch", "Deployment", "apps/v1"}, true, 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) {
func VerifyPegaHpa(t *testing.T, hpaObj *autoscaling.HorizontalPodAutoscaler, expectedHpa hpa, shouldHaveCpuTarget bool, 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)
require.Equal(t, hpaObj.Spec.Metrics[0].Resource.Name, api.ResourceName("cpu"))
require.Equal(t, hpaObj.Spec.Metrics[1].Resource.Name, api.ResourceName("memory"))
if shouldHaveCpuTarget {
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"))
}
require.Equal(t, hpaObj.Spec.MaxReplicas, int32(5))
}

Expand Down

0 comments on commit a0f9d1c

Please sign in to comment.