Skip to content

Commit

Permalink
add helm units tests for gcp cluster crds
Browse files Browse the repository at this point in the history
  • Loading branch information
floreks committed Sep 12, 2023
1 parent 9329f31 commit 9dc5afe
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 0 deletions.
33 changes: 33 additions & 0 deletions bootstrap/helm/cluster-api-cluster/tests/gcp_cluster_test.yaml
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9dc5afe

Please sign in to comment.