Skip to content

Commit

Permalink
System tests compatibility with Openshift (rabbitmq#1051)
Browse files Browse the repository at this point in the history
Overriding rabbitmq cluster security context
in system-tests when running in Openshift.

Co-authored-by: Daniele Palaia <dpalaial@vmware.com>
  • Loading branch information
2 people authored and guozhi.li committed Jun 9, 2022
1 parent b5d673f commit 43715c8
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion system_tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import (
"os"
"os/exec"
"path/filepath"
controllerruntime "sigs.k8s.io/controller-runtime"
"strconv"
"strings"
"time"

controllerruntime "sigs.k8s.io/controller-runtime"

"gopkg.in/ini.v1"

k8sresource "k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -416,6 +417,10 @@ func newRabbitmqCluster(namespace, instanceName string) *rabbitmqv1beta1.Rabbitm
},
}

if os.Getenv("ENVIRONMENT") == "openshift" {
overrideSecurityContextForOpenshift(cluster)
}

if image := os.Getenv("RABBITMQ_IMAGE"); image != "" {
cluster.Spec.Image = image
}
Expand All @@ -428,6 +433,27 @@ func newRabbitmqCluster(namespace, instanceName string) *rabbitmqv1beta1.Rabbitm
return cluster
}

func overrideSecurityContextForOpenshift(cluster *rabbitmqv1beta1.RabbitmqCluster) {

cluster.Spec.Override = rabbitmqv1beta1.RabbitmqClusterOverrideSpec{
StatefulSet: &rabbitmqv1beta1.StatefulSet{
Spec: &rabbitmqv1beta1.StatefulSetSpec{
Template: &rabbitmqv1beta1.PodTemplateSpec{
Spec: &corev1.PodSpec{
SecurityContext: &corev1.PodSecurityContext{},
Containers: []corev1.Container{
{
Name: "rabbitmq",
},
},
},
},
},
},
}

}

//the updateFn can change properties of the RabbitmqCluster CR
func updateRabbitmqCluster(ctx context.Context, client client.Client, name, namespace string, updateFn func(*rabbitmqv1beta1.RabbitmqCluster)) error {
var result rabbitmqv1beta1.RabbitmqCluster
Expand Down

0 comments on commit 43715c8

Please sign in to comment.