Skip to content

Commit f05f8ce

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

2 files changed

Lines changed: 162 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: 147 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import (
3030

3131
k8s_corev1 "k8s.io/api/core/v1"
3232
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
33+
34+
//metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3335
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3436
"k8s.io/apimachinery/pkg/types"
3537
"k8s.io/utils/ptr"
@@ -40,11 +42,14 @@ import (
4042
cinderv1 "github.com/openstack-k8s-operators/cinder-operator/api/v1beta1"
4143
rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
4244
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
45+
46+
//keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
4347
"github.com/openstack-k8s-operators/lib-common/modules/certmanager"
4448
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
4549
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
4650
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
4751
manilav1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1"
52+
novav1 "github.com/openstack-k8s-operators/nova-operator/api/v1beta1"
4853
clientv1 "github.com/openstack-k8s-operators/openstack-operator/apis/client/v1beta1"
4954
corev1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1"
5055
ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1"
@@ -1813,73 +1818,166 @@ var _ = Describe("OpenStackOperator controller", func() {
18131818
When("A OpenStackControlplane instance is created with top-scope notifications config pushed down", func() {
18141819
BeforeEach(func() {
18151820
spec := GetDefaultOpenStackControlPlaneSpec()
1816-
spec["notificationsBus"] = map[string]interface{}{
1817-
"rabbitMqClusterName": ptr.To("rabbitmq-notifications"),
1821+
// turn off unrelated to this test case services
1822+
spec["horizon"] = map[string]interface{}{
1823+
"enabled": false,
18181824
}
1819-
spec["nova"] = map[string]interface{}{
1820-
"enabled": false,
1821-
"template": map[string]interface{}{},
1825+
spec["cinder"] = map[string]interface{}{
1826+
"enabled": false,
18221827
}
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"),
1828+
spec["swift"] = map[string]interface{}{
1829+
"enabled": false,
18401830
}
1841-
spec["nova"] = map[string]interface{}{
1831+
spec["redis"] = map[string]interface{}{
18421832
"enabled": false,
1843-
"template": map[string]interface{}{
1844-
"notificationsBusInstance": ptr.To("rabbitmq-custom"),
1845-
},
18461833
}
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(""),
1834+
spec["ironic"] = map[string]interface{}{
1835+
"enabled": false,
18641836
}
1865-
spec["nova"] = map[string]interface{}{
1837+
spec["designate"] = map[string]interface{}{
1838+
"enabled": false,
1839+
}
1840+
spec["barbican"] = map[string]interface{}{
1841+
"enabled": false,
1842+
}
1843+
spec["manila"] = map[string]interface{}{
1844+
"enabled": false,
1845+
}
1846+
spec["heat"] = map[string]interface{}{
18661847
"enabled": false,
1867-
"template": map[string]interface{}{
1868-
"notificationsBusInstance": ptr.To("rabbitmq-maybe"),
1869-
},
18701848
}
1849+
spec["telemetry"] = map[string]interface{}{
1850+
"enabled": false,
1851+
}
1852+
spec["watcher"] = map[string]interface{}{
1853+
"enabled": false,
1854+
}
1855+
1856+
// NOTE(bogdando): DBs certs need to be created here as well, but those are leaking from the other non-isolated tests
1857+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
1858+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
1859+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
1860+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
1861+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNNorthdCertName))
1862+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNControllerCertName))
1863+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.NeutronOVNCertName))
1864+
1865+
th.CreateSecret(types.NamespacedName{
1866+
Name: "openstack-config-secret",
1867+
Namespace: namespace,
1868+
}, map[string][]byte{"secure.yaml": []byte("foo")})
1869+
1870+
th.CreateConfigMap(types.NamespacedName{
1871+
Name: "openstack-config",
1872+
Namespace: namespace,
1873+
}, map[string]interface{}{
1874+
"clouds.yaml": string("foo"),
1875+
"OS_CLOUD": "default",
1876+
})
1877+
18711878
DeferCleanup(
18721879
th.DeleteInstance,
18731880
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
18741881
)
1882+
SimulateControlplaneReady()
1883+
1884+
// enable Nova dependencies, disable TLS
1885+
Eventually(func(g Gomega) {
1886+
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
1887+
OSCtlplane.Spec.TLS.PodLevel.Enabled = false
1888+
OSCtlplane.Spec.Keystone.Enabled = true
1889+
OSCtlplane.Spec.Glance.Enabled = true
1890+
OSCtlplane.Spec.Neutron.Enabled = true
1891+
OSCtlplane.Spec.Placement.Enabled = true
1892+
OSCtlplane.Spec.Nova.Template = &novav1.NovaSpecCore{}
1893+
OSCtlplane.Spec.Nova.Template.APITimeout = 60
1894+
g.Expect(k8sClient.Update(ctx, OSCtlplane)).Should(Succeed())
1895+
}, timeout, interval).Should(Succeed())
1896+
1897+
nova := &novav1.Nova{}
1898+
Eventually(func(g Gomega) {
1899+
g.Expect(k8sClient.Get(ctx, names.NovaName, nova)).Should(Succeed())
1900+
g.Expect(nova).ShouldNot(BeNil())
1901+
nova.Status.ObservedGeneration = nova.Generation
1902+
nova.Status.Conditions.MarkTrue(novav1.NovaAPIReadyCondition, "Ready")
1903+
g.Expect(th.K8sClient.Status().Update(th.Ctx, nova)).To(Succeed())
1904+
th.Logger.Info("Simulated nova ready", "on", names.NovaName)
1905+
}, timeout, interval).Should(Succeed())
1906+
1907+
// not in SimulateControlplaneReady(), but never works (and is not needed here) anyways
1908+
// Eventually(func(_ Gomega) {
1909+
// th.ExpectCondition(
1910+
// names.OpenStackControlplaneName,
1911+
// ConditionGetterFunc(OpenStackControlPlaneConditionGetter),
1912+
// corev1.OpenStackControlPlaneNovaReadyCondition,
1913+
// k8s_corev1.ConditionTrue,
1914+
// )
1915+
// }, timeout, interval).Should(Succeed())
18751916
})
18761917

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

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

0 commit comments

Comments
 (0)