Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Jirka Kremser <jiri.kremser@gmail.com>
  • Loading branch information
jkremser committed Oct 23, 2023
1 parent 367df1d commit 7a3669a
Show file tree
Hide file tree
Showing 2 changed files with 188 additions and 0 deletions.
39 changes: 39 additions & 0 deletions cmd/template/cluster/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,45 @@ func Test_run(t *testing.T) {
args: nil,
expectedGoldenFile: "run_template_cluster_capz.golden",
},
{
name: "case 5: template cluster capv",
flags: &flag{
Name: "test1",
Provider: "vsphere",
Description: "yet another test cluster",
Organization: "test",
KubernetesVersion: "v1.2.3",
App: provider.AppConfig{
ClusterVersion: "1.2.3",
ClusterCatalog: "foo-catalog",
DefaultAppsCatalog: "foo-default-catalog",
DefaultAppsVersion: "3.2.1",
},
VSphere: provider.VSphereConfig{
ServiceLoadBalancerCIDR: "1.2.3.4/32",
ResourcePool: "foopool",
NetworkName: "foonet",
CredentialsSecretName: "foosecret",
ImageTemplate: "foo-%-os",
ControlPlane: provider.VSphereControlPlane{
VSphereMachineTemplate: provider.VSphereMachineTemplate{
DiskGiB: 42,
MemoryMiB: 42000,
NumCPUs: 6,
Replicas: 5,
},
},
Worker: provider.VSphereMachineTemplate{
DiskGiB: 43,
MemoryMiB: 43000,
NumCPUs: 7,
Replicas: 4,
},
},
},
args: nil,
expectedGoldenFile: "run_template_cluster_capv.golden",
},
}

for _, tc := range testCases {
Expand Down
149 changes: 149 additions & 0 deletions cmd/template/cluster/testdata/run_template_cluster_capv.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
---
apiVersion: v1
data:
values: |
baseDomain: test.gigantic.io
cluster:
kubernetesVersion: v1.2.3
clusterDescription: yet another test cluster
connectivity:
network:
allowAllEgress: true
controlPlaneEndpoint:
host: ""
ipPoolName: wc-cp-ips
port: 6443
loadBalancers:
cidrBlocks:
- 1.2.3.4/32
controlPlane:
image:
repository: registry.k8s.io
machineTemplate:
cloneMode: linkedClone
diskGiB: 42
memoryMiB: 42000
network:
devices:
- dhcp4: true
networkName: foonet
numCPUs: 6
resourcePool: foopool
template: foo-%!o(string=v1.2.3)s
replicas: 5
helmReleases:
cilium:
interval: 20s
coredns:
interval: 30s
cpi:
interval: 30s
nodeClasses:
default:
cloneMode: linkedClone
diskGiB: 43
memoryMiB: 43000
network:
devices:
- dhcp4: true
networkName: foonet
numCPUs: 7
resourcePool: foopool
template: foo-%!o(string=v1.2.3)s
nodePools:
worker:
class: default
replicas: 4
organization: test
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
giantswarm.io/cluster: test1
name: test1-userconfig
namespace: org-test
---
apiVersion: application.giantswarm.io/v1alpha1
kind: App
metadata:
labels:
app-operator.giantswarm.io/version: 0.0.0
name: test1
namespace: org-test
spec:
catalog: foo-catalog
config:
configMap:
name: ""
namespace: ""
secret:
name: ""
namespace: ""
extraConfigs:
- kind: secret
name: container-registries-configuration
namespace: default
priority: 25
kubeConfig:
context:
name: ""
inCluster: true
secret:
name: ""
namespace: ""
name: cluster-vsphere
namespace: org-test
userConfig:
configMap:
name: test1-userconfig
namespace: org-test
secret:
name: foosecret
namespace: org-test
version: 1.2.3
---
apiVersion: v1
data:
values: |
clusterName: test1
organization: test
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
giantswarm.io/cluster: test1
name: test1-default-apps-userconfig
namespace: org-test
---
apiVersion: application.giantswarm.io/v1alpha1
kind: App
metadata:
labels:
app-operator.giantswarm.io/version: 0.0.0
giantswarm.io/cluster: test1
giantswarm.io/managed-by: cluster
name: test1-default-apps
namespace: org-test
spec:
catalog: foo-default-catalog
config:
configMap:
name: test1-cluster-values
namespace: org-test
secret:
name: ""
namespace: ""
kubeConfig:
context:
name: ""
inCluster: true
secret:
name: ""
namespace: ""
name: default-apps-vsphere
namespace: org-test
userConfig:
configMap:
name: test1-default-apps-userconfig
namespace: org-test
version: 3.2.1

0 comments on commit 7a3669a

Please sign in to comment.