Skip to content

Commit

Permalink
chore: add mixed protocol service e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
nilo19 authored and k8s-infra-cherrypick-robot committed Apr 7, 2022
1 parent 91e6c56 commit b61384a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 10 deletions.
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

0 comments on commit b61384a

Please sign in to comment.