diff --git a/bootstrap/helm/cluster-api-cluster/tests/gcp_cluster_test.yaml b/bootstrap/helm/cluster-api-cluster/tests/gcp_cluster_test.yaml new file mode 100644 index 000000000..c80d6d2cc --- /dev/null +++ b/bootstrap/helm/cluster-api-cluster/tests/gcp_cluster_test.yaml @@ -0,0 +1,33 @@ +suite: test gcp cluster +templates: + - gcp/cluster.yaml +tests: + - it: should be created with default values when provider is gcp + set: + provider: gcp + type: managed + asserts: + - hasDocuments: + count: 1 + - isKind: + of: GCPManagedCluster + - equal: + path: metadata.name + value: plural + - isNullOrEmpty: + path: spec.project + - isNullOrEmpty: + path: spec.region + - lengthEqual: + path: spec.network.subnets + count: 1 + - equal: + path: spec.network.subnets[0].name + value: plural-subnetwork + - it: should not be created when provider is not gcp + set: + type: managed + asserts: + - hasDocuments: + count: 0 + diff --git a/bootstrap/helm/cluster-api-cluster/tests/gcp_control_plane_test.yaml b/bootstrap/helm/cluster-api-cluster/tests/gcp_control_plane_test.yaml new file mode 100644 index 000000000..0b5ff2515 --- /dev/null +++ b/bootstrap/helm/cluster-api-cluster/tests/gcp_control_plane_test.yaml @@ -0,0 +1,71 @@ +suite: test gcp control plane +templates: + - gcp/control-plane.yaml +tests: + - it: should be created with default values when provider is gcp + set: + provider: gcp + type: managed + asserts: + - hasDocuments: + count: 1 + - isKind: + of: GCPManagedControlPlane + - equal: + path: metadata.name + value: plural + - equal: + path: spec.clusterName + value: plural + - isNullOrEmpty: + path: spec.project + - isNullOrEmpty: + path: spec.location + - equal: + path: spec.controlPlaneVersion + value: "1.24.16" + - it: should use custom kubernetes version if provided + set: + provider: gcp + type: managed + cluster.kubernetesVersion: 1.24 + asserts: + - hasDocuments: + count: 1 + - isKind: + of: GCPManagedControlPlane + - equal: + path: spec.controlPlaneVersion + value: "1.24" + - it: should not contain release channel if set to "unspecified" + set: + provider: gcp + type: managed + cluster.gcp.releaseChannel: unspecified + asserts: + - hasDocuments: + count: 1 + - isKind: + of: GCPManagedControlPlane + - notExists: + path: spec.releaseChannel + - it: should contain release channel if set + set: + provider: gcp + type: managed + cluster.gcp.releaseChannel: stable + asserts: + - hasDocuments: + count: 1 + - isKind: + of: GCPManagedControlPlane + - equal: + path: spec.releaseChannel + value: stable + - it: should not be created when provider is not gcp + set: + type: managed + asserts: + - hasDocuments: + count: 0 + diff --git a/bootstrap/helm/cluster-api-cluster/tests/gcp_machinepools_test.yaml b/bootstrap/helm/cluster-api-cluster/tests/gcp_machinepools_test.yaml new file mode 100644 index 000000000..09ad196ad --- /dev/null +++ b/bootstrap/helm/cluster-api-cluster/tests/gcp_machinepools_test.yaml @@ -0,0 +1,79 @@ +suite: test gcp machine pools +templates: + - gcp/machinepools.yaml +tests: + - it: should be created with default values when provider is gcp + set: + provider: gcp + type: managed + asserts: + - hasDocuments: + count: 6 + - documentIndex: 0 + isKind: + of: GCPManagedMachinePool + - documentIndex: 1 + isKind: + of: MachinePool + - documentIndex: 0 + equal: + path: metadata.name + value: large-burst-on-demand + - documentIndex: 0 + equal: + path: spec.nodePoolName + value: large-burst-on-demand + - documentIndex: 0 + equal: + path: spec.machineType + value: e2-standard-8 + - documentIndex: 2 + equal: + path: metadata.name + value: medium-burst-on-demand + - documentIndex: 2 + equal: + path: spec.nodePoolName + value: medium-burst-on-demand + - documentIndex: 2 + equal: + path: spec.machineType + value: e2-standard-4 + - documentIndex: 4 + equal: + path: metadata.name + value: small-burst-on-demand + - documentIndex: 4 + equal: + path: spec.nodePoolName + value: small-burst-on-demand + - documentIndex: 4 + equal: + path: spec.machineType + value: e2-standard-2 + - it: should have default kubernetes version set + set: + provider: gcp + type: managed + asserts: + - documentIndex: 1 + equal: + path: spec.template.spec.version + value: "1.24.16" + - it: should have custom kubernetes version set + set: + provider: gcp + type: managed + cluster.kubernetesVersion: 1.24 + asserts: + - documentIndex: 1 + equal: + path: spec.template.spec.version + value: "1.24" + - it: should not be created when provider is not gcp + set: + type: managed + asserts: + - hasDocuments: + count: 0 +