@@ -51,7 +51,7 @@ var _ = Describe("Watcher controller with minimal spec values", func() {
5151 Expect (* (Watcher .Spec .DatabaseAccount )).Should (Equal ("watcher" ))
5252 Expect (* (Watcher .Spec .Secret )).Should (Equal ("osp-secret" ))
5353 Expect (* (Watcher .Spec .PasswordSelectors .Service )).Should (Equal ("WatcherPassword" ))
54- Expect (* ( Watcher .Spec .RabbitMqClusterName ) ).Should (Equal ("rabbitmq" ))
54+ Expect (Watcher .Spec .MessagingBus . Cluster ).Should (Equal ("rabbitmq" ))
5555 Expect (* (Watcher .Spec .ServiceUser )).Should (Equal ("watcher" ))
5656 Expect (Watcher .Spec .PreserveJobs ).Should (BeFalse ())
5757 Expect (Watcher .Spec .APIServiceTemplate .TLS .CaBundleSecretName ).Should (Equal ("" ))
@@ -100,7 +100,7 @@ var _ = Describe("Watcher controller", func() {
100100 Expect (* (Watcher .Spec .DatabaseAccount )).Should (Equal ("watcher" ))
101101 Expect (* (Watcher .Spec .ServiceUser )).Should (Equal ("watcher" ))
102102 Expect (* (Watcher .Spec .Secret )).Should (Equal ("test-osp-secret" ))
103- Expect (* ( Watcher .Spec .RabbitMqClusterName ) ).Should (Equal ("rabbitmq" ))
103+ Expect (Watcher .Spec .MessagingBus . Cluster ).Should (Equal ("rabbitmq" ))
104104 Expect (Watcher .Spec .PreserveJobs ).Should (BeFalse ())
105105 Expect (* (Watcher .Spec .APITimeout )).To (Equal (60 ))
106106
@@ -710,7 +710,9 @@ var _ = Describe("Watcher controller", func() {
710710 It ("should raise an error for empty databaseInstance" , func () {
711711 spec := GetDefaultWatcherAPISpec ()
712712 spec ["databaseInstance" ] = ""
713- spec ["rabbitMqClusterName" ] = "rabbitmq"
713+ spec ["messagingBus" ] = map [string ]any {
714+ "cluster" : "rabbitmq" ,
715+ }
714716
715717 raw := map [string ]any {
716718 "apiVersion" : "watcher.openstack.org/v1beta1" ,
@@ -742,7 +744,9 @@ var _ = Describe("Watcher controller", func() {
742744
743745 spec := GetDefaultWatcherAPISpec ()
744746 spec ["topologyRef" ] = map [string ]any {"name" : "foo" , "namespace" : "bar" }
745- spec ["rabbitMqClusterName" ] = "rabbitmq"
747+ spec ["messagingBus" ] = map [string ]any {
748+ "cluster" : "rabbitmq" ,
749+ }
746750
747751 raw := map [string ]any {
748752 "apiVersion" : "watcher.openstack.org/v1beta1" ,
@@ -770,34 +774,18 @@ var _ = Describe("Watcher controller", func() {
770774 })
771775
772776 When ("Watcher is created with empty messagingBus.cluster" , func () {
773- It ("should raise an error for empty messagingBus.cluster" , func () {
774- spec := GetDefaultWatcherAPISpec ()
775- spec ["rabbitMqClusterName" ] = ""
777+ It ("should default messagingBus.cluster to rabbitmq" , func () {
778+ spec := GetDefaultWatcherSpec ()
776779 spec ["messagingBus" ] = map [string ]any {
777780 "cluster" : "" ,
778781 }
782+ DeferCleanup (th .DeleteInstance , CreateWatcher (watcherTest .Instance , spec ))
779783
780- raw := map [string ]any {
781- "apiVersion" : "watcher.openstack.org/v1beta1" ,
782- "kind" : "watcher" ,
783- "metadata" : map [string ]any {
784- "name" : watcherName .Name ,
785- "namespace" : watcherName .Namespace ,
786- },
787- "spec" : spec ,
788- }
789-
790- unstructuredObj := & unstructured.Unstructured {Object : raw }
791- _ , err := controllerutil .CreateOrPatch (
792- th .Ctx , th .K8sClient , unstructuredObj , func () error { return nil })
793- Expect (err ).To (HaveOccurred ())
794- // Error comes from CRD schema validation (minLength: 1) before webhook validation
795- Expect (err .Error ()).To (
796- ContainSubstring (
797- "Watcher.watcher.openstack.org \" watcher\" is invalid: " +
798- "spec.messagingBus.cluster: Invalid value: \" \" : " +
799- "spec.messagingBus.cluster in body should be at least 1 chars long" ),
800- )
784+ // Webhook should default empty cluster to "rabbitmq"
785+ Eventually (func (g Gomega ) {
786+ watcher := GetWatcher (watcherTest .Instance )
787+ g .Expect (watcher .Spec .MessagingBus .Cluster ).To (Equal ("rabbitmq" ))
788+ }, timeout , interval ).Should (Succeed ())
801789 })
802790 })
803791
@@ -850,7 +838,7 @@ var _ = Describe("Watcher controller", func() {
850838 Expect (* (Watcher .Spec .ServiceUser )).Should (Equal ("fakeuser" ))
851839 Expect (* (Watcher .Spec .Secret )).Should (Equal ("test-osp-secret" ))
852840 Expect (Watcher .Spec .PreserveJobs ).Should (BeTrue ())
853- Expect (* ( Watcher .Spec .RabbitMqClusterName ) ).Should (Equal ("rabbitmq" ))
841+ Expect (Watcher .Spec .MessagingBus . Cluster ).Should (Equal ("rabbitmq" ))
854842 Expect (Watcher .Spec .APIServiceTemplate .TLS .CaBundleSecretName ).Should (Equal ("combined-ca-bundle" ))
855843 Expect (Watcher .Spec .CustomServiceConfig ).Should (Equal ("# Global config" ))
856844 Expect (* (Watcher .Spec .PrometheusSecret )).Should (Equal ("custom-prometheus-config" ))
@@ -1632,7 +1620,9 @@ var _ = Describe("Watcher controller", func() {
16321620 When ("Watcher with notification bus instance is created" , func () {
16331621 BeforeEach (func () {
16341622 spec := GetDefaultWatcherSpec ()
1635- spec ["notificationsBusInstance" ] = ptr .To ("rabbitmq-notification" )
1623+ spec ["notificationsBus" ] = map [string ]any {
1624+ "cluster" : "rabbitmq-notification" ,
1625+ }
16361626 DeferCleanup (th .DeleteInstance , CreateWatcher (watcherTest .Instance , spec ))
16371627 DeferCleanup (k8sClient .Delete , ctx , CreateWatcherMessageBusSecret (watcherTest .Instance .Namespace , "rabbitmq-secret" ))
16381628 memcachedSpec := memcachedv1.MemcachedSpec {
@@ -1675,8 +1665,8 @@ var _ = Describe("Watcher controller", func() {
16751665
16761666 It ("should have the Spec fields with the expected values" , func () {
16771667 Watcher := GetWatcher (watcherTest .Instance )
1678- Expect (* ( Watcher .Spec .RabbitMqClusterName ) ).Should (Equal ("rabbitmq" ))
1679- Expect (* ( Watcher .Spec .NotificationsBusInstance ) ).Should (Equal ("rabbitmq-notification" ))
1668+ Expect (Watcher .Spec .MessagingBus . Cluster ).Should (Equal ("rabbitmq" ))
1669+ Expect (Watcher .Spec .NotificationsBus . Cluster ).Should (Equal ("rabbitmq-notification" ))
16801670 })
16811671
16821672 It ("should have the condition WatcherNotificationTransportURLReadyCondition set to false" , func () {
@@ -1762,9 +1752,6 @@ var _ = Describe("Watcher controller", func() {
17621752 When ("Watcher with custom messagingBus and notificationsBus is created" , func () {
17631753 BeforeEach (func () {
17641754 spec := GetDefaultWatcherSpec ()
1765- // Null out deprecated fields before setting new bus fields
1766- spec ["rabbitMqClusterName" ] = ""
1767- spec ["notificationsBusInstance" ] = ""
17681755 spec ["messagingBus" ] = map [string ]any {
17691756 "cluster" : "custom-rabbitmq" ,
17701757 "user" : "custom-rpc-user" ,
0 commit comments