Skip to content

Commit 168b2b4

Browse files
committed
WIP tests
Signed-off-by: Bohdan Dobrelia <bdobreli@redhat.com>
1 parent 1e37ac3 commit 168b2b4

7 files changed

Lines changed: 148 additions & 59 deletions

File tree

apis/core/v1beta1/openstackcontrolplane_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,12 @@ type NotificationsBusSection struct {
500500
// +kubebuilder:validation:Optional
501501
// The name of RabbitMQ Cluster CR to select a Messaging
502502
// Bus Service instance used by all services that produce or consume notifications.
503-
// Avoid colocating it with RabbitMQ services used for PRC.
503+
// Avoid colocating it with RabbitMQ services used for RPC.
504504
// That instance will be pushed down for services, unless overriden in templates.
505505
// An empty value disables notifications drivers, and makes the services emitting no notifications at all.
506506
// When undefined, no configuration will be pushed down for services, which provides backward compatibility during upgrades,
507507
// and leaves a possibility for services to override the configuration, stick with its default behavior, or disable notifications only for itself.
508-
// Services that support this global configuration interface include: Nova
508+
// Services that support this global configuration interface include: Nova
509509
RabbitMqClusterName *string `json:"rabbitMqClusterName,omitempty"`
510510
}
511511

apis/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/openstack-k8s-operators/glance-operator/api v0.6.1-0.20250407064150-1cff0f51b44d
1414
github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20250423034234-f96998c6fdac
1515
github.com/openstack-k8s-operators/horizon-operator/api v0.6.1-0.20250421055257-62660c8c5cba
16-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250424140239-2d89c1d9f3ec
16+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250430070919-2ce4eea3a06d
1717
github.com/openstack-k8s-operators/ironic-operator/api v0.6.1-0.20250423054051-4b1b486312a5
1818
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250420193521-f2b86a82d7e8
1919
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250423055245-3cb2ae8df6f0

apis/go.sum

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20250423034234-f96
106106
github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20250423034234-f96998c6fdac/go.mod h1:H7Cd+GRpWmm+Viqu2eqNMGhK7qTE7SpSVo6qz1Gksec=
107107
github.com/openstack-k8s-operators/horizon-operator/api v0.6.1-0.20250421055257-62660c8c5cba h1:ZJSh4+IWoojgMeY2Pe2kaG3lLPPxT81X9tSEV2Ke3hM=
108108
github.com/openstack-k8s-operators/horizon-operator/api v0.6.1-0.20250421055257-62660c8c5cba/go.mod h1:Jti6wluZ1s3eRUQKoeYTZyMfap5cKYZsjkkVuAiiqQA=
109-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250424140239-2d89c1d9f3ec h1:Sr12fbgiUTL/a7qvKCosedKW5gn5S+53DgRJgeveTk4=
110-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250424140239-2d89c1d9f3ec/go.mod h1:XywwuHkxaBZA+6QsF+N/3f9ekBq3tH0I/gQZzwL89GU=
109+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250430070919-2ce4eea3a06d h1:aphoDw96rkEMGhZJoc+kO3S4o9e/GQfXz/njRPjh+Kw=
111110
github.com/openstack-k8s-operators/ironic-operator/api v0.6.1-0.20250423054051-4b1b486312a5 h1:5joWLQOZmZb1vQRm0h0n2oTEmwcazQskWq7Tq77l2p0=
112111
github.com/openstack-k8s-operators/ironic-operator/api v0.6.1-0.20250423054051-4b1b486312a5/go.mod h1:Xla9BX9bX9/9SqV6g4fQEJUGiCLyd2JiR7Xk5fZJFmk=
113112
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250420193521-f2b86a82d7e8 h1:goExj6wO3m63qMWsavIR+IbnmkJ/H/kN5ypLDAfys+c=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/openstack-k8s-operators/glance-operator/api v0.6.1-0.20250407064150-1cff0f51b44d
1919
github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20250423034234-f96998c6fdac
2020
github.com/openstack-k8s-operators/horizon-operator/api v0.6.1-0.20250421055257-62660c8c5cba
21-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250424140239-2d89c1d9f3ec
21+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250430070919-2ce4eea3a06d
2222
github.com/openstack-k8s-operators/ironic-operator/api v0.6.1-0.20250423054051-4b1b486312a5
2323
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250420193521-f2b86a82d7e8
2424
github.com/openstack-k8s-operators/lib-common/modules/ansible v0.6.1-0.20250423055245-3cb2ae8df6f0

