@@ -21,11 +21,12 @@ import (
21
21
22
22
func TestInitStorageContainerChecks (t * testing.T ) {
23
23
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
29
30
}{
30
31
{
31
32
name : "client not initialized" ,
@@ -80,7 +81,7 @@ func TestInitStorageContainerChecks(t *testing.T) {
80
81
nclient : & mocknclient {},
81
82
},
82
83
{
83
- name : "cluster config with CSI and control plane" ,
84
+ name : "cluster config with CSI and control plane without failure domains " ,
84
85
nutanixClusterConfigSpec : & carenv1.NutanixClusterConfigSpec {
85
86
ControlPlane : & carenv1.NutanixControlPlaneSpec {
86
87
Nutanix : & carenv1.NutanixControlPlaneNodeSpec {
@@ -113,7 +114,41 @@ func TestInitStorageContainerChecks(t *testing.T) {
113
114
nclient : & mocknclient {},
114
115
},
115
116
{
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" ,
117
152
nutanixClusterConfigSpec : & carenv1.NutanixClusterConfigSpec {
118
153
Addons : & carenv1.NutanixAddons {
119
154
CSI : & carenv1.NutanixCSI {
@@ -138,6 +173,33 @@ func TestInitStorageContainerChecks(t *testing.T) {
138
173
expectedChecksCount : 1 ,
139
174
nclient : & mocknclient {},
140
175
},
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
+ },
141
203
{
142
204
name : "cluster config with CSI, control plane and worker nodes" ,
143
205
nutanixClusterConfigSpec : & carenv1.NutanixClusterConfigSpec {
@@ -238,7 +300,11 @@ func TestInitStorageContainerChecks(t *testing.T) {
238
300
cd := & checkDependencies {
239
301
nutanixClusterConfigSpec : tc .nutanixClusterConfigSpec ,
240
302
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 {}
242
308
}
243
309
244
310
// Call the function under test
0 commit comments