Skip to content

Commit c9069ba

Browse files
test that backend http annotation are set (#234)
1 parent f518c9a commit c9069ba

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

pkg/appgw/appgw_test.go

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -671,12 +671,16 @@ var _ = Describe("Tests `appgw.ConfigBuilder`", func() {
671671
})
672672

673673
Context("Tests Ingress Controller Annotations", func() {
674-
It("Should be able to create Application Gateway Configuration from Ingress with backend prefix.", func() {
674+
It("Should be able to create Application Gateway Configuration from Ingress with all annotations.", func() {
675675
ingress, err := k8sClient.Extensions().Ingresses(ingressNS).Get(ingressName, metav1.GetOptions{})
676676
Expect(err).Should(BeNil(), "Unable to create ingress resource due to: %v", err)
677677

678-
// Set the ingress annotation for this ingress.
678+
// Set the ingress annotations for this ingress.
679679
ingress.Annotations[annotations.BackendPathPrefixKey] = "/test"
680+
ingress.Annotations[annotations.ConnectionDrainingKey] = "true"
681+
ingress.Annotations[annotations.ConnectionDrainingTimeoutKey] = "10"
682+
ingress.Annotations[annotations.CookieBasedAffinityKey] = "true"
683+
ingress.Annotations[annotations.RequestTimeoutKey] = "10"
680684

681685
// Update the ingress.
682686
_, err = k8sClient.Extensions().Ingresses(ingressNS).Update(ingress)
@@ -689,7 +693,7 @@ var _ = Describe("Tests `appgw.ConfigBuilder`", func() {
689693
ingressEvent()
690694

691695
// Method to test all the ingress that have been added to the K8s context.
692-
backendPrefixIngress := func() []*v1beta1.Ingress {
696+
annotationIngress := func() []*v1beta1.Ingress {
693697
// Get all the ingresses
694698
ingressList := ctxt.GetHTTPIngressList()
695699
// There should be only one ingress
@@ -701,9 +705,9 @@ var _ = Describe("Tests `appgw.ConfigBuilder`", func() {
701705
}
702706

703707
// Get all the ingresses
704-
ingressList := backendPrefixIngress()
708+
ingressList := annotationIngress()
705709

706-
backendPrefixHTTPSettingsChecker := func(appGW *network.ApplicationGatewayPropertiesFormat) {
710+
annotationsHTTPSettingsChecker := func(appGW *network.ApplicationGatewayPropertiesFormat) {
707711
appGwIdentifier := Identifier{}
708712
expectedBackend := &ingress.Spec.Rules[0].IngressRuleValue.HTTP.Paths[0].Backend
709713
probeID := appGwIdentifier.probeID(generateProbeName(expectedBackend.ServiceName, expectedBackend.ServicePort.String(), ingress.Name))
@@ -712,11 +716,17 @@ var _ = Describe("Tests `appgw.ConfigBuilder`", func() {
712716
Etag: to.StringPtr("*"),
713717
Name: &httpSettingsName,
714718
ApplicationGatewayBackendHTTPSettingsPropertiesFormat: &network.ApplicationGatewayBackendHTTPSettingsPropertiesFormat{
715-
Protocol: network.HTTP,
716-
Port: &backendPort,
717-
Path: to.StringPtr("/test"),
718-
Probe: resourceRef(probeID),
719-
HostName: nil,
719+
Protocol: network.HTTP,
720+
Port: &backendPort,
721+
Path: to.StringPtr("/test"),
722+
Probe: resourceRef(probeID),
723+
HostName: nil,
724+
CookieBasedAffinity: network.Enabled,
725+
ConnectionDraining: &network.ApplicationGatewayConnectionDraining{
726+
Enabled: to.BoolPtr(true),
727+
DrainTimeoutInSec: to.Int32Ptr(10),
728+
},
729+
RequestTimeout: to.Int32Ptr(10),
720730
},
721731
}
722732

@@ -738,7 +748,7 @@ var _ = Describe("Tests `appgw.ConfigBuilder`", func() {
738748
},
739749
backendHTTPSettingsCollection: appGWSettingsChecker{
740750
total: 2,
741-
checker: backendPrefixHTTPSettingsChecker,
751+
checker: annotationsHTTPSettingsChecker,
742752
},
743753
backendAddressPools: appGWSettingsChecker{
744754
total: 2,

0 commit comments

Comments
 (0)