go.sum

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20250423034234-f96
110110
github.com/openstack-k8s-operators/heat-operator/api v0.6.1-0.20250423034234-f96998c6fdac/go.mod h1:H7Cd+GRpWmm+Viqu2eqNMGhK7qTE7SpSVo6qz1Gksec=
111111
github.com/openstack-k8s-operators/horizon-operator/api v0.6.1-0.20250421055257-62660c8c5cba h1:ZJSh4+IWoojgMeY2Pe2kaG3lLPPxT81X9tSEV2Ke3hM=
112112
github.com/openstack-k8s-operators/horizon-operator/api v0.6.1-0.20250421055257-62660c8c5cba/go.mod h1:Jti6wluZ1s3eRUQKoeYTZyMfap5cKYZsjkkVuAiiqQA=
113-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250424140239-2d89c1d9f3ec h1:Sr12fbgiUTL/a7qvKCosedKW5gn5S+53DgRJgeveTk4=
114-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250424140239-2d89c1d9f3ec/go.mod h1:XywwuHkxaBZA+6QsF+N/3f9ekBq3tH0I/gQZzwL89GU=
113+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250430070919-2ce4eea3a06d h1:aphoDw96rkEMGhZJoc+kO3S4o9e/GQfXz/njRPjh+Kw=
115114
github.com/openstack-k8s-operators/ironic-operator/api v0.6.1-0.20250423054051-4b1b486312a5 h1:5joWLQOZmZb1vQRm0h0n2oTEmwcazQskWq7Tq77l2p0=
116115
github.com/openstack-k8s-operators/ironic-operator/api v0.6.1-0.20250423054051-4b1b486312a5/go.mod h1:Xla9BX9bX9/9SqV6g4fQEJUGiCLyd2JiR7Xk5fZJFmk=
117116
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250420193521-f2b86a82d7e8 h1:goExj6wO3m63qMWsavIR+IbnmkJ/H/kN5ypLDAfys+c=

