@@ -40,6 +40,7 @@ import (
40
40
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/scope"
41
41
"sigs.k8s.io/cluster-api-provider-aws/v2/test/mocks"
42
42
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
43
+ "sigs.k8s.io/cluster-api/util/conditions"
43
44
)
44
45
45
46
func TestELBName (t * testing.T ) {
@@ -1587,8 +1588,9 @@ func TestDeleteAPIServerELB(t *testing.T) {
1587
1588
clusterName := "bar" //nolint:goconst // does not need to be a package-level const
1588
1589
elbName := "bar-apiserver"
1589
1590
tests := []struct {
1590
- name string
1591
- elbAPIMocks func (m * mocks.MockELBAPIMockRecorder )
1591
+ name string
1592
+ elbAPIMocks func (m * mocks.MockELBAPIMockRecorder )
1593
+ verifyAWSCluster func (* infrav1.AWSCluster )
1592
1594
}{
1593
1595
{
1594
1596
name : "if control plane ELB is not found, do nothing" ,
@@ -1597,6 +1599,16 @@ func TestDeleteAPIServerELB(t *testing.T) {
1597
1599
LoadBalancerNames : aws .StringSlice ([]string {elbName }),
1598
1600
})).Return (nil , awserr .New (elb .ErrCodeAccessPointNotFoundException , "" , nil ))
1599
1601
},
1602
+ verifyAWSCluster : func (awsCluster * infrav1.AWSCluster ) {
1603
+ loadBalancerConditionReady := conditions .IsTrue (awsCluster , infrav1 .LoadBalancerReadyCondition )
1604
+ if loadBalancerConditionReady {
1605
+ t .Fatalf ("Expected LoadBalancerReady condition to be False, but was True" )
1606
+ }
1607
+ loadBalancerConditionReason := conditions .GetReason (awsCluster , infrav1 .LoadBalancerReadyCondition )
1608
+ if loadBalancerConditionReason != clusterv1 .DeletedReason {
1609
+ t .Fatalf ("Expected LoadBalancerReady condition reason to be Deleted, but was %s" , loadBalancerConditionReason )
1610
+ }
1611
+ },
1600
1612
},
1601
1613
{
1602
1614
name : "if control plane ELB is found, and it is not managed, do nothing" ,
@@ -1636,6 +1648,16 @@ func TestDeleteAPIServerELB(t *testing.T) {
1636
1648
nil ,
1637
1649
)
1638
1650
},
1651
+ verifyAWSCluster : func (awsCluster * infrav1.AWSCluster ) {
1652
+ loadBalancerConditionReady := conditions .IsTrue (awsCluster , infrav1 .LoadBalancerReadyCondition )
1653
+ if loadBalancerConditionReady {
1654
+ t .Fatalf ("Expected LoadBalancerReady condition to be False, but was True" )
1655
+ }
1656
+ loadBalancerConditionReason := conditions .GetReason (awsCluster , infrav1 .LoadBalancerReadyCondition )
1657
+ if loadBalancerConditionReason != clusterv1 .DeletedReason {
1658
+ t .Fatalf ("Expected LoadBalancerReady condition reason to be Deleted, but was %s" , loadBalancerConditionReason )
1659
+ }
1660
+ },
1639
1661
},
1640
1662
{
1641
1663
name : "if control plane ELB is found, and it is managed, delete the ELB" ,
@@ -1688,6 +1710,16 @@ func TestDeleteAPIServerELB(t *testing.T) {
1688
1710
nil ,
1689
1711
)
1690
1712
},
1713
+ verifyAWSCluster : func (awsCluster * infrav1.AWSCluster ) {
1714
+ loadBalancerConditionReady := conditions .IsTrue (awsCluster , infrav1 .LoadBalancerReadyCondition )
1715
+ if loadBalancerConditionReady {
1716
+ t .Fatalf ("Expected LoadBalancerReady condition to be False, but was True" )
1717
+ }
1718
+ loadBalancerConditionReason := conditions .GetReason (awsCluster , infrav1 .LoadBalancerReadyCondition )
1719
+ if loadBalancerConditionReason != clusterv1 .DeletedReason {
1720
+ t .Fatalf ("Expected LoadBalancerReady condition reason to be Deleted, but was %s" , loadBalancerConditionReason )
1721
+ }
1722
+ },
1691
1723
},
1692
1724
}
1693
1725
@@ -1742,6 +1774,8 @@ func TestDeleteAPIServerELB(t *testing.T) {
1742
1774
if err != nil {
1743
1775
t .Fatal (err )
1744
1776
}
1777
+
1778
+ tc .verifyAWSCluster (awsCluster )
1745
1779
})
1746
1780
}
1747
1781
}
0 commit comments