@@ -52,7 +52,7 @@ var _ = Describe("Watcher controller with minimal spec values", func() {
5252 Expect (* (Watcher .Spec .DatabaseAccount )).Should (Equal ("watcher" ))
5353 Expect (* (Watcher .Spec .Secret )).Should (Equal ("osp-secret" ))
5454 Expect (* (Watcher .Spec .PasswordSelectors .Service )).Should (Equal ("WatcherPassword" ))
55- Expect (* ( Watcher .Spec .RabbitMqClusterName ) ).Should (Equal ("rabbitmq" ))
55+ Expect (Watcher .Spec .MessagingBus . Cluster ).Should (Equal ("rabbitmq" ))
5656 Expect (* (Watcher .Spec .ServiceUser )).Should (Equal ("watcher" ))
5757 Expect (Watcher .Spec .PreserveJobs ).Should (BeFalse ())
5858 Expect (Watcher .Spec .APIServiceTemplate .TLS .CaBundleSecretName ).Should (Equal ("" ))
@@ -101,7 +101,7 @@ var _ = Describe("Watcher controller", func() {
101101 Expect (* (Watcher .Spec .DatabaseAccount )).Should (Equal ("watcher" ))
102102 Expect (* (Watcher .Spec .ServiceUser )).Should (Equal ("watcher" ))
103103 Expect (* (Watcher .Spec .Secret )).Should (Equal ("test-osp-secret" ))
104- Expect (* ( Watcher .Spec .RabbitMqClusterName ) ).Should (Equal ("rabbitmq" ))
104+ Expect (Watcher .Spec .MessagingBus . Cluster ).Should (Equal ("rabbitmq" ))
105105 Expect (Watcher .Spec .PreserveJobs ).Should (BeFalse ())
106106 Expect (* (Watcher .Spec .APITimeout )).To (Equal (60 ))
107107
@@ -711,7 +711,9 @@ var _ = Describe("Watcher controller", func() {
711711 It ("should raise an error for empty databaseInstance" , func () {
712712 spec := GetDefaultWatcherAPISpec ()
713713 spec ["databaseInstance" ] = ""
714- spec ["rabbitMqClusterName" ] = "rabbitmq"
714+ spec ["messagingBus" ] = map [string ]any {
715+ "cluster" : "rabbitmq" ,
716+ }
715717
716718 raw := map [string ]any {
717719 "apiVersion" : "watcher.openstack.org/v1beta1" ,
@@ -743,7 +745,9 @@ var _ = Describe("Watcher controller", func() {
743745
744746 spec := GetDefaultWatcherAPISpec ()
745747 spec ["topologyRef" ] = map [string ]any {"name" : "foo" , "namespace" : "bar" }
746- spec ["rabbitMqClusterName" ] = "rabbitmq"
748+ spec ["messagingBus" ] = map [string ]any {
749+ "cluster" : "rabbitmq" ,
750+ }
747751
748752 raw := map [string ]any {
749753 "apiVersion" : "watcher.openstack.org/v1beta1" ,
@@ -771,34 +775,18 @@ var _ = Describe("Watcher controller", func() {
771775 })
772776
773777 When ("Watcher is created with empty messagingBus.cluster" , func () {
774- It ("should raise an error for empty messagingBus.cluster" , func () {
775- spec := GetDefaultWatcherAPISpec ()
776- spec ["rabbitMqClusterName" ] = ""
778+ It ("should default messagingBus.cluster to rabbitmq" , func () {
779+ spec := GetDefaultWatcherSpec ()
777780 spec ["messagingBus" ] = map [string ]any {
778781 "cluster" : "" ,
779782 }
783+ DeferCleanup (th .DeleteInstance , CreateWatcher (watcherTest .Instance , spec ))
780784
781- raw := map [string ]any {
782- "apiVersion" : "watcher.openstack.org/v1beta1" ,
783- "kind" : "watcher" ,
784- "metadata" : map [string ]any {
785- "name" : watcherName .Name ,
786- "namespace" : watcherName .Namespace ,
787- },
788- "spec" : spec ,
789- }
790-
791- unstructuredObj := & unstructured.Unstructured {Object : raw }
792- _ , err := controllerutil .CreateOrPatch (
793- th .Ctx , th .K8sClient , unstructuredObj , func () error { return nil })
794- Expect (err ).To (HaveOccurred ())
795- // Error comes from CRD schema validation (minLength: 1) before webhook validation
796- Expect (err .Error ()).To (
797- ContainSubstring (
798- "Watcher.watcher.openstack.org \" watcher\" is invalid: " +
799- "spec.messagingBus.cluster: Invalid value: \" \" : " +
800- "spec.messagingBus.cluster in body should be at least 1 chars long" ),
801- )
785+ // Webhook should default empty cluster to "rabbitmq"
786+ Eventually (func (g Gomega ) {
787+ watcher := GetWatcher (watcherTest .Instance )
788+ g .Expect (watcher .Spec .MessagingBus .Cluster ).To (Equal ("rabbitmq" ))
789+ }, timeout , interval ).Should (Succeed ())
802790 })
803791 })
804792
@@ -851,7 +839,7 @@ var _ = Describe("Watcher controller", func() {
851839 Expect (* (Watcher .Spec .ServiceUser )).Should (Equal ("fakeuser" ))
852840 Expect (* (Watcher .Spec .Secret )).Should (Equal ("test-osp-secret" ))
853841 Expect (Watcher .Spec .PreserveJobs ).Should (BeTrue ())
854- Expect (* ( Watcher .Spec .RabbitMqClusterName ) ).Should (Equal ("rabbitmq" ))
842+ Expect (Watcher .Spec .MessagingBus . Cluster ).Should (Equal ("rabbitmq" ))
855843 Expect (Watcher .Spec .APIServiceTemplate .TLS .CaBundleSecretName ).Should (Equal ("combined-ca-bundle" ))
856844 Expect (Watcher .Spec .CustomServiceConfig ).Should (Equal ("# Global config" ))
857845 Expect (* (Watcher .Spec .PrometheusSecret )).Should (Equal ("custom-prometheus-config" ))
@@ -1633,7 +1621,9 @@ var _ = Describe("Watcher controller", func() {
16331621 When ("Watcher with notification bus instance is created" , func () {
16341622 BeforeEach (func () {
16351623 spec := GetDefaultWatcherSpec ()
1636- spec ["notificationsBusInstance" ] = ptr .To ("rabbitmq-notification" )
1624+ spec ["notificationsBus" ] = map [string ]any {
1625+ "cluster" : "rabbitmq-notification" ,
1626+ }
16371627 DeferCleanup (th .DeleteInstance , CreateWatcher (watcherTest .Instance , spec ))
16381628 DeferCleanup (k8sClient .Delete , ctx , CreateWatcherMessageBusSecret (watcherTest .Instance .Namespace , "rabbitmq-secret" ))
16391629 memcachedSpec := memcachedv1.MemcachedSpec {
@@ -1676,8 +1666,8 @@ var _ = Describe("Watcher controller", func() {
16761666
16771667 It ("should have the Spec fields with the expected values" , func () {
16781668 Watcher := GetWatcher (watcherTest .Instance )
1679- Expect (* ( Watcher .Spec .RabbitMqClusterName ) ).Should (Equal ("rabbitmq" ))
1680- Expect (* ( Watcher .Spec .NotificationsBusInstance ) ).Should (Equal ("rabbitmq-notification" ))
1669+ Expect (Watcher .Spec .MessagingBus . Cluster ).Should (Equal ("rabbitmq" ))
1670+ Expect (Watcher .Spec .NotificationsBus . Cluster ).Should (Equal ("rabbitmq-notification" ))
16811671 })
16821672
16831673 It ("should have the condition WatcherNotificationTransportURLReadyCondition set to false" , func () {
@@ -2015,9 +2005,6 @@ var _ = Describe("Watcher controller", func() {
20152005 When ("Watcher with custom messagingBus and notificationsBus is created" , func () {
20162006 BeforeEach (func () {
20172007 spec := GetDefaultWatcherSpec ()
2018- // Null out deprecated fields before setting new bus fields
2019- spec ["rabbitMqClusterName" ] = ""
2020- spec ["notificationsBusInstance" ] = ""
20212008 spec ["messagingBus" ] = map [string ]any {
20222009 "cluster" : "custom-rabbitmq" ,
20232010 "user" : "custom-rpc-user" ,
0 commit comments