@@ -21,11 +21,12 @@ import (
2121
2222func TestInitStorageContainerChecks (t * testing.T ) {
2323 testCases := []struct {
24- name string
25- nutanixClusterConfigSpec * carenv1.NutanixClusterConfigSpec
26- workerNodeConfigSpecByMDName map [string ]* carenv1.NutanixWorkerNodeConfigSpec
27- expectedChecksCount int
28- nclient client
24+ name string
25+ nutanixClusterConfigSpec * carenv1.NutanixClusterConfigSpec
26+ workerNodeConfigSpecByMDName map [string ]* carenv1.NutanixWorkerNodeConfigSpec
27+ failureDomainByMachineDeploymentName map [string ]string
28+ expectedChecksCount int
29+ nclient client
2930 }{
3031 {
3132 name : "client not initialized" ,
@@ -80,7 +81,7 @@ func TestInitStorageContainerChecks(t *testing.T) {
8081 nclient : & mocknclient {},
8182 },
8283 {
83- name : "cluster config with CSI and control plane" ,
84+ name : "cluster config with CSI and control plane without failure domains " ,
8485 nutanixClusterConfigSpec : & carenv1.NutanixClusterConfigSpec {
8586 ControlPlane : & carenv1.NutanixControlPlaneSpec {
8687 Nutanix : & carenv1.NutanixControlPlaneNodeSpec {
@@ -113,7 +114,41 @@ func TestInitStorageContainerChecks(t *testing.T) {
113114 nclient : & mocknclient {},
114115 },
115116 {
116- name : "cluster config with CSI and worker nodes" ,
117+ name : "cluster config with CSI and control plane with failure domains" ,
118+ nutanixClusterConfigSpec : & carenv1.NutanixClusterConfigSpec {
119+ ControlPlane : & carenv1.NutanixControlPlaneSpec {
120+ Nutanix : & carenv1.NutanixControlPlaneNodeSpec {
121+ FailureDomains : []string {"fd-1" , "fd-2" , "fd-3" },
122+ MachineDetails : carenv1.NutanixMachineDetails {
123+ Cluster : capxv1.NutanixResourceIdentifier {
124+ Type : capxv1 .NutanixIdentifierName ,
125+ Name : ptr .To ("my-cluster" ),
126+ },
127+ },
128+ },
129+ },
130+ Addons : & carenv1.NutanixAddons {
131+ CSI : & carenv1.NutanixCSI {
132+ Providers : carenv1.NutanixCSIProviders {
133+ NutanixCSI : carenv1.CSIProvider {
134+ StorageClassConfigs : map [string ]carenv1.StorageClassConfig {
135+ "test-sc" : {
136+ Parameters : map [string ]string {
137+ "storageContainer" : "test-container" ,
138+ },
139+ },
140+ },
141+ },
142+ },
143+ },
144+ },
145+ },
146+ workerNodeConfigSpecByMDName : map [string ]* carenv1.NutanixWorkerNodeConfigSpec {},
147+ expectedChecksCount : 0 ,
148+ nclient : & mocknclient {},
149+ },
150+ {
151+ name : "cluster config with CSI and worker nodes without failureDomain" ,
117152 nutanixClusterConfigSpec : & carenv1.NutanixClusterConfigSpec {
118153 Addons : & carenv1.NutanixAddons {
119154 CSI : & carenv1.NutanixCSI {
@@ -138,6 +173,33 @@ func TestInitStorageContainerChecks(t *testing.T) {
138173 expectedChecksCount : 1 ,
139174 nclient : & mocknclient {},
140175 },
176+ {
177+ name : "cluster config with CSI and worker nodes with failureDomain" ,
178+ nutanixClusterConfigSpec : & carenv1.NutanixClusterConfigSpec {
179+ Addons : & carenv1.NutanixAddons {
180+ CSI : & carenv1.NutanixCSI {
181+ Providers : carenv1.NutanixCSIProviders {
182+ NutanixCSI : carenv1.CSIProvider {},
183+ },
184+ },
185+ },
186+ },
187+ workerNodeConfigSpecByMDName : map [string ]* carenv1.NutanixWorkerNodeConfigSpec {
188+ "worker-1" : {
189+ Nutanix : & carenv1.NutanixWorkerNodeSpec {
190+ MachineDetails : carenv1.NutanixMachineDetails {
191+ Cluster : capxv1.NutanixResourceIdentifier {
192+ Type : capxv1 .NutanixIdentifierName ,
193+ Name : ptr .To ("worker-cluster" ),
194+ },
195+ },
196+ },
197+ },
198+ },
199+ failureDomainByMachineDeploymentName : map [string ]string {"worker-1" : "fd-4" },
200+ expectedChecksCount : 0 ,
201+ nclient : & mocknclient {},
202+ },
141203 {
142204 name : "cluster config with CSI, control plane and worker nodes" ,
143205 nutanixClusterConfigSpec : & carenv1.NutanixClusterConfigSpec {
@@ -238,7 +300,11 @@ func TestInitStorageContainerChecks(t *testing.T) {
238300 cd := & checkDependencies {
239301 nutanixClusterConfigSpec : tc .nutanixClusterConfigSpec ,
240302 nutanixWorkerNodeConfigSpecByMachineDeploymentName : tc .workerNodeConfigSpecByMDName ,
241- nclient : tc .nclient ,
303+ failureDomainByMachineDeploymentName : tc .failureDomainByMachineDeploymentName ,
304+ nclient : tc .nclient ,
305+ }
306+ if cd .failureDomainByMachineDeploymentName == nil {
307+ cd .failureDomainByMachineDeploymentName = map [string ]string {}
242308 }
243309
244310 // Call the function under test
0 commit comments