Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-1.1] chore: add mixed protocol service e2e test #1437

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions tests/e2e/network/ensureloadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,47 @@ var _ = Describe("Ensure LoadBalancer", func() {
tc = nil
})

It("should support mixed protocol services", func() {
By("creating a mixed protocol service")
mixedProtocolPorts := []v1.ServicePort{
{
Name: "tcp",
Port: nginxPort,
TargetPort: intstr.FromInt(nginxPort),
Protocol: v1.ProtocolTCP,
},
{
Name: "udp",
Port: testingPort,
TargetPort: intstr.FromInt(testingPort),
Protocol: v1.ProtocolUDP,
},
}
service := utils.CreateLoadBalancerServiceManifest(testServiceName, nil, labels, ns.Name, mixedProtocolPorts)
_, err := cs.CoreV1().Services(ns.Name).Create(context.TODO(), service, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())
ip, err := utils.WaitServiceExposureAndValidateConnectivity(cs, ns.Name, testServiceName, "")
Expect(err).NotTo(HaveOccurred())

By("checking load balancing rules")
foundTCP, foundUDP := false, false
lb := getAzureLoadBalancerFromPIP(tc, ip, tc.GetResourceGroup(), "")
for _, rule := range *lb.LoadBalancingRules {
switch {
case strings.EqualFold(string(rule.Protocol), string(v1.ProtocolTCP)):
if to.Int32(rule.FrontendPort) == nginxPort {
foundTCP = true
}
case strings.EqualFold(string(rule.Protocol), string(v1.ProtocolUDP)):
if to.Int32(rule.FrontendPort) == testingPort {
foundUDP = true
}
}
}
Expect(foundTCP).To(BeTrue())
Expect(foundUDP).To(BeTrue())
})

It("should support BYO public IP", func() {
By("creating a public IP with tags")
ipName := basename + "-public-IP" + string(uuid.NewUUID())[0:4]
Expand Down
19 changes: 9 additions & 10 deletions tests/e2e/network/standard_lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package network

import (
"context"
"os"
"strings"

"github.com/Azure/go-autorest/autorest/to"
Expand Down Expand Up @@ -80,15 +81,14 @@ var _ = Describe("[StandardLoadBalancer] Standard load balancer", func() {
})

It("should add all nodes in different agent pools to backends [MultipleAgentPools]", func() {
if !strings.EqualFold(os.Getenv(utils.LoadBalancerSkuEnv), "standard") {
Skip("only test standard load balancer")
}

rgName := tc.GetResourceGroup()
publicIP := createAndExposeDefaultServiceWithAnnotation(cs, serviceName, ns.Name, labels, map[string]string{}, ports)
lb := getAzureLoadBalancerFromPIP(tc, publicIP, rgName, rgName)

if !strings.EqualFold(string(lb.Sku.Name), "standard") {
utils.Logf("sku: %s", lb.Sku.Name)
Skip("only support standard load balancer")
}

nodeList, err := utils.GetAgentNodes(cs)
Expect(err).NotTo(HaveOccurred())
if len(nodeList) < 2 {
Expand Down Expand Up @@ -130,15 +130,14 @@ var _ = Describe("[StandardLoadBalancer] Standard load balancer", func() {
})

It("should make outbound IP of pod same as in SLB's outbound rules", func() {
if !strings.EqualFold(os.Getenv(utils.LoadBalancerSkuEnv), "standard") {
Skip("only test standard load balancer")
}

rgName := tc.GetResourceGroup()
publicIP := createAndExposeDefaultServiceWithAnnotation(cs, serviceName, ns.Name, labels, map[string]string{}, ports)
lb := getAzureLoadBalancerFromPIP(tc, publicIP, rgName, rgName)

if !strings.EqualFold(string(lb.Sku.Name), "standard") {
utils.Logf("sku: %s", lb.Sku.Name)
Skip("only support standard load balancer")
}

Expect(lb.OutboundRules).NotTo(BeNil())
var fipConfigIDs []string
for _, outboundRule := range *lb.OutboundRules {
Expand Down