Skip to content

Commit

Permalink
add e2e case for updating service.beta.kubernetes.io/azure-dns-label-…
Browse files Browse the repository at this point in the history
…name
  • Loading branch information
MartinForReal committed Nov 4, 2022
1 parent 4354fec commit cd72ea6
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
37 changes: 36 additions & 1 deletion pkg/provider/azure_loadbalancer_test.go
Expand Up @@ -4198,7 +4198,6 @@ func TestEnsurePublicIPExists(t *testing.T) {
foundDNSLabelAnnotation: true,
isIPv6: true,
existingPIPs: []network.PublicIPAddress{{

Name: to.StringPtr("pip1"),
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{
DNSSettings: &network.PublicIPAddressDNSSettings{
Expand All @@ -4217,6 +4216,42 @@ func TestEnsurePublicIPExists(t *testing.T) {
PublicIPAllocationMethod: "Dynamic",
PublicIPAddressVersion: "IPv6",
},
Tags: map[string]*string{
"k8s-azure-dns-label-service": to.StringPtr("default/test1"),
},
},
shouldPutPIP: true,
},
{
desc: "shall update existed PIP's dns label for IPv4",
inputDNSLabel: "newdns",
foundDNSLabelAnnotation: true,
isIPv6: false,
existingPIPs: []network.PublicIPAddress{{

Name: to.StringPtr("pip1"),
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{
DNSSettings: &network.PublicIPAddressDNSSettings{
DomainNameLabel: to.StringPtr("previousdns"),
},
PublicIPAllocationMethod: "Dynamic",
PublicIPAddressVersion: "IPv4",
},
}},
expectedPIP: &network.PublicIPAddress{
Name: to.StringPtr("pip1"),
ID: to.StringPtr("/subscriptions/subscription/resourceGroups/rg" +
"/providers/Microsoft.Network/publicIPAddresses/pip1"),
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{
DNSSettings: &network.PublicIPAddressDNSSettings{
DomainNameLabel: to.StringPtr("newdns"),
},
PublicIPAllocationMethod: "Dynamic",
PublicIPAddressVersion: "IPv4",
},
Tags: map[string]*string{
"k8s-azure-dns-label-service": to.StringPtr("default/test1"),
},
},
shouldPutPIP: true,
},
Expand Down
31 changes: 31 additions & 0 deletions tests/e2e/network/service_annotations.go
Expand Up @@ -158,6 +158,37 @@ var _ = Describe("Service with annotation", Label(utils.TestSuiteLabelServiceAnn
time.Sleep(20 * time.Second)
}
Expect(code).To(Equal(nginxStatusCode), "Fail to get response from the domain name")
By("Update service")
annotation = map[string]string{
consts.ServiceAnnotationDNSLabelName: serviceDomainNamePrefix + "new",
}
service := utils.CreateLoadBalancerServiceManifest(serviceName, annotation, labels, ns.Name, ports)
_, err := cs.CoreV1().Services(ns.Name).Update(context.TODO(), service, metav1.UpdateOptions{})
Expect(err).NotTo(HaveOccurred())
serviceDomainName = utils.GetServiceDomainName(serviceDomainNamePrefix)
url = fmt.Sprintf("http://%s:%v", serviceDomainName, ports[0].Port)
for i := 1; i <= 30; i++ {
/* #nosec G107: Potential HTTP request made with variable url */
resp, err := http.Get(url)
if err == nil {
defer func() {
if resp != nil {
resp.Body.Close()
}
}()
code = resp.StatusCode
if code == nginxStatusCode {
break
} else {
utils.Logf("Received %d status code from %s", code, url)
}
} else {
utils.Logf("Received the following error when validating %s: %v", url, err)
}
utils.Logf("Retrying in 20 seconds")
time.Sleep(20 * time.Second)
}
Expect(code).To(Equal(nginxStatusCode), "Fail to get response from the domain name")
})

It("should support service annotation 'service.beta.kubernetes.io/azure-load-balancer-internal'", func() {
Expand Down

0 comments on commit cd72ea6

Please sign in to comment.