@@ -42,6 +42,7 @@ func TestNutanixChecker_Init(t *testing.T) {
42
42
vmImageCheckCount int
43
43
vmImageKubernetesVersionCheckCount int
44
44
storageContainerCheckCount int
45
+ failureDomainCheckCount int
45
46
}{
46
47
{
47
48
name : "basic initialization with no configs" ,
@@ -53,6 +54,7 @@ func TestNutanixChecker_Init(t *testing.T) {
53
54
vmImageCheckCount : 0 ,
54
55
vmImageKubernetesVersionCheckCount : 0 ,
55
56
storageContainerCheckCount : 0 ,
57
+ failureDomainCheckCount : 0 ,
56
58
},
57
59
{
58
60
name : "initialization with control plane config" ,
@@ -62,12 +64,13 @@ func TestNutanixChecker_Init(t *testing.T) {
62
64
},
63
65
},
64
66
workerNodeConfigs : nil ,
65
- expectedCheckCount : 5 , //nolint:lll // config check, credentials check, 1 VM image check, 1 storage container check, 1 VM image Kubernetes version check
67
+ expectedCheckCount : 6 , //nolint:lll // config check, credentials check, 1 VM image check, 1 storage container check, 1 VM image Kubernetes version check, 1 failure domain check
66
68
expectedFirstCheckName : "NutanixConfiguration" ,
67
69
expectedSecondCheckName : "NutanixCredentials" ,
68
70
vmImageCheckCount : 1 ,
69
71
vmImageKubernetesVersionCheckCount : 1 ,
70
72
storageContainerCheckCount : 1 ,
73
+ failureDomainCheckCount : 1 ,
71
74
},
72
75
{
73
76
name : "initialization with worker node configs" ,
@@ -80,12 +83,13 @@ func TestNutanixChecker_Init(t *testing.T) {
80
83
Nutanix : & carenv1.NutanixWorkerNodeSpec {},
81
84
},
82
85
},
83
- expectedCheckCount : 8 , //nolint:lll // config check, credentials check, 2 VM image checks, 2 storage container checks, 2 VM image Kubernetes version checks
86
+ expectedCheckCount : 10 , //nolint:lll // config check, credentials check, 2 VM image checks, 2 storage container checks, 2 VM image Kubernetes version checks, 2 failure domain checks
84
87
expectedFirstCheckName : "NutanixConfiguration" ,
85
88
expectedSecondCheckName : "NutanixCredentials" ,
86
89
vmImageCheckCount : 2 ,
87
90
vmImageKubernetesVersionCheckCount : 2 ,
88
91
storageContainerCheckCount : 2 ,
92
+ failureDomainCheckCount : 2 ,
89
93
},
90
94
{
91
95
name : "initialization with both control plane and worker node configs" ,
@@ -99,12 +103,13 @@ func TestNutanixChecker_Init(t *testing.T) {
99
103
Nutanix : & carenv1.NutanixWorkerNodeSpec {},
100
104
},
101
105
},
102
- expectedCheckCount : 8 , //nolint:lll // config check, credentials check, 2 VM image checks (1 CP + 1 worker), 2 storage container checks (1 CP + 1 worker), 2 VM image Kubernetes version checks
106
+ expectedCheckCount : 10 , //nolint:lll // config check, credentials check, 2 VM image checks (1 CP + 1 worker), 2 storage container checks (1 CP + 1 worker), 2 VM image Kubernetes version checks, 2 failure domain checks
103
107
expectedFirstCheckName : "NutanixConfiguration" ,
104
108
expectedSecondCheckName : "NutanixCredentials" ,
105
109
vmImageCheckCount : 2 ,
106
110
vmImageKubernetesVersionCheckCount : 2 ,
107
111
storageContainerCheckCount : 2 ,
112
+ failureDomainCheckCount : 2 ,
108
113
},
109
114
}
110
115
@@ -119,6 +124,7 @@ func TestNutanixChecker_Init(t *testing.T) {
119
124
vmImageCheckCount := 0
120
125
storageContainerCheckCount := 0
121
126
vmImageKubernetesVersionCheckCount := 0
127
+ failureDomainCheckCount := 0
122
128
123
129
checker .configurationCheckFactory = func (cd * checkDependencies ) preflight.Check {
124
130
configCheckCalled = true
@@ -188,6 +194,22 @@ func TestNutanixChecker_Init(t *testing.T) {
188
194
return checks
189
195
}
190
196
197
+ checker .failureDomainCheckFactory = func (cd * checkDependencies ) []preflight.Check {
198
+ checks := []preflight.Check {}
199
+ for i := 0 ; i < tt .failureDomainCheckCount ; i ++ {
200
+ failureDomainCheckCount ++
201
+ checks = append (checks ,
202
+ & mockCheck {
203
+ name : fmt .Sprintf ("NutanixFailureDomain-%d" , i ),
204
+ result : preflight.CheckResult {
205
+ Allowed : true ,
206
+ },
207
+ },
208
+ )
209
+ }
210
+ return checks
211
+ }
212
+
191
213
// Call Init
192
214
ctx := context .Background ()
193
215
checks := checker .Init (ctx , nil , & clusterv1.Cluster {
@@ -210,6 +232,12 @@ func TestNutanixChecker_Init(t *testing.T) {
210
232
storageContainerCheckCount ,
211
233
"Wrong number of storage container checks" ,
212
234
)
235
+ assert .Equal (
236
+ t ,
237
+ tt .failureDomainCheckCount ,
238
+ failureDomainCheckCount ,
239
+ "Wrong number of failure domain checks" ,
240
+ )
213
241
214
242
// Verify the first two checks when we have results
215
243
if len (checks ) >= 2 {
0 commit comments