Skip to content

Commit cbab417

Browse files
committed
Add BGP e2e test for pod->external
Add bgp e2e tests This adds a new test for BGP+exposed default network. A simple north-south traffic flow check to ensure traffic is going out with podIP. A new controlplane lane has been added for this Signed-off-by: Surya Seetharaman <[email protected]>
1 parent 44233ca commit cbab417

File tree

6 files changed

+391
-60
lines changed

6 files changed

+391
-60
lines changed

test/e2e/e2e.go

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,25 +2024,47 @@ var _ = ginkgo.Describe("e2e br-int flow monitoring export validation", func() {
20242024

20252025
})
20262026

2027-
func getNodePodCIDR(nodeName string) (string, error) {
2027+
func getNodePodCIDRs(nodeName string) (string, string, error) {
20282028
// retrieve the pod cidr for the worker node
20292029
jsonFlag := "jsonpath='{.metadata.annotations.k8s\\.ovn\\.org/node-subnets}'"
20302030
kubectlOut, err := e2ekubectl.RunKubectl("default", "get", "node", nodeName, "-o", jsonFlag)
20312031
if err != nil {
2032-
return "", err
2032+
return "", "", err
20332033
}
20342034
// strip the apostrophe from stdout and parse the pod cidr
20352035
annotation := strings.Replace(kubectlOut, "'", "", -1)
20362036

2037+
var ipv4CIDR, ipv6CIDR string
2038+
20372039
ssSubnets := make(map[string]string)
20382040
if err := json.Unmarshal([]byte(annotation), &ssSubnets); err == nil {
2039-
return ssSubnets["default"], nil
2041+
// If only one subnet, determine if it's v4 or v6
2042+
if subnet, ok := ssSubnets["default"]; ok {
2043+
if strings.Contains(subnet, ":") {
2044+
ipv6CIDR = subnet
2045+
} else {
2046+
ipv4CIDR = subnet
2047+
}
2048+
return ipv4CIDR, ipv6CIDR, nil
2049+
}
20402050
}
2051+
20412052
dsSubnets := make(map[string][]string)
20422053
if err := json.Unmarshal([]byte(annotation), &dsSubnets); err == nil {
2043-
return dsSubnets["default"][0], nil
2054+
if subnets, ok := dsSubnets["default"]; ok && len(subnets) > 0 {
2055+
// Classify each subnet as IPv4 or IPv6
2056+
for _, subnet := range subnets {
2057+
if strings.Contains(subnet, ":") {
2058+
ipv6CIDR = subnet
2059+
} else {
2060+
ipv4CIDR = subnet
2061+
}
2062+
}
2063+
return ipv4CIDR, ipv6CIDR, nil
2064+
}
20442065
}
2045-
return "", fmt.Errorf("could not parse annotation %q", annotation)
2066+
2067+
return "", "", fmt.Errorf("could not parse annotation %q", annotation)
20462068
}
20472069

20482070
var _ = ginkgo.Describe("e2e delete databases", func() {

test/e2e/external_gateways.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ var _ = ginkgo.Describe("External Gateway", func() {
164164
framework.Logf("Annotating the external gateway test namespace to a container gw: %s ", exGWIpAlt1)
165165
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, annotateArgs...)
166166

167-
podCIDR, err := getNodePodCIDR(ciWorkerNodeSrc)
167+
podCIDR, _, err := getNodePodCIDRs(ciWorkerNodeSrc)
168168
if err != nil {
169169
framework.Failf("Error retrieving the pod cidr from %s %v", ciWorkerNodeSrc, err)
170170
}
@@ -342,7 +342,7 @@ var _ = ginkgo.Describe("External Gateway", func() {
342342
nodeIP = nodeIPv6
343343
}
344344
framework.Logf("the pod side node is %s and the source node ip is %s", workerNodeInfo.name, nodeIP)
345-
podCIDR, err := getNodePodCIDR(workerNodeInfo.name)
345+
podCIDR, _, err := getNodePodCIDRs(workerNodeInfo.name)
346346
if err != nil {
347347
framework.Failf("Error retrieving the pod cidr from %s %v", workerNodeInfo.name, err)
348348
}
@@ -1468,9 +1468,9 @@ var _ = ginkgo.Describe("External Gateway", func() {
14681468
func(protocol string, addresses *gatewayTestIPs, destPort, destPortOnPod int) {
14691469
ncCmd := func(sourcePort int, target string) []string {
14701470
if protocol == "tcp" {
1471-
return []string {"exec", srcPingPodName, "--", "bash", "-c", fmt.Sprintf("echo | nc -p %d -s %s -w 1 %s %d", sourcePort, addresses.srcPodIP, target, destPort)}
1471+
return []string{"exec", srcPingPodName, "--", "bash", "-c", fmt.Sprintf("echo | nc -p %d -s %s -w 1 %s %d", sourcePort, addresses.srcPodIP, target, destPort)}
14721472
} else {
1473-
return []string {"exec", srcPingPodName, "--", "bash", "-c", fmt.Sprintf("echo | nc -p %d -s %s -w 1 -u %s %d", sourcePort, addresses.srcPodIP, target, destPort)}
1473+
return []string{"exec", srcPingPodName, "--", "bash", "-c", fmt.Sprintf("echo | nc -p %d -s %s -w 1 -u %s %d", sourcePort, addresses.srcPodIP, target, destPort)}
14741474
}
14751475
}
14761476
if addresses.srcPodIP == "" || addresses.nodeIP == "" {

test/e2e/go.mod

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ require (
4545
github.com/distribution/reference v0.5.0 // indirect
4646
github.com/docker/go-connections v0.4.0 // indirect
4747
github.com/docker/go-units v0.5.0 // indirect
48-
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
48+
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
4949
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
5050
github.com/felixge/httpsnoop v1.0.4 // indirect
5151
github.com/fsnotify/fsnotify v1.7.0 // indirect
@@ -55,9 +55,9 @@ require (
5555
github.com/go-logfmt/logfmt v0.5.1 // indirect
5656
github.com/go-logr/logr v1.4.2 // indirect
5757
github.com/go-logr/stdr v1.2.2 // indirect
58-
github.com/go-openapi/jsonpointer v0.19.6 // indirect
59-
github.com/go-openapi/jsonreference v0.20.2 // indirect
60-
github.com/go-openapi/swag v0.22.4 // indirect
58+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
59+
github.com/go-openapi/jsonreference v0.21.0 // indirect
60+
github.com/go-openapi/swag v0.23.0 // indirect
6161
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
6262
github.com/gogo/protobuf v1.3.2 // indirect
6363
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
@@ -71,7 +71,7 @@ require (
7171
github.com/gorilla/websocket v1.5.0 // indirect
7272
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
7373
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
74-
github.com/imdario/mergo v0.3.15 // indirect
74+
github.com/imdario/mergo v0.3.16 // indirect
7575
github.com/inconshreveable/mousetrap v1.1.0 // indirect
7676
github.com/josharian/intern v1.0.0 // indirect
7777
github.com/josharian/native v1.0.0 // indirect
@@ -84,6 +84,7 @@ require (
8484
github.com/mdlayher/ndp v1.0.1 // indirect
8585
github.com/mdlayher/packet v1.0.0 // indirect
8686
github.com/mdlayher/socket v0.2.1 // indirect
87+
github.com/metallb/frr-k8s v0.0.15 // indirect
8788
github.com/miekg/dns v1.1.43 // indirect
8889
github.com/moby/spdystream v0.4.0 // indirect
8990
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@@ -130,15 +131,15 @@ require (
130131
go.uber.org/multierr v1.11.0 // indirect
131132
go.uber.org/zap v1.26.0 // indirect
132133
golang.org/x/crypto v0.24.0 // indirect
133-
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
134-
golang.org/x/mod v0.17.0 // indirect
134+
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
135+
golang.org/x/mod v0.18.0 // indirect
135136
golang.org/x/net v0.26.0 // indirect
136137
golang.org/x/oauth2 v0.21.0 // indirect
137138
golang.org/x/sys v0.21.0 // indirect
138139
golang.org/x/term v0.21.0 // indirect
139140
golang.org/x/text v0.16.0 // indirect
140-
golang.org/x/time v0.3.0 // indirect
141-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
141+
golang.org/x/time v0.5.0 // indirect
142+
golang.org/x/tools v0.22.0 // indirect
142143
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
143144
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
144145
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
@@ -160,7 +161,7 @@ require (
160161
k8s.io/controller-manager v0.31.1 // indirect
161162
k8s.io/klog/v2 v2.130.1 // indirect
162163
k8s.io/kms v0.31.1 // indirect
163-
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
164+
k8s.io/kube-openapi v0.0.0-20240521193020-835d969ad83a // indirect
164165
k8s.io/kubelet v0.31.1 // indirect
165166
kubevirt.io/containerized-data-importer-api v1.57.0-alpha1 // indirect
166167
kubevirt.io/controller-lifecycle-operator-sdk/api v0.0.0-20220329064328-f3cc58c6ed90 // indirect
@@ -177,7 +178,7 @@ require (
177178
github.com/google/goexpect v0.0.0-20210430020637-ab937bf7fd6f
178179
github.com/onsi/ginkgo v1.16.5
179180
github.com/openshift-kni/k8sreporter v1.0.6
180-
github.com/ovn-org/ovn-kubernetes/go-controller v0.0.0-20241008155748-956f8fa6b868
181+
github.com/ovn-org/ovn-kubernetes/go-controller v0.0.0-20250304211626-ab2bbed40acc
181182
go.universe.tf/metallb v0.0.0-00010101000000-000000000000
182183
google.golang.org/grpc v1.65.0
183184
k8s.io/kubectl v0.31.1

0 commit comments

Comments
 (0)