@@ -363,7 +363,7 @@ func TestEnsureLoadBalancerDeleted(t *testing.T) {
363
363
}{
364
364
{
365
365
desc : "external service should be created and deleted successfully" ,
366
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
366
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
367
367
},
368
368
{
369
369
desc : "internal service should be created and deleted successfully" ,
@@ -612,7 +612,7 @@ func TestGetServiceLoadBalancer(t *testing.T) {
612
612
},
613
613
},
614
614
},
615
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
615
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
616
616
wantLB : false ,
617
617
expectedLB : & network.LoadBalancer {
618
618
Name : to .StringPtr ("lb1" ),
@@ -633,7 +633,7 @@ func TestGetServiceLoadBalancer(t *testing.T) {
633
633
},
634
634
{
635
635
desc : "getServiceLoadBalancer shall report error if there're loadbalancer mode annotations on a standard lb" ,
636
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
636
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
637
637
annotations : map [string ]string {ServiceAnnotationLoadBalancerMode : "__auto__" },
638
638
sku : "standard" ,
639
639
expectedExists : false ,
@@ -671,7 +671,7 @@ func TestGetServiceLoadBalancer(t *testing.T) {
671
671
},
672
672
},
673
673
},
674
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
674
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
675
675
annotations : map [string ]string {ServiceAnnotationLoadBalancerMode : "__auto__" },
676
676
wantLB : true ,
677
677
expectedLB : & network.LoadBalancer {
@@ -687,7 +687,7 @@ func TestGetServiceLoadBalancer(t *testing.T) {
687
687
},
688
688
{
689
689
desc : "getServiceLoadBalancer shall create a new lb otherwise" ,
690
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
690
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
691
691
expectedLB : & network.LoadBalancer {
692
692
Name : to .StringPtr ("testCluster" ),
693
693
Location : to .StringPtr ("westus" ),
@@ -839,7 +839,7 @@ func TestIsFrontendIPChanged(t *testing.T) {
839
839
},
840
840
},
841
841
lbFrontendIPConfigName : "btest1-name" ,
842
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
842
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
843
843
expectedFlag : false ,
844
844
expectedError : false ,
845
845
},
@@ -852,7 +852,7 @@ func TestIsFrontendIPChanged(t *testing.T) {
852
852
},
853
853
},
854
854
lbFrontendIPConfigName : "btest1-name" ,
855
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
855
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
856
856
loadBalancerIP : "1.1.1.1" ,
857
857
exsistingPIPs : []network.PublicIPAddress {
858
858
{
@@ -875,7 +875,7 @@ func TestIsFrontendIPChanged(t *testing.T) {
875
875
},
876
876
},
877
877
lbFrontendIPConfigName : "btest1-name" ,
878
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
878
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
879
879
loadBalancerIP : "1.1.1.1" ,
880
880
exsistingPIPs : []network.PublicIPAddress {
881
881
{
@@ -898,7 +898,7 @@ func TestIsFrontendIPChanged(t *testing.T) {
898
898
},
899
899
},
900
900
lbFrontendIPConfigName : "btest1-name" ,
901
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
901
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
902
902
loadBalancerIP : "1.1.1.1" ,
903
903
exsistingPIPs : []network.PublicIPAddress {
904
904
{
@@ -978,7 +978,7 @@ func TestDeterminePublicIPName(t *testing.T) {
978
978
}
979
979
for i , test := range testCases {
980
980
az := GetTestCloud (ctrl )
981
- service := getTestService ("test1" , v1 .ProtocolTCP , nil , 80 )
981
+ service := getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 )
982
982
service .Spec .LoadBalancerIP = test .loadBalancerIP
983
983
for _ , existingPIP := range test .exsistingPIPs {
984
984
err := az .PublicIPAddressesClient .CreateOrUpdate (context .TODO (), "rg" , "test" , existingPIP )
@@ -1007,12 +1007,12 @@ func TestReconcileLoadBalancerRule(t *testing.T) {
1007
1007
}{
1008
1008
{
1009
1009
desc : "reconcileLoadBalancerRule shall return nil if wantLb is false" ,
1010
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
1010
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
1011
1011
wantLb : false ,
1012
1012
},
1013
1013
{
1014
1014
desc : "reconcileLoadBalancerRule shall return corresponding probe and lbRule(blb)" ,
1015
- service : getTestService ("test1" , v1 .ProtocolTCP , map [string ]string {"service.beta.kubernetes.io/azure-load-balancer-disable-tcp-reset" : "true" }, 80 ),
1015
+ service : getTestService ("test1" , v1 .ProtocolTCP , map [string ]string {"service.beta.kubernetes.io/azure-load-balancer-disable-tcp-reset" : "true" }, false , 80 ),
1016
1016
wantLb : true ,
1017
1017
expectedProbes : []network.Probe {
1018
1018
{
@@ -1053,7 +1053,7 @@ func TestReconcileLoadBalancerRule(t *testing.T) {
1053
1053
},
1054
1054
{
1055
1055
desc : "reconcileLoadBalancerRule shall return corresponding probe and lbRule (slb without tcp reset)" ,
1056
- service : getTestService ("test1" , v1 .ProtocolTCP , map [string ]string {"service.beta.kubernetes.io/azure-load-balancer-disable-tcp-reset" : "True" }, 80 ),
1056
+ service : getTestService ("test1" , v1 .ProtocolTCP , map [string ]string {"service.beta.kubernetes.io/azure-load-balancer-disable-tcp-reset" : "True" }, false , 80 ),
1057
1057
loadBalancerSku : "standard" ,
1058
1058
wantLb : true ,
1059
1059
expectedProbes : []network.Probe {
@@ -1095,7 +1095,7 @@ func TestReconcileLoadBalancerRule(t *testing.T) {
1095
1095
},
1096
1096
{
1097
1097
desc : "reconcileLoadBalancerRule shall return corresponding probe and lbRule(slb with tcp reset)" ,
1098
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
1098
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
1099
1099
loadBalancerSku : "standard" ,
1100
1100
wantLb : true ,
1101
1101
expectedProbes : []network.Probe {
@@ -1214,10 +1214,10 @@ func TestReconcileLoadBalancer(t *testing.T) {
1214
1214
ctrl := gomock .NewController (t )
1215
1215
defer ctrl .Finish ()
1216
1216
1217
- service1 := getTestService ("test1" , v1 .ProtocolTCP , nil , 80 )
1217
+ service1 := getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 )
1218
1218
basicLb1 := getTestLoadBalancer (to .StringPtr ("lb1" ), to .StringPtr ("rg" ), to .StringPtr ("testCluster" ), to .StringPtr ("atest1" ), service1 , "Basic" )
1219
1219
1220
- service2 := getTestService ("test1" , v1 .ProtocolTCP , nil , 80 )
1220
+ service2 := getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 )
1221
1221
basicLb2 := getTestLoadBalancer (to .StringPtr ("lb1" ), to .StringPtr ("rg" ), to .StringPtr ("testCluster" ), to .StringPtr ("btest1" ), service2 , "Basic" )
1222
1222
basicLb2 .Name = to .StringPtr ("testCluster" )
1223
1223
basicLb2 .FrontendIPConfigurations = & []network.FrontendIPConfiguration {
@@ -1229,7 +1229,7 @@ func TestReconcileLoadBalancer(t *testing.T) {
1229
1229
},
1230
1230
}
1231
1231
1232
- service3 := getTestService ("test1" , v1 .ProtocolTCP , nil , 80 )
1232
+ service3 := getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 )
1233
1233
modifiedLb1 := getTestLoadBalancer (to .StringPtr ("testCluster" ), to .StringPtr ("rg" ), to .StringPtr ("testCluster" ), to .StringPtr ("atest1" ), service3 , "Basic" )
1234
1234
modifiedLb1 .FrontendIPConfigurations = & []network.FrontendIPConfiguration {
1235
1235
{
@@ -1280,7 +1280,7 @@ func TestReconcileLoadBalancer(t *testing.T) {
1280
1280
},
1281
1281
}
1282
1282
1283
- service4 := getTestService ("test1" , v1 .ProtocolTCP , map [string ]string {"service.beta.kubernetes.io/azure-load-balancer-disable-tcp-reset" : "true" }, 80 )
1283
+ service4 := getTestService ("test1" , v1 .ProtocolTCP , map [string ]string {"service.beta.kubernetes.io/azure-load-balancer-disable-tcp-reset" : "true" }, false , 80 )
1284
1284
existingSLB := getTestLoadBalancer (to .StringPtr ("testCluster" ), to .StringPtr ("rg" ), to .StringPtr ("testCluster" ), to .StringPtr ("atest1" ), service4 , "Standard" )
1285
1285
existingSLB .FrontendIPConfigurations = & []network.FrontendIPConfiguration {
1286
1286
{
@@ -1332,7 +1332,7 @@ func TestReconcileLoadBalancer(t *testing.T) {
1332
1332
},
1333
1333
}
1334
1334
1335
- service5 := getTestService ("test1" , v1 .ProtocolTCP , nil , 80 )
1335
+ service5 := getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 )
1336
1336
slb5 := getTestLoadBalancer (to .StringPtr ("testCluster" ), to .StringPtr ("rg" ), to .StringPtr ("testCluster" ), to .StringPtr ("atest1" ), service5 , "Standard" )
1337
1337
slb5 .FrontendIPConfigurations = & []network.FrontendIPConfiguration {
1338
1338
{
@@ -1386,7 +1386,7 @@ func TestReconcileLoadBalancer(t *testing.T) {
1386
1386
},
1387
1387
}
1388
1388
1389
- service6 := getTestService ("test1" , v1 .ProtocolUDP , nil , 80 )
1389
+ service6 := getTestService ("test1" , v1 .ProtocolUDP , nil , false , 80 )
1390
1390
lb6 := getTestLoadBalancer (to .StringPtr ("testCluster" ), to .StringPtr ("rg" ), to .StringPtr ("testCluster" ), to .StringPtr ("atest1" ), service6 , "basic" )
1391
1391
lb6 .FrontendIPConfigurations = & []network.FrontendIPConfiguration {}
1392
1392
lb6 .Probes = & []network.Probe {}
@@ -1405,7 +1405,7 @@ func TestReconcileLoadBalancer(t *testing.T) {
1405
1405
},
1406
1406
}
1407
1407
1408
- service7 := getTestService ("test1" , v1 .ProtocolUDP , nil , 80 )
1408
+ service7 := getTestService ("test1" , v1 .ProtocolUDP , nil , false , 80 )
1409
1409
service7 .Spec .HealthCheckNodePort = 10081
1410
1410
service7 .Spec .ExternalTrafficPolicy = v1 .ServiceExternalTrafficPolicyTypeLocal
1411
1411
lb7 := getTestLoadBalancer (to .StringPtr ("testCluster" ), to .StringPtr ("rg" ), to .StringPtr ("testCluster" ), to .StringPtr ("atest1" ), service7 , "basic" )
@@ -1440,7 +1440,7 @@ func TestReconcileLoadBalancer(t *testing.T) {
1440
1440
},
1441
1441
}
1442
1442
1443
- service8 := getTestService ("test1" , v1 .ProtocolTCP , nil , 80 )
1443
+ service8 := getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 )
1444
1444
lb8 := getTestLoadBalancer (to .StringPtr ("testCluster" ), to .StringPtr ("anotherRG" ), to .StringPtr ("testCluster" ), to .StringPtr ("atest1" ), service8 , "Standard" )
1445
1445
lb8 .FrontendIPConfigurations = & []network.FrontendIPConfiguration {}
1446
1446
lb8 .Probes = & []network.Probe {}
@@ -1610,7 +1610,7 @@ func TestGetServiceLoadBalancerStatus(t *testing.T) {
1610
1610
defer ctrl .Finish ()
1611
1611
1612
1612
az := GetTestCloud (ctrl )
1613
- service := getTestService ("test1" , v1 .ProtocolTCP , nil , 80 )
1613
+ service := getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 )
1614
1614
internalService := getInternalTestService ("test1" , 80 )
1615
1615
1616
1616
PIPClient := newFakeAzurePIPClient (az .Config .SubscriptionID )
@@ -1772,25 +1772,25 @@ func TestReconcileSecurityGroup(t *testing.T) {
1772
1772
},
1773
1773
{
1774
1774
desc : "reconcileSecurityGroup shall report error if no such sg can be found" ,
1775
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
1775
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
1776
1776
expectedError : true ,
1777
1777
},
1778
1778
{
1779
1779
desc : "reconcileSecurityGroup shall report error if wantLb is true and lbIP is nil" ,
1780
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
1780
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
1781
1781
wantLb : true ,
1782
1782
existingSgs : map [string ]network.SecurityGroup {"nsg" : {}},
1783
1783
expectedError : true ,
1784
1784
},
1785
1785
{
1786
1786
desc : "reconcileSecurityGroup shall remain the existingSgs intact if nothing needs to be modified" ,
1787
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
1787
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
1788
1788
existingSgs : map [string ]network.SecurityGroup {"nsg" : {}},
1789
1789
expectedSg : & network.SecurityGroup {},
1790
1790
},
1791
1791
{
1792
1792
desc : "reconcileSecurityGroup shall delete unwanted sgs and create needed ones" ,
1793
- service : getTestService ("test1" , v1 .ProtocolTCP , nil , 80 ),
1793
+ service : getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 ),
1794
1794
existingSgs : map [string ]network.SecurityGroup {"nsg" : {
1795
1795
Name : to .StringPtr ("nsg" ),
1796
1796
SecurityGroupPropertiesFormat : & network.SecurityGroupPropertiesFormat {
@@ -1896,7 +1896,7 @@ func TestSafeDeletePublicIP(t *testing.T) {
1896
1896
if err != nil {
1897
1897
t .Fatalf ("TestCase[%d] meets unexpected error: %v" , i , err )
1898
1898
}
1899
- service := getTestService ("test1" , v1 .ProtocolTCP , nil , 80 )
1899
+ service := getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 )
1900
1900
rerr := az .safeDeletePublicIP (& service , "rg" , test .pip , test .lb )
1901
1901
assert .Equal (t , 0 , len (* test .lb .FrontendIPConfigurations ), "TestCase[%d]: %s" , i , test .desc )
1902
1902
assert .Equal (t , 0 , len (* test .lb .LoadBalancingRules ), "TestCase[%d]: %s" , i , test .desc )
@@ -2007,7 +2007,7 @@ func TestReconcilePublicIP(t *testing.T) {
2007
2007
2008
2008
for i , test := range testCases {
2009
2009
az := GetTestCloud (ctrl )
2010
- service := getTestService ("test1" , v1 .ProtocolTCP , nil , 80 )
2010
+ service := getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 )
2011
2011
service .Annotations = test .annotations
2012
2012
for _ , pip := range test .existingPIPs {
2013
2013
err := az .PublicIPAddressesClient .CreateOrUpdate (context .TODO (), "rg" , to .String (pip .Name ), pip )
@@ -2036,6 +2036,7 @@ func TestEnsurePublicIPExists(t *testing.T) {
2036
2036
foundDNSLabelAnnotation bool
2037
2037
expectedPIP * network.PublicIPAddress
2038
2038
expectedID string
2039
+ isIPv6 bool
2039
2040
expectedError bool
2040
2041
}{
2041
2042
{
@@ -2072,6 +2073,7 @@ func TestEnsurePublicIPExists(t *testing.T) {
2072
2073
DNSSettings : & network.PublicIPAddressDNSSettings {
2073
2074
DomainNameLabel : to .StringPtr ("newdns" ),
2074
2075
},
2076
+ PublicIPAddressVersion : "IPv4" ,
2075
2077
},
2076
2078
},
2077
2079
},
@@ -2091,7 +2093,8 @@ func TestEnsurePublicIPExists(t *testing.T) {
2091
2093
ID : to .StringPtr ("/subscriptions/subscription/resourceGroups/rg" +
2092
2094
"/providers/Microsoft.Network/publicIPAddresses/pip1" ),
2093
2095
PublicIPAddressPropertiesFormat : & network.PublicIPAddressPropertiesFormat {
2094
- DNSSettings : nil ,
2096
+ DNSSettings : nil ,
2097
+ PublicIPAddressVersion : "IPv4" ,
2095
2098
},
2096
2099
},
2097
2100
},
@@ -2114,14 +2117,41 @@ func TestEnsurePublicIPExists(t *testing.T) {
2114
2117
DNSSettings : & network.PublicIPAddressDNSSettings {
2115
2118
DomainNameLabel : to .StringPtr ("previousdns" ),
2116
2119
},
2120
+ PublicIPAddressVersion : "IPv4" ,
2121
+ },
2122
+ },
2123
+ },
2124
+ {
2125
+ desc : "ensurePublicIPExists shall update existed PIP's dns label for IPv6" ,
2126
+ inputDNSLabel : "newdns" ,
2127
+ foundDNSLabelAnnotation : true ,
2128
+ isIPv6 : true ,
2129
+ existingPIPs : []network.PublicIPAddress {{
2130
+ Name : to .StringPtr ("pip1" ),
2131
+ PublicIPAddressPropertiesFormat : & network.PublicIPAddressPropertiesFormat {
2132
+ DNSSettings : & network.PublicIPAddressDNSSettings {
2133
+ DomainNameLabel : to .StringPtr ("previousdns" ),
2134
+ },
2135
+ },
2136
+ }},
2137
+ expectedPIP : & network.PublicIPAddress {
2138
+ Name : to .StringPtr ("pip1" ),
2139
+ ID : to .StringPtr ("/subscriptions/subscription/resourceGroups/rg" +
2140
+ "/providers/Microsoft.Network/publicIPAddresses/pip1" ),
2141
+ PublicIPAddressPropertiesFormat : & network.PublicIPAddressPropertiesFormat {
2142
+ DNSSettings : & network.PublicIPAddressDNSSettings {
2143
+ DomainNameLabel : to .StringPtr ("newdns" ),
2144
+ },
2145
+ PublicIPAllocationMethod : "Dynamic" ,
2146
+ PublicIPAddressVersion : "IPv6" ,
2117
2147
},
2118
2148
},
2119
2149
},
2120
2150
}
2121
2151
2122
2152
for i , test := range testCases {
2123
2153
az := GetTestCloud (ctrl )
2124
- service := getTestService ("test1" , v1 .ProtocolTCP , nil , 80 )
2154
+ service := getTestService ("test1" , v1 .ProtocolTCP , nil , test . isIPv6 , 80 )
2125
2155
for _ , pip := range test .existingPIPs {
2126
2156
err := az .PublicIPAddressesClient .CreateOrUpdate (context .TODO (), "rg" , to .String (pip .Name ), pip )
2127
2157
if err != nil {
@@ -2176,7 +2206,7 @@ func TestShouldUpdateLoadBalancer(t *testing.T) {
2176
2206
2177
2207
for i , test := range testCases {
2178
2208
az := GetTestCloud (ctrl )
2179
- service := getTestService ("test1" , v1 .ProtocolTCP , nil , 80 )
2209
+ service := getTestService ("test1" , v1 .ProtocolTCP , nil , false , 80 )
2180
2210
if test .lbHasDeletionTimestamp {
2181
2211
service .ObjectMeta .DeletionTimestamp = & metav1.Time {Time : time .Now ()}
2182
2212
}
@@ -2271,7 +2301,7 @@ func TestIsBackendPoolPreConfigured(t *testing.T) {
2271
2301
if test .isInternalService {
2272
2302
service = getInternalTestService ("test" , 80 )
2273
2303
} else {
2274
- service = getTestService ("test" , v1 .ProtocolTCP , nil , 80 )
2304
+ service = getTestService ("test" , v1 .ProtocolTCP , nil , false , 80 )
2275
2305
}
2276
2306
2277
2307
isPreConfigured := az .isBackendPoolPreConfigured (& service )
0 commit comments