Skip to content

Commit 228c7fb

Browse files
committed
Add tests for novncproxy certs and routes cleanup
1 parent b628e5e commit 228c7fb

2 files changed

Lines changed: 158 additions & 41 deletions

File tree

tests/functional/ctlplane/base_test.go

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -44,47 +44,50 @@ import (
4444
)
4545

4646
type Names struct {
47-
Namespace string
48-
OpenStackControlplaneName types.NamespacedName
49-
OpenStackVersionName types.NamespacedName
50-
KeystoneAPIName types.NamespacedName
51-
MemcachedName types.NamespacedName
52-
MemcachedCertName types.NamespacedName
53-
CinderName types.NamespacedName
54-
ManilaName types.NamespacedName
55-
GlanceName types.NamespacedName
56-
NeutronName types.NamespacedName
57-
HorizonName types.NamespacedName
58-
HeatName types.NamespacedName
59-
TelemetryName types.NamespacedName
60-
DBName types.NamespacedName
61-
DBCertName types.NamespacedName
62-
DBCell1Name types.NamespacedName
63-
DBCell1CertName types.NamespacedName
64-
RabbitMQName types.NamespacedName
65-
RabbitMQCertName types.NamespacedName
66-
RabbitMQCell1Name types.NamespacedName
67-
RabbitMQCell1CertName types.NamespacedName
68-
ServiceAccountName types.NamespacedName
69-
RoleName types.NamespacedName
70-
RoleBindingName types.NamespacedName
71-
RootCAPublicName types.NamespacedName
72-
RootCAInternalName types.NamespacedName
73-
RootCAOvnName types.NamespacedName
74-
RootCALibvirtName types.NamespacedName
75-
SelfSignedIssuerName types.NamespacedName
76-
CustomIssuerName types.NamespacedName
77-
CustomServiceCertSecretName types.NamespacedName
78-
CABundleName types.NamespacedName
79-
OpenStackClientName types.NamespacedName
80-
OVNNorthdName types.NamespacedName
81-
OVNNorthdCertName types.NamespacedName
82-
OVNControllerName types.NamespacedName
83-
OVNControllerCertName types.NamespacedName
84-
OVNDbServerNBName types.NamespacedName
85-
OVNDbServerSBName types.NamespacedName
86-
NeutronOVNCertName types.NamespacedName
87-
OpenStackTopology []types.NamespacedName
47+
Namespace string
48+
OpenStackControlplaneName types.NamespacedName
49+
OpenStackVersionName types.NamespacedName
50+
KeystoneAPIName types.NamespacedName
51+
MemcachedName types.NamespacedName
52+
MemcachedCertName types.NamespacedName
53+
CinderName types.NamespacedName
54+
ManilaName types.NamespacedName
55+
GlanceName types.NamespacedName
56+
NeutronName types.NamespacedName
57+
HorizonName types.NamespacedName
58+
HeatName types.NamespacedName
59+
TelemetryName types.NamespacedName
60+
DBName types.NamespacedName
61+
DBCertName types.NamespacedName
62+
DBCell1Name types.NamespacedName
63+
DBCell1CertName types.NamespacedName
64+
RabbitMQName types.NamespacedName
65+
RabbitMQCertName types.NamespacedName
66+
RabbitMQCell1Name types.NamespacedName
67+
RabbitMQCell1CertName types.NamespacedName
68+
NoVNCProxyCell1CertPublicRouteName types.NamespacedName
69+
NoVNCProxyCell1CertPublicSvcName types.NamespacedName
70+
NoVNCProxyCell1CertVencryptName types.NamespacedName
71+
ServiceAccountName types.NamespacedName
72+
RoleName types.NamespacedName
73+
RoleBindingName types.NamespacedName
74+
RootCAPublicName types.NamespacedName
75+
RootCAInternalName types.NamespacedName
76+
RootCAOvnName types.NamespacedName
77+
RootCALibvirtName types.NamespacedName
78+
SelfSignedIssuerName types.NamespacedName
79+
CustomIssuerName types.NamespacedName
80+
CustomServiceCertSecretName types.NamespacedName
81+
CABundleName types.NamespacedName
82+
OpenStackClientName types.NamespacedName
83+
OVNNorthdName types.NamespacedName
84+
OVNNorthdCertName types.NamespacedName
85+
OVNControllerName types.NamespacedName
86+
OVNControllerCertName types.NamespacedName
87+
OVNDbServerNBName types.NamespacedName
88+
OVNDbServerSBName types.NamespacedName
89+
NeutronOVNCertName types.NamespacedName
90+
OpenStackTopology []types.NamespacedName
8891
}
8992

9093
func CreateNames(openstackControlplaneName types.NamespacedName) Names {
@@ -200,6 +203,18 @@ func CreateNames(openstackControlplaneName types.NamespacedName) Names {
200203
Namespace: openstackControlplaneName.Namespace,
201204
Name: "cert-rabbitmq-cell1-svc",
202205
},
206+
NoVNCProxyCell1CertPublicRouteName: types.NamespacedName{
207+
Name: "cert-nova-novncproxy-cell1-public-route",
208+
Namespace: openstackControlplaneName.Namespace,
209+
},
210+
NoVNCProxyCell1CertPublicSvcName: types.NamespacedName{
211+
Name: "cert-nova-novncproxy-cell1-public-svc",
212+
Namespace: openstackControlplaneName.Namespace,
213+
},
214+
NoVNCProxyCell1CertVencryptName: types.NamespacedName{
215+
Name: "cert-nova-novncproxy-cell1-vencrypt",
216+
Namespace: openstackControlplaneName.Namespace,
217+
},
203218
OpenStackClientName: types.NamespacedName{
204219
Namespace: openstackControlplaneName.Namespace,
205220
Name: "openstackclient",

tests/functional/ctlplane/openstackoperator_controller_test.go

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ import (
4545
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
4646
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
4747
manilav1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1"
48+
novav1 "github.com/openstack-k8s-operators/nova-operator/api/v1beta1"
4849
clientv1 "github.com/openstack-k8s-operators/openstack-operator/apis/client/v1beta1"
4950
corev1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1"
5051
ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1"
52+
placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1"
5153
)
5254

5355
var _ = Describe("OpenStackOperator controller", func() {
@@ -2931,6 +2933,14 @@ var _ = Describe("OpenStackOperator controller galera and rabbitmq", func() {
29312933
th.CreateCertSecret(names.RabbitMQCertName)
29322934
th.CreateCertSecret(names.RabbitMQCell1CertName)
29332935

2936+
// create cert secrets for ovn instance
2937+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNNorthdCertName))
2938+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNControllerCertName))
2939+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.NeutronOVNCertName))
2940+
2941+
// create cert secrets for memcached instance
2942+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
2943+
29342944
extGalera := CreateGaleraConfig(namespace, GetDefaultGaleraSpec())
29352945
extGaleraName.Name = extGalera.GetName()
29362946
extGaleraName.Namespace = extGalera.GetNamespace()
@@ -3102,6 +3112,98 @@ var _ = Describe("OpenStackOperator controller galera and rabbitmq", func() {
31023112

31033113
})
31043114

3115+
When("The novncproxy k8s service is created", func() {
3116+
BeforeEach(func() {
3117+
3118+
novncProxyPublicSvcName := types.NamespacedName{
3119+
Name: "nova-novncproxy-cell1-public",
3120+
Namespace: namespace}
3121+
3122+
th.CreateService(
3123+
novncProxyPublicSvcName,
3124+
map[string]string{
3125+
"osctlplane-service": "nova-novncproxy",
3126+
"osctlplane": "",
3127+
},
3128+
k8s_corev1.ServiceSpec{
3129+
Ports: []k8s_corev1.ServicePort{
3130+
{
3131+
Name: "nova-novncproxy-cell1-public",
3132+
Port: int32(6080),
3133+
Protocol: k8s_corev1.ProtocolTCP,
3134+
},
3135+
},
3136+
})
3137+
3138+
novncProxySvc := th.GetService(novncProxyPublicSvcName)
3139+
3140+
if novncProxySvc.Annotations == nil {
3141+
novncProxySvc.Annotations = map[string]string{}
3142+
}
3143+
3144+
novncProxySvc.Annotations[service.AnnotationIngressCreateKey] = "true"
3145+
novncProxySvc.Annotations[service.AnnotationEndpointKey] = "public"
3146+
3147+
Expect(th.K8sClient.Status().Update(th.Ctx, novncProxySvc)).To(Succeed())
3148+
3149+
// vnproxy certs
3150+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.NoVNCProxyCell1CertPublicRouteName))
3151+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.NoVNCProxyCell1CertPublicSvcName))
3152+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.NoVNCProxyCell1CertVencryptName))
3153+
3154+
})
3155+
3156+
It("cell1 certs should be deleted from CR", func() {
3157+
3158+
// enable Nova and dependencies
3159+
Eventually(func(g Gomega) {
3160+
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
3161+
OSCtlplane.Spec.Nova.Enabled = true
3162+
OSCtlplane.Spec.Nova.Template = &novav1.NovaSpecCore{}
3163+
// enable "Galera, Memcached, RabbitMQ, Keystone, Glance, Neutron, Placement" too
3164+
3165+
OSCtlplane.Spec.Keystone.Enabled = true
3166+
OSCtlplane.Spec.Glance.Enabled = true
3167+
OSCtlplane.Spec.Neutron.Enabled = true
3168+
OSCtlplane.Spec.Placement.Enabled = true
3169+
// th.Logger.Info("", "number 5", "")
3170+
3171+
// th.Logger.Info("", ">>> pre-update", OSCtlplane)
3172+
3173+
if OSCtlplane.Spec.Placement.Template == nil {
3174+
OSCtlplane.Spec.Placement.Template = &placementv1.PlacementAPISpecCore{}
3175+
OSCtlplane.Spec.Placement.Template.APITimeout = 10
3176+
}
3177+
g.Expect(k8sClient.Update(ctx, OSCtlplane)).Should(Succeed())
3178+
}, timeout, interval).Should(Succeed())
3179+
3180+
// OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
3181+
3182+
// certNames := []types.NamespacedName{
3183+
// {Name: "cert-nova-novncproxy-cell1-public-route", Namespace: namespace},
3184+
// {Name: "cert-nova-novncproxy-cell1-public-svc", Namespace: namespace},
3185+
// {Name: "cert-nova-novncproxy-cell1-vencrypt", Namespace: namespace},
3186+
// }
3187+
3188+
// Eventually(func(g Gomega) {
3189+
// for _, certName := range certNames {
3190+
// cert := crtmgr.GetCert(certName)
3191+
// g.Expect(cert).NotTo(BeNil())
3192+
// th.Logger.Info("XXX cert created", "", cert.Name)
3193+
// }
3194+
// }, timeout, interval).Should(Succeed())
3195+
3196+
certs := crtmgr.GetCerts(namespace)
3197+
th.Logger.Info("XXX---", "", certs)
3198+
// for _, certName := range certs.Items {
3199+
// th.Logger.Info("XXX---", "", certName)
3200+
3201+
// }
3202+
3203+
})
3204+
3205+
})
3206+
31053207
})
31063208

31073209
})

0 commit comments

Comments
 (0)