@@ -42,6 +42,7 @@ func TestNutanixChecker_Init(t *testing.T) {
4242 vmImageCheckCount int
4343 vmImageKubernetesVersionCheckCount int
4444 storageContainerCheckCount int
45+ failureDomainCheckCount int
4546 }{
4647 {
4748 name : "basic initialization with no configs" ,
@@ -53,6 +54,7 @@ func TestNutanixChecker_Init(t *testing.T) {
5354 vmImageCheckCount : 0 ,
5455 vmImageKubernetesVersionCheckCount : 0 ,
5556 storageContainerCheckCount : 0 ,
57+ failureDomainCheckCount : 0 ,
5658 },
5759 {
5860 name : "initialization with control plane config" ,
@@ -62,12 +64,13 @@ func TestNutanixChecker_Init(t *testing.T) {
6264 },
6365 },
6466 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
6668 expectedFirstCheckName : "NutanixConfiguration" ,
6769 expectedSecondCheckName : "NutanixCredentials" ,
6870 vmImageCheckCount : 1 ,
6971 vmImageKubernetesVersionCheckCount : 1 ,
7072 storageContainerCheckCount : 1 ,
73+ failureDomainCheckCount : 1 ,
7174 },
7275 {
7376 name : "initialization with worker node configs" ,
@@ -80,12 +83,13 @@ func TestNutanixChecker_Init(t *testing.T) {
8083 Nutanix : & carenv1.NutanixWorkerNodeSpec {},
8184 },
8285 },
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
8487 expectedFirstCheckName : "NutanixConfiguration" ,
8588 expectedSecondCheckName : "NutanixCredentials" ,
8689 vmImageCheckCount : 2 ,
8790 vmImageKubernetesVersionCheckCount : 2 ,
8891 storageContainerCheckCount : 2 ,
92+ failureDomainCheckCount : 2 ,
8993 },
9094 {
9195 name : "initialization with both control plane and worker node configs" ,
@@ -99,12 +103,13 @@ func TestNutanixChecker_Init(t *testing.T) {
99103 Nutanix : & carenv1.NutanixWorkerNodeSpec {},
100104 },
101105 },
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
103107 expectedFirstCheckName : "NutanixConfiguration" ,
104108 expectedSecondCheckName : "NutanixCredentials" ,
105109 vmImageCheckCount : 2 ,
106110 vmImageKubernetesVersionCheckCount : 2 ,
107111 storageContainerCheckCount : 2 ,
112+ failureDomainCheckCount : 2 ,
108113 },
109114 }
110115
@@ -119,6 +124,7 @@ func TestNutanixChecker_Init(t *testing.T) {
119124 vmImageCheckCount := 0
120125 storageContainerCheckCount := 0
121126 vmImageKubernetesVersionCheckCount := 0
127+ failureDomainCheckCount := 0
122128
123129 checker .configurationCheckFactory = func (cd * checkDependencies ) preflight.Check {
124130 configCheckCalled = true
@@ -188,6 +194,22 @@ func TestNutanixChecker_Init(t *testing.T) {
188194 return checks
189195 }
190196
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+
191213 // Call Init
192214 ctx := context .Background ()
193215 checks := checker .Init (ctx , nil , & clusterv1.Cluster {
@@ -210,6 +232,12 @@ func TestNutanixChecker_Init(t *testing.T) {
210232 storageContainerCheckCount ,
211233 "Wrong number of storage container checks" ,
212234 )
235+ assert .Equal (
236+ t ,
237+ tt .failureDomainCheckCount ,
238+ failureDomainCheckCount ,
239+ "Wrong number of failure domain checks" ,
240+ )
213241
214242 // Verify the first two checks when we have results
215243 if len (checks ) >= 2 {
0 commit comments