Skip to content

Commit

Permalink
Make rabbitmq image configurable (#481)
Browse files Browse the repository at this point in the history
Make rabbitmq image configurable by setting environment variables so
that we can run system tests using the commercial rabbitmq image as well
as using the OSS rabbitmq image.
  • Loading branch information
ansd authored Nov 20, 2020
1 parent 7824d1e commit 870c6af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
6 changes: 0 additions & 6 deletions system_tests/system_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"gopkg.in/ini.v1"

rabbitmqv1beta1 "github.com/rabbitmq/cluster-operator/api/v1beta1"
corev1 "k8s.io/api/core/v1"
k8sresource "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
)
Expand Down Expand Up @@ -441,10 +439,6 @@ CONSOLE_LOG=new`
BeforeEach(func() {
instanceName := "mqtt-stomp-rabbit"
cluster = newRabbitmqCluster(namespace, instanceName)
cluster.Spec.Resources = &corev1.ResourceRequirements{
Requests: map[corev1.ResourceName]k8sresource.Quantity{},
Limits: map[corev1.ResourceName]k8sresource.Quantity{},
}
cluster.Spec.Service.Type = "NodePort"
cluster.Spec.Rabbitmq.AdditionalPlugins = []rabbitmqv1beta1.Plugin{
"rabbitmq_mqtt",
Expand Down
26 changes: 22 additions & 4 deletions system_tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type featureFlag struct {
func MustHaveEnv(name string) string {
value := os.Getenv(name)
if value == "" {
panic(fmt.Sprintf("Value '%s' not found", name))
panic(fmt.Sprintf("Environment variable '%s' not found", name))
}
return value
}
Expand Down Expand Up @@ -404,7 +404,7 @@ func getUsernameAndPassword(ctx context.Context, clientset *kubernetes.Clientset
}

func newRabbitmqCluster(namespace, instanceName string) *rabbitmqv1beta1.RabbitmqCluster {
return &rabbitmqv1beta1.RabbitmqCluster{
cluster := &rabbitmqv1beta1.RabbitmqCluster{
ObjectMeta: metav1.ObjectMeta{
Name: instanceName,
Namespace: namespace,
Expand All @@ -413,12 +413,30 @@ func newRabbitmqCluster(namespace, instanceName string) *rabbitmqv1beta1.Rabbitm
Service: rabbitmqv1beta1.RabbitmqClusterServiceSpec{
Type: "NodePort",
},
// run system tests with low resources so that they can run on GitHub actions
Resources: &corev1.ResourceRequirements{
Requests: map[corev1.ResourceName]k8sresource.Quantity{},
Limits: map[corev1.ResourceName]k8sresource.Quantity{},
Requests: map[corev1.ResourceName]k8sresource.Quantity{
corev1.ResourceCPU: k8sresource.MustParse("100m"),
corev1.ResourceMemory: k8sresource.MustParse("500M"),
},
Limits: map[corev1.ResourceName]k8sresource.Quantity{
corev1.ResourceCPU: k8sresource.MustParse("1000m"),
corev1.ResourceMemory: k8sresource.MustParse("500M"),
},
},
},
}

if image := os.Getenv("RABBITMQ_IMAGE"); image != "" {
cluster.Spec.Image = image
}
if secret := os.Getenv("RABBITMQ_IMAGE_PULL_SECRET"); secret != "" {
cluster.Spec.ImagePullSecrets = []corev1.LocalObjectReference{
corev1.LocalObjectReference{Name: secret},
}
}

return cluster
}

//the updateFn can change properties of the RabbitmqCluster CR
Expand Down

0 comments on commit 870c6af

Please sign in to comment.