From 7a3669a25f1b362f50082e6b1e03b1a3a63b821e Mon Sep 17 00:00:00 2001 From: Jirka Kremser Date: Mon, 23 Oct 2023 13:22:39 +0200 Subject: [PATCH] add unit test Signed-off-by: Jirka Kremser --- cmd/template/cluster/runner_test.go | 39 +++++ .../testdata/run_template_cluster_capv.golden | 149 ++++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 cmd/template/cluster/testdata/run_template_cluster_capv.golden diff --git a/cmd/template/cluster/runner_test.go b/cmd/template/cluster/runner_test.go index 1a95851f0..f452b738c 100644 --- a/cmd/template/cluster/runner_test.go +++ b/cmd/template/cluster/runner_test.go @@ -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 { diff --git a/cmd/template/cluster/testdata/run_template_cluster_capv.golden b/cmd/template/cluster/testdata/run_template_cluster_capv.golden new file mode 100644 index 000000000..4abdd61fb --- /dev/null +++ b/cmd/template/cluster/testdata/run_template_cluster_capv.golden @@ -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