tests/functional/ctlplane/base_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ type Names struct {
5656
NeutronName types.NamespacedName
5757
HorizonName types.NamespacedName
5858
HeatName types.NamespacedName
59+
NovaName types.NamespacedName
60+
PlacementName types.NamespacedName
5961
TelemetryName types.NamespacedName
6062
DBName types.NamespacedName
6163
DBCertName types.NamespacedName
@@ -170,6 +172,14 @@ func CreateNames(openstackControlplaneName types.NamespacedName) Names {
170172
Namespace: openstackControlplaneName.Namespace,
171173
Name: "telemetry",
172174
},
175+
NovaName: types.NamespacedName{
176+
Namespace: openstackControlplaneName.Namespace,
177+
Name: "nova",
178+
},
179+
PlacementName: types.NamespacedName{
180+
Namespace: openstackControlplaneName.Namespace,
181+
Name: "placement",
182+
},
173183
DBName: types.NamespacedName{
174184
Namespace: openstackControlplaneName.Namespace,
175185
Name: "openstack",

tests/functional/ctlplane/openstackoperator_controller_test.go

Lines changed: 132 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030

3131
k8s_corev1 "k8s.io/api/core/v1"
3232
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
33+
3334
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3435
"k8s.io/apimachinery/pkg/types"
3536
"k8s.io/utils/ptr"
@@ -40,17 +41,20 @@ import (
4041
cinderv1 "github.com/openstack-k8s-operators/cinder-operator/api/v1beta1"
4142
rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
4243
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
44+
4345
"github.com/openstack-k8s-operators/lib-common/modules/certmanager"
4446
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
4547
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
4648
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
4749
manilav1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1"
50+
novav1 "github.com/openstack-k8s-operators/nova-operator/api/v1beta1"
4851
clientv1 "github.com/openstack-k8s-operators/openstack-operator/apis/client/v1beta1"
4952
corev1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1"
5053
ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1"
54+
placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1"
5155
)
5256

53-
var _ = Describe("OpenStackOperator controller", func() {
57+
var _ = Describe("OpenStackOperator controller", Focus, func() {
5458
BeforeEach(func() {
5559
// lib-common uses OPERATOR_TEMPLATES env var to locate the "templates"
5660
// directory of the operator. We need to set them othervise lib-common
@@ -1810,76 +1814,153 @@ var _ = Describe("OpenStackOperator controller", func() {
18101814
})
18111815
})
18121816

1813-
When("A OpenStackControlplane instance is created with top-scope notifications config pushed down", func() {
1817+
When("A OpenStackControlplane instance is created with top-scope notifications config pushed down", Focus, func() {
18141818
BeforeEach(func() {
1815-
spec := GetDefaultOpenStackControlPlaneSpec()
1816-
spec["notificationsBus"] = map[string]interface{}{
1817-
"rabbitMqClusterName": ptr.To("rabbitmq-notifications"),
1818-
}
1819-
spec["nova"] = map[string]interface{}{
1820-
"enabled": false,
1821-
"template": map[string]interface{}{},
1822-
}
1823-
DeferCleanup(
1824-
th.DeleteInstance,
1825-
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
1826-
)
1827-
})
1819+
// NOTE(bogdando): DBs certs need to be created here as well, but those are leaking from the other non-isolated tests
1820+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
1821+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
1822+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
1823+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
1824+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNNorthdCertName))
1825+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNControllerCertName))
1826+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.NeutronOVNCertName))
18281827

1829-
It("should have Nova notifications bus instance configured by inheritance", func() {
1830-
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1831-
Expect(*OSCtlplane.Spec.Nova.Template.NotificationsBusInstance).Should(ContainSubstring("rabbitmq-notifications"))
1832-
})
1833-
})
1828+
DeferCleanup(k8sClient.Delete, ctx,
1829+
th.CreateSecret(types.NamespacedName{Name: "openstack-config-secret", Namespace: namespace}, map[string][]byte{"secure.yaml": []byte("foo")}))
1830+
DeferCleanup(k8sClient.Delete, ctx,
1831+
th.CreateConfigMap(types.NamespacedName{Name: "openstack-config", Namespace: namespace}, map[string]interface{}{"clouds.yaml": string("foo"), "OS_CLOUD": "default"}))
18341832

1835-
When("A OpenStackControlplane instance is created with notifications config override", func() {
1836-
BeforeEach(func() {
18371833
spec := GetDefaultOpenStackControlPlaneSpec()
1838-
spec["notificationsBus"] = map[string]interface{}{
1839-
"rabbitMqClusterName": ptr.To("rabbitmq-notifications-top-scope"),
1840-
}
18411834
spec["nova"] = map[string]interface{}{
1835+
"enabled": true,
1836+
}
1837+
// turn off unrelated to this test case services
1838+
spec["horizon"] = map[string]interface{}{
18421839
"enabled": false,
1843-
"template": map[string]interface{}{
1844-
"notificationsBusInstance": ptr.To("rabbitmq-custom"),
1845-
},
18461840
}
1847-
DeferCleanup(
1848-
th.DeleteInstance,
1849-
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
1850-
)
1851-
})
1852-
1853-
It("should have Nova notifications bus instance configured from local templates", func() {
1854-
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1855-
Expect(*OSCtlplane.Spec.Nova.Template.NotificationsBusInstance).Should(Equal("rabbitmq-custom"))
1856-
})
1857-
})
1858-
1859-
When("A OpenStackControlplane instance is created with notifications config force-disabled", func() {
1860-
BeforeEach(func() {
1861-
spec := GetDefaultOpenStackControlPlaneSpec()
1862-
spec["notificationsBus"] = map[string]interface{}{
1863-
"rabbitMqClusterName": ptr.To(""),
1841+
spec["cinder"] = map[string]interface{}{
1842+
"enabled": false,
18641843
}
1865-
spec["nova"] = map[string]interface{}{
1844+
spec["swift"] = map[string]interface{}{
18661845
"enabled": false,
1867-
"template": map[string]interface{}{
1868-
"notificationsBusInstance": ptr.To("rabbitmq-maybe"),
1869-
},
18701846
}
1847+
spec["redis"] = map[string]interface{}{
1848+
"enabled": false,
1849+
}
1850+
spec["ironic"] = map[string]interface{}{
1851+
"enabled": false,
1852+
}
1853+
spec["designate"] = map[string]interface{}{
1854+
"enabled": false,
1855+
}
1856+
spec["barbican"] = map[string]interface{}{
1857+
"enabled": false,
1858+
}
1859+
spec["manila"] = map[string]interface{}{
1860+
"enabled": false,
1861+
}
1862+
spec["heat"] = map[string]interface{}{
1863+
"enabled": false,
1864+
}
1865+
spec["telemetry"] = map[string]interface{}{
1866+
"enabled": false,
1867+
}
1868+
// spec["watcher"] = map[string]interface{}{
1869+
// "enabled": false,
1870+
// }
1871+
18711872
DeferCleanup(
18721873
th.DeleteInstance,
18731874
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
18741875
)
1876+
SimulateControlplaneReady()
1877+
1878+
// enable Nova with dependencies, disable TLS
1879+
Eventually(func(g Gomega) {
1880+
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1881+
OSCtlplane.Spec.TLS.PodLevel.Enabled = false
1882+
OSCtlplane.Spec.Keystone.Enabled = true
1883+
OSCtlplane.Spec.Glance.Enabled = true
1884+
OSCtlplane.Spec.Neutron.Enabled = true
1885+
OSCtlplane.Spec.Placement.Enabled = true
1886+
OSCtlplane.Spec.NotificationsBus.RabbitMqClusterName = ptr.To("rabbitmq-notifications")
1887+
OSCtlplane.Spec.Placement.Template = &placementv1.PlacementAPISpecCore{}
1888+
OSCtlplane.Spec.Placement.Template.APITimeout = 60
1889+
OSCtlplane.Spec.Nova.Enabled = true
1890+
OSCtlplane.Spec.Nova.Template = &novav1.NovaSpecCore{}
1891+
OSCtlplane.Spec.Nova.Template.APITimeout = 60
1892+
OSCtlplane.Spec.Nova.Template.NotificationsBusInstance = nil
1893+
g.Expect(k8sClient.Update(ctx, OSCtlplane)).Should(Succeed())
1894+
}, timeout, interval).Should(Succeed())
1895+
1896+
Eventually(func(g Gomega) {
1897+
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1898+
OSCtlplane.Status.ObservedGeneration = OSCtlplane.Generation
1899+
OSCtlplane.Status.Conditions.MarkTrue(corev1.OpenStackControlPlaneMemcachedReadyCondition, "Ready")
1900+
OSCtlplane.Status.Conditions.MarkTrue(corev1.OpenStackControlPlaneRabbitMQReadyCondition, "Ready")
1901+
OSCtlplane.Status.Conditions.MarkTrue(corev1.OpenStackControlPlaneNeutronReadyCondition, "Ready")
1902+
OSCtlplane.Status.Conditions.MarkTrue(corev1.OpenStackControlPlaneGlanceReadyCondition, "Ready")
1903+
OSCtlplane.Status.Conditions.MarkTrue(corev1.OpenStackControlPlanePlacementAPIReadyCondition, "Ready")
1904+
OSCtlplane.Status.Conditions.MarkTrue(corev1.OpenStackControlPlaneNovaReadyCondition, "Ready")
1905+
g.Expect(k8sClient.Update(ctx, OSCtlplane)).Should(Succeed())
1906+
th.Logger.Info("Simulated nova and its dependencies ready", "on", names.OpenStackControlplaneName)
1907+
}, timeout, interval).Should(Succeed())
18751908
})
18761909

1877-
It("should have Nova enabled and its notifications bus instance configured for a special empty value", func() {
1910+
It("should have nova and deps enabled with nova notifications bus instance configured by inheritance", Focus, func() {
18781911
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1879-
Expect(*OSCtlplane.Spec.Nova.Template.NotificationsBusInstance).Should(Equal(""))
1912+
Expect(OSCtlplane.Spec.Nova.Template.NotificationsBusInstance).Should(Equal("rabbitmq-notifications"))
18801913
})
18811914
})
18821915

1916+
// When("A OpenStackControlplane instance is created with notifications config override", func() {
1917+
// BeforeEach(func() {
1918+
// spec := GetDefaultOpenStackControlPlaneSpec()
1919+
// spec["notificationsBus"] = map[string]interface{}{
1920+
// "rabbitMqClusterName": ptr.To("rabbitmq-notifications-top-scope"),
1921+
// }
1922+
// spec["nova"] = map[string]interface{}{
1923+
// "enabled": false,
1924+
// "template": map[string]interface{}{
1925+
// "notificationsBusInstance": ptr.To("rabbitmq-custom"),
1926+
// },
1927+
// }
1928+
// DeferCleanup(
1929+
// th.DeleteInstance,
1930+
// CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
1931+
// )
1932+
// })
1933+
1934+
// It("should have Nova notifications bus instance configured from local templates", func() {
1935+
// OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1936+
// Expect(*OSCtlplane.Spec.Nova.Template.NotificationsBusInstance).Should(Equal("rabbitmq-custom"))
1937+
// })
1938+
// })
1939+
1940+
// When("A OpenStackControlplane instance is created with notifications config force-disabled", func() {
1941+
// BeforeEach(func() {
1942+
// spec := GetDefaultOpenStackControlPlaneSpec()
1943+
// spec["notificationsBus"] = map[string]interface{}{
1944+
// "rabbitMqClusterName": ptr.To(""),
1945+
// }
1946+
// spec["nova"] = map[string]interface{}{
1947+
// "enabled": false,
1948+
// "template": map[string]interface{}{
1949+
// "notificationsBusInstance": ptr.To("rabbitmq-maybe"),
1950+
// },
1951+
// }
1952+
// DeferCleanup(
1953+
// th.DeleteInstance,
1954+
// CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
1955+
// )
1956+
// })
1957+
1958+
// It("should have Nova enabled and its notifications bus instance configured for a special empty value", func() {
1959+
// OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1960+
// Expect(*OSCtlplane.Spec.Nova.Template.NotificationsBusInstance).Should(Equal(""))
1961+
// })
1962+
// })
1963+
18831964
When("OpenStackControlplane instance is deleted", func() {
18841965
BeforeEach(func() {
18851966
DeferCleanup(

0 commit comments

Comments
 (0)