mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-20 19:29:10 +00:00
*: Add tests for additional configmaps being mounted.
This commit is contained in:
parent
a6cb9dec6d
commit
96c8e901cf
2 changed files with 62 additions and 0 deletions
pkg
|
@ -493,6 +493,37 @@ func TestRetention(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestAdditionalConfigMap(t *testing.T) {
|
||||
sset, err := makeStatefulSet(&monitoringv1.Alertmanager{
|
||||
Spec: monitoringv1.AlertmanagerSpec{
|
||||
ConfigMaps: []string{"test-cm1"},
|
||||
},
|
||||
}, nil, defaultTestConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error while making StatefulSet: %v", err)
|
||||
}
|
||||
|
||||
cmVolumeFound := false
|
||||
for _, v := range sset.Spec.Template.Spec.Volumes {
|
||||
if v.Name == "configmap-test-cm1" {
|
||||
cmVolumeFound = true
|
||||
}
|
||||
}
|
||||
if !cmVolumeFound {
|
||||
t.Fatal("ConfigMap volume not found")
|
||||
}
|
||||
|
||||
cmMounted := false
|
||||
for _, v := range sset.Spec.Template.Spec.Containers[0].VolumeMounts {
|
||||
if v.Name == "configmap-test-cm1" && v.MountPath == "/etc/alertmanager/configmaps/test-cm1" {
|
||||
cmMounted = true
|
||||
}
|
||||
}
|
||||
if !cmMounted {
|
||||
t.Fatal("ConfigMap volume not mounted")
|
||||
}
|
||||
}
|
||||
|
||||
func sliceContains(slice []string, match string) bool {
|
||||
contains := false
|
||||
for _, s := range slice {
|
||||
|
|
|
@ -300,6 +300,37 @@ func TestMemoryRequestNotAdjustedWhenLimitLarger2Gi(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestAdditionalConfigMap(t *testing.T) {
|
||||
sset, err := makeStatefulSet(monitoringv1.Prometheus{
|
||||
Spec: monitoringv1.PrometheusSpec{
|
||||
ConfigMaps: []string{"test-cm1"},
|
||||
},
|
||||
}, "", defaultTestConfig, nil, "")
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error while making StatefulSet: %v", err)
|
||||
}
|
||||
|
||||
cmVolumeFound := false
|
||||
for _, v := range sset.Spec.Template.Spec.Volumes {
|
||||
if v.Name == "configmap-test-cm1" {
|
||||
cmVolumeFound = true
|
||||
}
|
||||
}
|
||||
if !cmVolumeFound {
|
||||
t.Fatal("ConfigMap volume not found")
|
||||
}
|
||||
|
||||
cmMounted := false
|
||||
for _, v := range sset.Spec.Template.Spec.Containers[0].VolumeMounts {
|
||||
if v.Name == "configmap-test-cm1" && v.MountPath == "/etc/prometheus/configmaps/test-cm1" {
|
||||
cmMounted = true
|
||||
}
|
||||
}
|
||||
if !cmMounted {
|
||||
t.Fatal("ConfigMap volume not mounted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMemoryRequestAdjustedWhenOnlyLimitGiven(t *testing.T) {
|
||||
sset, err := makeStatefulSet(monitoringv1.Prometheus{
|
||||
Spec: monitoringv1.PrometheusSpec{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue