Skip to content

Commit 7141023

Browse files
committed
tests: e2e tests implemented
Signed-off-by: Bharath Nallapeta <[email protected]>
1 parent a0074c3 commit 7141023

18 files changed

+344
-64
lines changed

api/v1beta1/identity_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ package v1beta1
1919
// OpenStackIdentityReference is a reference to an infrastructure
2020
// provider identity to be used to provision cluster resources.
2121
// +kubebuilder:validation:XValidation:rule="(!has(self.region) && !has(oldSelf.region)) || self.region == oldSelf.region",message="region is immutable"
22-
// +kubebuilder:validation:XValidation:rule="has(self.name)",message="name is required"
23-
// +kubebuilder:validation:XValidation:rule="has(self.cloudName)",message="cloudName is required"
2422
type OpenStackIdentityReference struct {
2523
// Type specifies the identity reference type. Defaults to Secret for backward compatibility.
2624
// +kubebuilder:validation:Enum=Secret;ClusterIdentity
@@ -33,10 +31,12 @@ type OpenStackIdentityReference struct {
3331
// The Secret must contain a key named `clouds.yaml` which contains an OpenStack clouds.yaml file.
3432
// The Secret may optionally contain a key named `cacert` containing a PEM-encoded CA certificate.
3533
// +kubebuilder:validation:Required
34+
// +kubebuilder:validation:MinLength=1
3635
Name string `json:"name"`
3736

3837
// CloudName specifies the name of the entry in the clouds.yaml file to use.
3938
// +kubebuilder:validation:Required
39+
// +kubebuilder:validation:MinLength=1
4040
CloudName string `json:"cloudName"`
4141

4242
// Region specifies an OpenStack region to use. If specified, it overrides

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackfloatingippools.yaml

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackmachines.yaml

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackmachinetemplates.yaml

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackservers.yaml

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controllers/openstackcluster_controller_test.go

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ var _ = Describe("OpenStackCluster controller", func() {
9090
},
9191
},
9292
},
93-
Spec: infrav1.OpenStackClusterSpec{},
93+
Spec: infrav1.OpenStackClusterSpec{
94+
IdentityRef: infrav1.OpenStackIdentityReference{
95+
Name: "test-creds",
96+
CloudName: "openstack",
97+
},
98+
},
9499
Status: infrav1.OpenStackClusterStatus{},
95100
}
96101
capiCluster = &clusterv1.Cluster{
@@ -326,6 +331,10 @@ var _ = Describe("OpenStackCluster controller", func() {
326331
It("should be able to reconcile when bastion is explicitly disabled and does not exist", func() {
327332
testCluster.SetName("no-bastion-explicit")
328333
testCluster.Spec = infrav1.OpenStackClusterSpec{
334+
IdentityRef: infrav1.OpenStackIdentityReference{
335+
Name: "test-creds",
336+
CloudName: "openstack",
337+
},
329338
Bastion: &infrav1.Bastion{Enabled: ptr.To(false)},
330339
}
331340
err := k8sClient.Create(ctx, testCluster)
@@ -350,7 +359,12 @@ var _ = Describe("OpenStackCluster controller", func() {
350359
})
351360
It("should delete an existing bastion even if its uuid is not stored in status", func() {
352361
testCluster.SetName("delete-existing-bastion")
353-
testCluster.Spec = infrav1.OpenStackClusterSpec{}
362+
testCluster.Spec = infrav1.OpenStackClusterSpec{
363+
IdentityRef: infrav1.OpenStackIdentityReference{
364+
Name: "test-creds",
365+
CloudName: "openstack",
366+
},
367+
}
354368
err := k8sClient.Create(ctx, testCluster)
355369
Expect(err).To(BeNil())
356370
err = k8sClient.Create(ctx, capiCluster)
@@ -381,6 +395,10 @@ var _ = Describe("OpenStackCluster controller", func() {
381395

382396
testCluster.SetName("subnet-filtering")
383397
testCluster.Spec = infrav1.OpenStackClusterSpec{
398+
IdentityRef: infrav1.OpenStackIdentityReference{
399+
Name: "test-creds",
400+
CloudName: "openstack",
401+
},
384402
Bastion: &infrav1.Bastion{
385403
Enabled: ptr.To(true),
386404
Spec: &bastionSpec,
@@ -451,6 +469,10 @@ var _ = Describe("OpenStackCluster controller", func() {
451469

452470
testCluster.SetName("subnet-filtering")
453471
testCluster.Spec = infrav1.OpenStackClusterSpec{
472+
IdentityRef: infrav1.OpenStackIdentityReference{
473+
Name: "test-creds",
474+
CloudName: "openstack",
475+
},
454476
Bastion: &infrav1.Bastion{
455477
Enabled: ptr.To(true),
456478
Spec: &bastionSpec,
@@ -528,6 +550,10 @@ var _ = Describe("OpenStackCluster controller", func() {
528550

529551
testCluster.SetName("subnet-filtering")
530552
testCluster.Spec = infrav1.OpenStackClusterSpec{
553+
IdentityRef: infrav1.OpenStackIdentityReference{
554+
Name: "test-creds",
555+
CloudName: "openstack",
556+
},
531557
DisableAPIServerFloatingIP: ptr.To(true),
532558
APIServerFixedIP: ptr.To("10.0.0.1"),
533559
DisableExternalNetwork: ptr.To(true),
@@ -571,6 +597,10 @@ var _ = Describe("OpenStackCluster controller", func() {
571597

572598
testCluster.SetName("pre-existing-network-components-by-id")
573599
testCluster.Spec = infrav1.OpenStackClusterSpec{
600+
IdentityRef: infrav1.OpenStackIdentityReference{
601+
Name: "test-creds",
602+
CloudName: "openstack",
603+
},
574604
Network: &infrav1.NetworkParam{
575605
ID: ptr.To(clusterNetworkID),
576606
},
@@ -630,6 +660,10 @@ var _ = Describe("OpenStackCluster controller", func() {
630660

631661
testCluster.SetName("pre-existing-network-components-by-id")
632662
testCluster.Spec = infrav1.OpenStackClusterSpec{
663+
IdentityRef: infrav1.OpenStackIdentityReference{
664+
Name: "test-creds",
665+
CloudName: "openstack",
666+
},
633667
Network: &infrav1.NetworkParam{
634668
Filter: &infrav1.NetworkFilter{
635669
Name: clusterNetworkName,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- ../../../../../kustomize/v1beta1/default
6+
- openstackclusteridentity.yaml
7+
8+
components:
9+
- ../common-patches/cluster
10+
- ../common-patches/cni
11+
- ../upgrade-patches
12+
- ../common-patches/ccm
13+
- ../common-patches/externalNetworkByName
14+
- ../common-patches/images
15+
16+
patches:
17+
- path: patch-openstackcluster-identityref.yaml
18+
target:
19+
kind: OpenStackCluster
20+
name: ${CLUSTER_NAME}
21+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
2+
kind: OpenStackClusterIdentity
3+
metadata:
4+
name: ${CLUSTER_NAME}-cluster-identity
5+
spec:
6+
secretRef:
7+
name: ${CLUSTER_NAME}-cloud-config
8+
namespace: ${NAMESPACE}
9+
namespaceSelector:
10+
matchLabels:
11+
env: prod
12+

0 commit comments

Comments
 (0)