@@ -35,10 +35,12 @@ import (
35
35
"k8s.io/utils/pointer"
36
36
"sigs.k8s.io/controller-runtime/pkg/client/fake"
37
37
38
+ clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
39
+ "sigs.k8s.io/cluster-api/util/conditions"
40
+
38
41
infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
39
42
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/scope"
40
43
"sigs.k8s.io/cluster-api-provider-aws/v2/test/mocks"
41
- clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
42
44
)
43
45
44
46
func TestELBName (t * testing.T ) {
@@ -600,8 +602,9 @@ func TestDeleteAPIServerELB(t *testing.T) {
600
602
clusterName := "bar" //nolint:goconst // does not need to be a package-level const
601
603
elbName := "bar-apiserver"
602
604
tests := []struct {
603
- name string
604
- elbAPIMocks func (m * mocks.MockELBAPIMockRecorder )
605
+ name string
606
+ elbAPIMocks func (m * mocks.MockELBAPIMockRecorder )
607
+ verifyAWSCluster func (* infrav1.AWSCluster )
605
608
}{
606
609
{
607
610
name : "if control plane ELB is not found, do nothing" ,
@@ -610,6 +613,16 @@ func TestDeleteAPIServerELB(t *testing.T) {
610
613
LoadBalancerNames : aws .StringSlice ([]string {elbName }),
611
614
})).Return (nil , awserr .New (elb .ErrCodeAccessPointNotFoundException , "" , nil ))
612
615
},
616
+ verifyAWSCluster : func (awsCluster * infrav1.AWSCluster ) {
617
+ loadBalancerConditionReady := conditions .IsTrue (awsCluster , infrav1 .LoadBalancerReadyCondition )
618
+ if loadBalancerConditionReady {
619
+ t .Fatalf ("Expected LoadBalancerReady condition to be False, but was True" )
620
+ }
621
+ loadBalancerConditionReason := conditions .GetReason (awsCluster , infrav1 .LoadBalancerReadyCondition )
622
+ if loadBalancerConditionReason != clusterv1 .DeletedReason {
623
+ t .Fatalf ("Expected LoadBalancerReady condition reason to be Deleted, but was %s" , loadBalancerConditionReason )
624
+ }
625
+ },
613
626
},
614
627
{
615
628
name : "if control plane ELB is found, and it is not managed, do nothing" ,
@@ -649,6 +662,16 @@ func TestDeleteAPIServerELB(t *testing.T) {
649
662
nil ,
650
663
)
651
664
},
665
+ verifyAWSCluster : func (awsCluster * infrav1.AWSCluster ) {
666
+ loadBalancerConditionReady := conditions .IsTrue (awsCluster , infrav1 .LoadBalancerReadyCondition )
667
+ if loadBalancerConditionReady {
668
+ t .Fatalf ("Expected LoadBalancerReady condition to be False, but was True" )
669
+ }
670
+ loadBalancerConditionReason := conditions .GetReason (awsCluster , infrav1 .LoadBalancerReadyCondition )
671
+ if loadBalancerConditionReason != clusterv1 .DeletedReason {
672
+ t .Fatalf ("Expected LoadBalancerReady condition reason to be Deleted, but was %s" , loadBalancerConditionReason )
673
+ }
674
+ },
652
675
},
653
676
{
654
677
name : "if control plane ELB is found, and it is managed, delete the ELB" ,
@@ -701,6 +724,16 @@ func TestDeleteAPIServerELB(t *testing.T) {
701
724
nil ,
702
725
)
703
726
},
727
+ verifyAWSCluster : func (awsCluster * infrav1.AWSCluster ) {
728
+ loadBalancerConditionReady := conditions .IsTrue (awsCluster , infrav1 .LoadBalancerReadyCondition )
729
+ if loadBalancerConditionReady {
730
+ t .Fatalf ("Expected LoadBalancerReady condition to be False, but was True" )
731
+ }
732
+ loadBalancerConditionReason := conditions .GetReason (awsCluster , infrav1 .LoadBalancerReadyCondition )
733
+ if loadBalancerConditionReason != clusterv1 .DeletedReason {
734
+ t .Fatalf ("Expected LoadBalancerReady condition reason to be Deleted, but was %s" , loadBalancerConditionReason )
735
+ }
736
+ },
704
737
},
705
738
}
706
739
@@ -755,6 +788,8 @@ func TestDeleteAPIServerELB(t *testing.T) {
755
788
if err != nil {
756
789
t .Fatal (err )
757
790
}
791
+
792
+ tc .verifyAWSCluster (awsCluster )
758
793
})
759
794
}
760
795
}
0 commit comments