@@ -388,7 +388,7 @@ func TestClusterReconcilePhases_reconcileFailureDomains(t *testing.T) {
388388 },
389389 InfrastructureRef : & corev1.ObjectReference {
390390 APIVersion : "infrastructure.cluster.x-k8s.io/v1beta1" ,
391- Kind : "GenericInfrastructureMachine " ,
391+ Kind : "GenericInfrastructureCluster " ,
392392 Name : "test" ,
393393 },
394394 },
@@ -438,25 +438,32 @@ func TestClusterReconcilePhases_reconcileFailureDomains(t *testing.T) {
438438 cluster : & clusterv1.Cluster {ObjectMeta : metav1.ObjectMeta {Name : "test-cluster" , Namespace : "test-namespace" }},
439439 },
440440 {
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 {},
444451 },
445452 {
446453 name : "expect failure domain to remain same if infra config have same failure domain" ,
447- cluster : cluster ,
454+ cluster : cluster . DeepCopy () ,
448455 infraRef : generateInfraRef (true ),
449456 expectFailureDomains : newFailureDomain ,
450457 },
451458 {
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 () ,
454461 infraRef : generateInfraRef (true ),
455462 expectFailureDomains : newFailureDomain ,
456463 },
457464 {
458465 name : "expect failure domain to be reset if infra config have different failure domain" ,
459- cluster : clusterWithOldFailureDomain ,
466+ cluster : clusterWithOldFailureDomain . DeepCopy () ,
460467 infraRef : generateInfraRef (true ),
461468 expectFailureDomains : newFailureDomain ,
462469 },
@@ -466,7 +473,7 @@ func TestClusterReconcilePhases_reconcileFailureDomains(t *testing.T) {
466473 t .Run (tt .name , func (t * testing.T ) {
467474 g := NewWithT (t )
468475
469- objs := []client.Object {builder .GenericInfrastructureMachineCRD .DeepCopy (), tt .cluster }
476+ objs := []client.Object {builder .GenericInfrastructureClusterCRD .DeepCopy (), tt .cluster }
470477 if tt .infraRef != nil {
471478 objs = append (objs , & unstructured.Unstructured {Object : tt .infraRef })
472479 }
@@ -477,20 +484,23 @@ func TestClusterReconcilePhases_reconcileFailureDomains(t *testing.T) {
477484
478485 _ , err := r .reconcileInfrastructure (ctx , tt .cluster )
479486 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 ))
481488 })
482489 }
483490}
484491
485492func generateInfraRef (withFailureDomain bool ) map [string ]interface {} {
486493 infraRef := map [string ]interface {}{
487- "kind" : "GenericInfrastructureMachine " ,
494+ "kind" : "GenericInfrastructureCluster " ,
488495 "apiVersion" : "infrastructure.cluster.x-k8s.io/v1beta1" ,
489496 "metadata" : map [string ]interface {}{
490497 "name" : "test" ,
491498 "namespace" : "test-namespace" ,
492499 "deletionTimestamp" : "sometime" ,
493500 },
501+ "status" : map [string ]interface {}{
502+ "ready" : true ,
503+ },
494504 }
495505
496506 if withFailureDomain {
0 commit comments