@@ -38,6 +38,125 @@ import (
3838 "github.com/openstack-k8s-operators/nova-operator/controllers"
3939)
4040
41+ var _ = Describe ("Nova controller - notifications" , func () {
42+
43+ When ("Nova CR instance is created" , func () {
44+ BeforeEach (func () {
45+ DeferCleanup (
46+ k8sClient .Delete , ctx , CreateNovaSecret (novaNames .NovaName .Namespace , SecretName ))
47+ DeferCleanup (
48+ k8sClient .Delete , ctx , CreateNovaMessageBusSecret (cell0 ))
49+ DeferCleanup (
50+ mariadb .DeleteDBService ,
51+ mariadb .CreateDBService (
52+ novaNames .NovaName .Namespace ,
53+ "openstack" ,
54+ corev1.ServiceSpec {
55+ Ports : []corev1.ServicePort {{Port : 3306 }},
56+ },
57+ ),
58+ )
59+ memcachedSpec := infra .GetDefaultMemcachedSpec ()
60+
61+ DeferCleanup (infra .DeleteMemcached , infra .CreateMemcached (novaNames .NovaName .Namespace , MemcachedInstance , memcachedSpec ))
62+ infra .SimulateMemcachedReady (novaNames .MemcachedNamespace )
63+
64+ DeferCleanup (keystone .DeleteKeystoneAPI , keystone .CreateKeystoneAPI (novaNames .NovaName .Namespace ))
65+
66+ DeferCleanup (th .DeleteInstance , CreateNovaWithCell0 (novaNames .NovaName ))
67+
68+ keystone .SimulateKeystoneServiceReady (novaNames .KeystoneServiceName )
69+ mariadb .SimulateMariaDBDatabaseCompleted (novaNames .APIMariaDBDatabaseName )
70+ mariadb .SimulateMariaDBAccountCompleted (novaNames .APIMariaDBDatabaseAccount )
71+ mariadb .SimulateMariaDBDatabaseCompleted (cell0 .MariaDBDatabaseName )
72+ mariadb .SimulateMariaDBAccountCompleted (cell0 .MariaDBAccountName )
73+ infra .SimulateTransportURLReady (cell0 .TransportURLName )
74+ SimulateReadyOfNovaTopServices ()
75+ })
76+ It ("notification transport url is not set" , func () {
77+
78+ // assert that a the top level internal internal secret is created
79+ // with the proper data
80+ internalTopLevelSecret := th .GetSecret (novaNames .InternalTopLevelSecretName )
81+ // verify if nova secret has notification-transport-url
82+ Expect (internalTopLevelSecret .Data ).To (HaveKey ("notification_transport_url" ))
83+ Expect (internalTopLevelSecret .Data ).To (
84+ HaveKeyWithValue ("notification_transport_url" , []byte ("" )))
85+
86+ // verify if confs are updated with notification-transport-url under oslo_messaging_notifications
87+ // assert in nova-api conf
88+ configDataMap := th .GetSecret (novaNames .APIConfigDataName )
89+ Expect (configDataMap .Data ).Should (HaveKey ("01-nova.conf" ))
90+ configData := string (configDataMap .Data ["01-nova.conf" ])
91+ AssertNotHaveNotificationTransportURL (configData )
92+
93+ // assert in sch conf
94+ configDataMap = th .GetSecret (novaNames .SchedulerConfigDataName )
95+ Expect (configDataMap .Data ).Should (HaveKey ("01-nova.conf" ))
96+ configData = string (configDataMap .Data ["01-nova.conf" ])
97+ AssertNotHaveNotificationTransportURL (configData )
98+
99+ // assert in cell0-conductor conf
100+ configDataMap = th .GetSecret (cell0 .ConductorConfigDataName )
101+ Expect (configDataMap .Data ).Should (HaveKey ("01-nova.conf" ))
102+ configData = string (configDataMap .Data ["01-nova.conf" ])
103+ AssertNotHaveNotificationTransportURL (configData )
104+
105+ })
106+
107+ It ("notification transport url is set with new rabbit" , func () {
108+
109+ // add new-rabbit in Nova CR
110+ notificationsBus := GetNotificationsBusNames (novaNames .NovaName )
111+ DeferCleanup (k8sClient .Delete , ctx , CreateNotificiationTransportURLSecret (notificationsBus ))
112+
113+ Eventually (func (g Gomega ) {
114+ nova := GetNova (novaNames .NovaName )
115+ nova .Spec .NotificationsBusInstance = & notificationsBus .BusName
116+ g .Expect (k8sClient .Update (ctx , nova )).Should (Succeed ())
117+ }, timeout , interval ).Should (Succeed ())
118+
119+ // as new-rabbit already exists in cluster, infra operator will create transporturl for it
120+ // simulating same
121+ infra .SimulateTransportURLReady (notificationsBus .TransportURLName )
122+ transportURLName := infra .GetTransportURL (notificationsBus .TransportURLName )
123+ Expect (transportURLName .Spec .RabbitmqClusterName ).To (Equal (notificationsBus .BusName ))
124+
125+ th .ExpectCondition (
126+ novaNames .NovaName ,
127+ ConditionGetterFunc (NovaConditionGetter ),
128+ novav1 .NovaNotificationMQReadyCondition ,
129+ corev1 .ConditionTrue ,
130+ )
131+
132+ // the nova secret(i.e top level secret) should have notification_transport_url value set
133+ internalTopLevelSecret := th .GetSecret (novaNames .InternalTopLevelSecretName )
134+ Expect (internalTopLevelSecret .Data ).To (HaveKey ("notification_transport_url" ))
135+ Expect (internalTopLevelSecret .Data ["notification_transport_url" ]).ShouldNot (BeEmpty ())
136+
137+ // assert in nova-api conf
138+ configDataMap := th .GetSecret (novaNames .APIConfigDataName )
139+ Expect (configDataMap .Data ).Should (HaveKey ("01-nova.conf" ))
140+ configData := string (configDataMap .Data ["01-nova.conf" ])
141+ AssertHaveNotificationTransportURL (configData , notificationsBus .TransportURLName .Name )
142+
143+ // assert in sch conf
144+ configDataMap = th .GetSecret (novaNames .SchedulerConfigDataName )
145+ Expect (configDataMap .Data ).Should (HaveKey ("01-nova.conf" ))
146+ configData = string (configDataMap .Data ["01-nova.conf" ])
147+ AssertHaveNotificationTransportURL (configData , notificationsBus .TransportURLName .Name )
148+
149+ // assert in cell0-conductor conf
150+ configDataMap = th .GetSecret (cell0 .ConductorConfigDataName )
151+ Expect (configDataMap .Data ).Should (HaveKey ("01-nova.conf" ))
152+ configData = string (configDataMap .Data ["01-nova.conf" ])
153+ AssertHaveNotificationTransportURL (configData , notificationsBus .TransportURLName .Name )
154+
155+ })
156+ })
157+
158+ })
159+
41160var _ = Describe ("Nova controller" , func () {
42161 When ("Nova CR instance is created without a proper secret" , func () {
43162 BeforeEach (func () {
@@ -265,6 +384,8 @@ var _ = Describe("Nova controller", func() {
265384 HaveKeyWithValue (controllers .ServicePasswordSelector , []byte ("service-password" )))
266385 Expect (internalCellSecret .Data ).To (
267386 HaveKeyWithValue ("transport_url" , []byte ("rabbit://cell0/fake" )))
387+ Expect (internalCellSecret .Data ).To (
388+ HaveKeyWithValue ("notification_transport_url" , []byte ("" )))
268389
269390 Expect (cell .Spec .Secret ).To (Equal (cell0 .InternalCellSecretName .Name ))
270391 Expect (conductor .Spec .Secret ).To (Equal (cell0 .InternalCellSecretName .Name ))
@@ -381,6 +502,8 @@ var _ = Describe("Nova controller", func() {
381502 HaveKeyWithValue (controllers .MetadataSecretSelector , []byte ("metadata-secret" )))
382503 Expect (internalTopLevelSecret .Data ).To (
383504 HaveKeyWithValue ("transport_url" , []byte ("rabbit://cell0/fake" )))
505+ Expect (internalTopLevelSecret .Data ).To (
506+ HaveKeyWithValue ("notification_transport_url" , []byte ("" )))
384507 })
385508
386509 It ("creates NovaAPI" , func () {
0 commit comments