@@ -11,6 +11,7 @@ package resource_test
1111
1212import (
1313 . "github.com/onsi/ginkgo"
14+ . "github.com/onsi/ginkgo/extensions/table"
1415 . "github.com/onsi/gomega"
1516 rabbitmqv1beta1 "github.com/rabbitmq/cluster-operator/api/v1beta1"
1617 "github.com/rabbitmq/cluster-operator/internal/resource"
@@ -28,7 +29,7 @@ var _ = Context("ClientServices", func() {
2829 scheme * runtime.Scheme
2930 )
3031
31- Context ("Build" , func () {
32+ Describe ("Build" , func () {
3233 BeforeEach (func () {
3334 scheme = runtime .NewScheme ()
3435 Expect (rabbitmqv1beta1 .AddToScheme (scheme )).To (Succeed ())
@@ -57,7 +58,7 @@ var _ = Context("ClientServices", func() {
5758 })
5859 })
5960
60- Context ("Update" , func () {
61+ Describe ("Update" , func () {
6162 BeforeEach (func () {
6263 scheme = runtime .NewScheme ()
6364 Expect (rabbitmqv1beta1 .AddToScheme (scheme )).To (Succeed ())
@@ -299,9 +300,27 @@ var _ = Context("ClientServices", func() {
299300 Port : 15672 ,
300301 Protocol : corev1 .ProtocolTCP ,
301302 }
302- Expect (svc .Spec .Ports ).Should (ConsistOf (amqpPort , managementPort ))
303+ Expect (svc .Spec .Ports ).To (ConsistOf (amqpPort , managementPort ))
303304 })
304305
306+ DescribeTable ("plugins exposing ports" ,
307+ func (plugin , servicePortName string , port int ) {
308+ instance .Spec .Rabbitmq .AdditionalPlugins = []rabbitmqv1beta1.Plugin {rabbitmqv1beta1 .Plugin (plugin )}
309+ Expect (serviceBuilder .Update (svc )).To (Succeed ())
310+
311+ expectedPort := corev1.ServicePort {
312+ Name : servicePortName ,
313+ Port : int32 (port ),
314+ Protocol : corev1 .ProtocolTCP ,
315+ }
316+ Expect (svc .Spec .Ports ).To (ContainElement (expectedPort ))
317+ },
318+ Entry ("MQTT" , "rabbitmq_mqtt" , "mqtt" , 1883 ),
319+ Entry ("MQTT-over-WebSockets" , "rabbitmq_web_mqtt" , "web-mqtt" , 15675 ),
320+ Entry ("STOMP" , "rabbitmq_stomp" , "stomp" , 61613 ),
321+ Entry ("STOMP-over-WebSockets" , "rabbitmq_web_stomp" , "web-stomp" , 15674 ),
322+ )
323+
305324 It ("updates the service type from ClusterIP to NodePort" , func () {
306325 svc .Spec .Type = corev1 .ServiceTypeClusterIP
307326 serviceBuilder .Instance .Spec .Service .Type = "NodePort"
0 commit comments