Skip to content

Commit 242d2ed

Browse files
committed
WIP tests
Signed-off-by: Bohdan Dobrelia <bdobreli@redhat.com>
1 parent d24ce5c commit 242d2ed

2 files changed

Lines changed: 163 additions & 52 deletions

File tree

tests/functional/ctlplane/base_test.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"context"
2121
"encoding/base64"
2222

23+
"k8s.io/utils/ptr"
24+
2325
"github.com/google/uuid"
2426
. "github.com/onsi/gomega" //revive:disable:dot-imports
2527

@@ -56,6 +58,8 @@ type Names struct {
5658
NeutronName types.NamespacedName
5759
HorizonName types.NamespacedName
5860
HeatName types.NamespacedName
61+
NovaName types.NamespacedName
62+
PlacementName types.NamespacedName
5963
TelemetryName types.NamespacedName
6064
DBName types.NamespacedName
6165
DBCertName types.NamespacedName
@@ -170,6 +174,14 @@ func CreateNames(openstackControlplaneName types.NamespacedName) Names {
170174
Namespace: openstackControlplaneName.Namespace,
171175
Name: "telemetry",
172176
},
177+
NovaName: types.NamespacedName{
178+
Namespace: openstackControlplaneName.Namespace,
179+
Name: "nova",
180+
},
181+
PlacementName: types.NamespacedName{
182+
Namespace: openstackControlplaneName.Namespace,
183+
Name: "placement",
184+
},
173185
DBName: types.NamespacedName{
174186
Namespace: openstackControlplaneName.Namespace,
175187
Name: "openstack",
@@ -538,9 +550,9 @@ func GetDefaultOpenStackControlPlaneSpec() map[string]interface{} {
538550
return map[string]interface{}{
539551
"secret": "osp-secret",
540552
"storageClass": "local-storage",
541-
// "notificationsBus": map[string]interface{}{
542-
// "rabbitMqClusterName": ptr.To("rabbitmq-notifications"),
543-
// },
553+
"notificationsBus": map[string]interface{}{
554+
"rabbitMqClusterName": ptr.To("rabbitmq-notifications"),
555+
},
544556
"galera": map[string]interface{}{
545557
"enabled": true,
546558
"templates": galeraTemplate,

tests/functional/ctlplane/openstackoperator_controller_test.go

Lines changed: 148 additions & 49 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,14 +41,17 @@ 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

5357
var _ = Describe("OpenStackOperator controller", func() {
@@ -1813,73 +1817,168 @@ var _ = Describe("OpenStackOperator controller", func() {
18131817
When("A OpenStackControlplane instance is created with top-scope notifications config pushed down", func() {
18141818
BeforeEach(func() {
18151819
spec := GetDefaultOpenStackControlPlaneSpec()
1816-
spec["notificationsBus"] = map[string]interface{}{
1817-
"rabbitMqClusterName": ptr.To("rabbitmq-notifications"),
1820+
// turn off unrelated to this test case services
1821+
spec["horizon"] = map[string]interface{}{
1822+
"enabled": false,
18181823
}
1819-
spec["nova"] = map[string]interface{}{
1820-
"enabled": false,
1821-
"template": map[string]interface{}{},
1824+
spec["cinder"] = map[string]interface{}{
1825+
"enabled": false,
18221826
}
1823-
DeferCleanup(
1824-
th.DeleteInstance,
1825-
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
1826-
)
1827-
})
1828-
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-
})
1834-
1835-
When("A OpenStackControlplane instance is created with notifications config override", func() {
1836-
BeforeEach(func() {
1837-
spec := GetDefaultOpenStackControlPlaneSpec()
1838-
spec["notificationsBus"] = map[string]interface{}{
1839-
"rabbitMqClusterName": ptr.To("rabbitmq-notifications-top-scope"),
1827+
spec["swift"] = map[string]interface{}{
1828+
"enabled": false,
18401829
}
1841-
spec["nova"] = map[string]interface{}{
1830+
spec["redis"] = map[string]interface{}{
18421831
"enabled": false,
1843-
"template": map[string]interface{}{
1844-
"notificationsBusInstance": ptr.To("rabbitmq-custom"),
1845-
},
18461832
}
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(""),
1833+
spec["ironic"] = map[string]interface{}{
1834+
"enabled": false,
18641835
}
1865-
spec["nova"] = map[string]interface{}{
1836+
spec["designate"] = map[string]interface{}{
1837+
"enabled": false,
1838+
}
1839+
spec["barbican"] = map[string]interface{}{
1840+
"enabled": false,
1841+
}
1842+
spec["manila"] = map[string]interface{}{
1843+
"enabled": false,
1844+
}
1845+
spec["heat"] = map[string]interface{}{
18661846
"enabled": false,
1867-
"template": map[string]interface{}{
1868-
"notificationsBusInstance": ptr.To("rabbitmq-maybe"),
1869-
},
18701847
}
1848+
spec["telemetry"] = map[string]interface{}{
1849+
"enabled": false,
1850+
}
1851+
spec["watcher"] = map[string]interface{}{
1852+
"enabled": false,
1853+
}
1854+
1855+
// NOTE(bogdando): DBs certs need to be created here as well, but those are leaking from the other non-isolated tests
1856+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
1857+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
1858+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
1859+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
1860+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNNorthdCertName))
1861+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNControllerCertName))
1862+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.NeutronOVNCertName))
1863+
1864+
th.CreateSecret(types.NamespacedName{
1865+
Name: "openstack-config-secret",
1866+
Namespace: namespace,
1867+
}, map[string][]byte{"secure.yaml": []byte("foo")})
1868+
1869+
th.CreateConfigMap(types.NamespacedName{
1870+
Name: "openstack-config",
1871+
Namespace: namespace,
1872+
}, map[string]interface{}{
1873+
"clouds.yaml": string("foo"),
1874+
"OS_CLOUD": "default",
1875+
})
1876+
18711877
DeferCleanup(
18721878
th.DeleteInstance,
18731879
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
18741880
)
1881+
SimulateControlplaneReady()
1882+
1883+
// enable Nova dependencies, disable TLS
1884+
Eventually(func(g Gomega) {
1885+
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1886+
OSCtlplane.Spec.TLS.PodLevel.Enabled = false
1887+
OSCtlplane.Spec.Keystone.Enabled = true
1888+
OSCtlplane.Spec.Glance.Enabled = true
1889+
OSCtlplane.Spec.Neutron.Enabled = true
1890+
OSCtlplane.Spec.Placement.Enabled = true
1891+
OSCtlplane.Spec.Placement.Template = &placementv1.PlacementAPISpecCore{}
1892+
OSCtlplane.Spec.Placement.Template.APITimeout = 60
1893+
OSCtlplane.Spec.Nova.Template = &novav1.NovaSpecCore{}
1894+
OSCtlplane.Spec.Nova.Template.APITimeout = 60
1895+
g.Expect(k8sClient.Update(ctx, OSCtlplane)).Should(Succeed())
1896+
}, timeout, interval).Should(Succeed())
1897+
1898+
nova := &novav1.Nova{}
1899+
Eventually(func(g Gomega) {
1900+
g.Expect(k8sClient.Get(ctx, names.NovaName, nova)).Should(Succeed())
1901+
g.Expect(nova).ShouldNot(BeNil())
1902+
nova.Status.ObservedGeneration = nova.Generation
1903+
nova.Status.Conditions.MarkTrue(novav1.NovaAPIReadyCondition, "Ready")
1904+
g.Expect(th.K8sClient.Status().Update(th.Ctx, nova)).To(Succeed())
1905+
th.Logger.Info("Simulated nova ready", "on", names.NovaName)
1906+
}, timeout, interval).Should(Succeed())
1907+
1908+
// not in SimulateControlplaneReady(), but never works (and is not needed here) anyways
1909+
// Eventually(func(_ Gomega) {
1910+
// th.ExpectCondition(
1911+
// names.OpenStackControlplaneName,
1912+
// ConditionGetterFunc(OpenStackControlPlaneConditionGetter),
1913+
// corev1.OpenStackControlPlaneNovaReadyCondition,
1914+
// k8s_corev1.ConditionTrue,
1915+
// )
1916+
// }, timeout, interval).Should(Succeed())
18751917
})
18761918

1877-
It("should have Nova enabled and its notifications bus instance configured for a special empty value", func() {
1919+
It("should have nova and deps enabled with nova notifications bus instance configured by inheritance", func() {
18781920
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1879-
Expect(*OSCtlplane.Spec.Nova.Template.NotificationsBusInstance).Should(Equal(""))
1921+
Expect(OSCtlplane.Spec.Nova.Enabled).Should(BeTrue())
1922+
Expect(OSCtlplane.Spec.Galera.Enabled).Should(BeTrue())
1923+
Expect(OSCtlplane.Spec.Rabbitmq.Enabled).Should(BeTrue())
1924+
Expect(OSCtlplane.Spec.Memcached.Enabled).Should(BeTrue())
1925+
Expect(OSCtlplane.Spec.Keystone.Enabled).Should(BeTrue())
1926+
Expect(OSCtlplane.Spec.Placement.Enabled).Should(BeTrue())
1927+
Expect(OSCtlplane.Spec.Glance.Enabled).Should(BeTrue())
1928+
Expect(OSCtlplane.Spec.Neutron.Enabled).Should(BeTrue())
1929+
1930+
Expect(*OSCtlplane.Spec.Nova.Template.NotificationsBusInstance).Should(Equal("rabbitmq-notifications"))
18801931
})
18811932
})
18821933

1934+
// When("A OpenStackControlplane instance is created with notifications config override", func() {
1935+
// BeforeEach(func() {
1936+
// spec := GetDefaultOpenStackControlPlaneSpec()
1937+
// spec["notificationsBus"] = map[string]interface{}{
1938+
// "rabbitMqClusterName": ptr.To("rabbitmq-notifications-top-scope"),
1939+
// }
1940+
// spec["nova"] = map[string]interface{}{
1941+
// "enabled": false,
1942+
// "template": map[string]interface{}{
1943+
// "notificationsBusInstance": ptr.To("rabbitmq-custom"),
1944+
// },
1945+
// }
1946+
// DeferCleanup(
1947+
// th.DeleteInstance,
1948+
// CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
1949+
// )
1950+
// })
1951+
1952+
// It("should have Nova notifications bus instance configured from local templates", func() {
1953+
// OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1954+
// Expect(*OSCtlplane.Spec.Nova.Template.NotificationsBusInstance).Should(Equal("rabbitmq-custom"))
1955+
// })
1956+
// })
1957+
1958+
// When("A OpenStackControlplane instance is created with notifications config force-disabled", func() {
1959+
// BeforeEach(func() {
1960+
// spec := GetDefaultOpenStackControlPlaneSpec()
1961+
// spec["notificationsBus"] = map[string]interface{}{
1962+
// "rabbitMqClusterName": ptr.To(""),
1963+
// }
1964+
// spec["nova"] = map[string]interface{}{
1965+
// "enabled": false,
1966+
// "template": map[string]interface{}{
1967+
// "notificationsBusInstance": ptr.To("rabbitmq-maybe"),
1968+
// },
1969+
// }
1970+
// DeferCleanup(
1971+
// th.DeleteInstance,
1972+
// CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
1973+
// )
1974+
// })
1975+
1976+
// It("should have Nova enabled and its notifications bus instance configured for a special empty value", func() {
1977+
// OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1978+
// Expect(*OSCtlplane.Spec.Nova.Template.NotificationsBusInstance).Should(Equal(""))
1979+
// })
1980+
// })
1981+
18831982
When("OpenStackControlplane instance is deleted", func() {
18841983
BeforeEach(func() {
18851984
DeferCleanup(

0 commit comments

Comments
 (0)