@@ -388,7 +388,7 @@ func TestClusterReconcilePhases_reconcileFailureDomains(t *testing.T) {
388
388
},
389
389
InfrastructureRef : & corev1.ObjectReference {
390
390
APIVersion : "infrastructure.cluster.x-k8s.io/v1beta1" ,
391
- Kind : "GenericInfrastructureMachine " ,
391
+ Kind : "GenericInfrastructureCluster " ,
392
392
Name : "test" ,
393
393
},
394
394
},
@@ -438,25 +438,32 @@ func TestClusterReconcilePhases_reconcileFailureDomains(t *testing.T) {
438
438
cluster : & clusterv1.Cluster {ObjectMeta : metav1.ObjectMeta {Name : "test-cluster" , Namespace : "test-namespace" }},
439
439
},
440
440
{
441
- name : "expect no failure domain if infra config does not have failure domain" ,
442
- cluster : cluster ,
443
- infraRef : generateInfraRef (false ),
441
+ name : "expect no failure domain if infra config does not have failure domain" ,
442
+ cluster : cluster .DeepCopy (),
443
+ infraRef : generateInfraRef (false ),
444
+ expectFailureDomains : clusterv1.FailureDomains {},
445
+ },
446
+ {
447
+ name : "expect cluster failure domain to be reset to empty if infra config does not have failure domain" ,
448
+ cluster : clusterWithOldFailureDomain .DeepCopy (),
449
+ infraRef : generateInfraRef (false ),
450
+ expectFailureDomains : clusterv1.FailureDomains {},
444
451
},
445
452
{
446
453
name : "expect failure domain to remain same if infra config have same failure domain" ,
447
- cluster : cluster ,
454
+ cluster : cluster . DeepCopy () ,
448
455
infraRef : generateInfraRef (true ),
449
456
expectFailureDomains : newFailureDomain ,
450
457
},
451
458
{
452
- name : "expect failure domain to be updated if infra config have update to failure domain" ,
453
- cluster : clusterWithNewFailureDomainUpdated ,
459
+ name : "expect failure domain to be updated if infra config has updates to failure domain" ,
460
+ cluster : clusterWithNewFailureDomainUpdated . DeepCopy () ,
454
461
infraRef : generateInfraRef (true ),
455
462
expectFailureDomains : newFailureDomain ,
456
463
},
457
464
{
458
465
name : "expect failure domain to be reset if infra config have different failure domain" ,
459
- cluster : clusterWithOldFailureDomain ,
466
+ cluster : clusterWithOldFailureDomain . DeepCopy () ,
460
467
infraRef : generateInfraRef (true ),
461
468
expectFailureDomains : newFailureDomain ,
462
469
},
@@ -466,7 +473,7 @@ func TestClusterReconcilePhases_reconcileFailureDomains(t *testing.T) {
466
473
t .Run (tt .name , func (t * testing.T ) {
467
474
g := NewWithT (t )
468
475
469
- objs := []client.Object {builder .GenericInfrastructureMachineCRD .DeepCopy (), tt .cluster }
476
+ objs := []client.Object {builder .GenericInfrastructureClusterCRD .DeepCopy (), tt .cluster }
470
477
if tt .infraRef != nil {
471
478
objs = append (objs , & unstructured.Unstructured {Object : tt .infraRef })
472
479
}
@@ -477,20 +484,23 @@ func TestClusterReconcilePhases_reconcileFailureDomains(t *testing.T) {
477
484
478
485
_ , err := r .reconcileInfrastructure (ctx , tt .cluster )
479
486
g .Expect (err ).ToNot (HaveOccurred ())
480
- g .Expect (cluster .Status .FailureDomains ).To (BeEquivalentTo (tt .expectFailureDomains ))
487
+ g .Expect (tt . cluster .Status .FailureDomains ).To (BeEquivalentTo (tt .expectFailureDomains ))
481
488
})
482
489
}
483
490
}
484
491
485
492
func generateInfraRef (withFailureDomain bool ) map [string ]interface {} {
486
493
infraRef := map [string ]interface {}{
487
- "kind" : "GenericInfrastructureMachine " ,
494
+ "kind" : "GenericInfrastructureCluster " ,
488
495
"apiVersion" : "infrastructure.cluster.x-k8s.io/v1beta1" ,
489
496
"metadata" : map [string ]interface {}{
490
497
"name" : "test" ,
491
498
"namespace" : "test-namespace" ,
492
499
"deletionTimestamp" : "sometime" ,
493
500
},
501
+ "status" : map [string ]interface {}{
502
+ "ready" : true ,
503
+ },
494
504
}
495
505
496
506
if withFailureDomain {
0 commit comments