Skip to content

Commit 44233ca

Browse files
committed
Add a new CP lane for BGP tests
This commit adds two new lanes to run lgw, sgw BGP e2e tests. Signed-off-by: Surya Seetharaman <[email protected]>
1 parent 6cdfa09 commit 44233ca

File tree

4 files changed

+120
-3
lines changed

4 files changed

+120
-3
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ jobs:
445445
- {"target": "network-segmentation", "ha": "noHA", "gateway-mode": "shared", "ipfamily": "dualstack", "disable-snat-multiple-gws": "SnatGW", "second-bridge": "1br", "ic": "ic-disabled"}
446446
- {"target": "network-segmentation", "ha": "noHA", "gateway-mode": "shared", "ipfamily": "ipv4", "disable-snat-multiple-gws": "noSnatGW", "second-bridge": "1br", "ic": "ic-single-node-zones"}
447447
- {"target": "network-segmentation", "ha": "noHA", "gateway-mode": "shared", "ipfamily": "ipv6", "disable-snat-multiple-gws": "noSnatGW", "second-bridge": "1br", "ic": "ic-single-node-zones"}
448+
- {"target": "bgp", "ha": "noHA", "gateway-mode": "local", "ipfamily": "dualstack", "disable-snat-multiple-gws": "snatGW", "second-bridge": "1br", "ic": "ic-single-node-zones", "routeadvertisements": "advertise-default"}
449+
- {"target": "bgp", "ha": "noHA", "gateway-mode": "shared", "ipfamily": "ipv4", "disable-snat-multiple-gws": "snatGW", "second-bridge": "1br", "ic": "ic-single-node-zones", "routeadvertisements": "advertise-default"}
448450
- {"target": "traffic-flow-test-only","ha": "noHA", "gateway-mode": "shared", "ipfamily": "ipv4", "disable-snat-multiple-gws": "noSnatGW", "second-bridge": "1br", "ic": "ic-single-node-zones", "traffic-flow-tests": "1-24"}
449451
- {"target": "tools", "ha": "noHA", "gateway-mode": "local", "ipfamily": "dualstack", "disable-snat-multiple-gws": "SnatGW", "second-bridge": "1br", "ic": "ic-single-node-zones"}
450452
needs: [ build-pr ]
@@ -461,7 +463,7 @@ jobs:
461463
KIND_IPV4_SUPPORT: "${{ matrix.ipfamily == 'IPv4' || matrix.ipfamily == 'dualstack' }}"
462464
KIND_IPV6_SUPPORT: "${{ matrix.ipfamily == 'IPv6' || matrix.ipfamily == 'dualstack' }}"
463465
ENABLE_MULTI_NET: "${{ matrix.target == 'multi-homing' || matrix.target == 'kv-live-migration' || matrix.target == 'network-segmentation' || matrix.target == 'tools' || matrix.target == 'multi-homing-helm' || matrix.target == 'traffic-flow-test-only' || matrix.routeadvertisements != '' }}"
464-
ENABLE_NETWORK_SEGMENTATION: "${{ matrix.target == 'network-segmentation' || matrix.target == 'tools' || matrix.target == 'kv-live-migration' || matrix.target == 'traffic-flow-test-only' }}"
466+
ENABLE_NETWORK_SEGMENTATION: "${{ matrix.target == 'network-segmentation' || matrix.target == 'tools' || matrix.target == 'kv-live-migration' || matrix.target == 'traffic-flow-test-only' || matrix.target == 'bgp' }}"
465467
DISABLE_UDN_HOST_ISOLATION: "true"
466468
KIND_INSTALL_KUBEVIRT: "${{ matrix.target == 'kv-live-migration' }}"
467469
OVN_COMPACT_MODE: "${{ matrix.target == 'compact-mode' }}"
@@ -597,6 +599,8 @@ jobs:
597599
make -C test conformance
598600
elif [ "${{ matrix.target }}" == "network-segmentation" ]; then
599601
make -C test control-plane WHAT="Network Segmentation"
602+
elif [ "${{ matrix.target }}" == "bgp" ]; then
603+
make -C test control-plane WHAT="BGP"
600604
elif [ "${{ matrix.target }}" == "tools" ]; then
601605
make -C go-controller build
602606
make -C test tools

contrib/kind-common

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,14 +652,23 @@ get_kubevirt_release_url() {
652652
echo "$kubevirt_release_url"
653653
}
654654

655-
readonly FRR_K8S_VERSION=v0.0.14
655+
readonly FRR_K8S_VERSION=v0.0.17
656656
readonly FRR_TMP_DIR=$(mktemp -d -u)
657657

658658
clone_frr() {
659659
[ -d "$FRR_TMP_DIR" ] || {
660660
mkdir -p "$FRR_TMP_DIR" && trap 'rm -rf $FRR_TMP_DIR' EXIT
661661
pushd "$FRR_TMP_DIR" || exit 1
662662
git clone --depth 1 --branch $FRR_K8S_VERSION https://github.com/metallb/frr-k8s
663+
664+
# Download the patches
665+
curl -Ls https://github.com/jcaamano/frr-k8s/archive/refs/heads/ovnk-bgp.tar.gz | tar xzvf - frr-k8s-ovnk-bgp/patches --strip-components 1
666+
667+
# Change into the cloned repo directory before applying patches
668+
pushd frr-k8s
669+
git apply ../patches/*
670+
popd
671+
663672
popd || exit 1
664673
}
665674
}
@@ -676,9 +685,86 @@ deploy_frr_external_container() {
676685
# can peer with acting as BGP (reflector) external gateway
677686
pushd "${FRR_TMP_DIR}"/frr-k8s/hack/demo || exit 1
678687
# modify config template to configure neighbors as route reflector clients
688+
# First check if IPv4 network already exists
689+
grep -q 'network '"${BGP_SERVER_NET_SUBNET_IPV4}" frr/frr.conf.tmpl || \
690+
sed -i '/address-family ipv4 unicast/a \ \ network '"${BGP_SERVER_NET_SUBNET_IPV4}"'' frr/frr.conf.tmpl
691+
692+
# Add route reflector client config
679693
sed -i '/remote-as 64512/a \ neighbor {{ . }} route-reflector-client' frr/frr.conf.tmpl
694+
695+
if [ "$KIND_IPV6_SUPPORT" == true ]; then
696+
# Check if IPv6 address-family section exists
697+
if ! grep -q 'address-family ipv6 unicast' frr/frr.conf.tmpl; then
698+
# Add IPv6 address-family section if it doesn't exist
699+
sed -i '/exit-address-family/a \ \
700+
address-family ipv6 unicast\
701+
network '"${BGP_SERVER_NET_SUBNET_IPV6}"'\
702+
exit-address-family' frr/frr.conf.tmpl
703+
else
704+
# Add network to existing IPv6 section
705+
sed -i '/address-family ipv6 unicast/a \ \ network '"${BGP_SERVER_NET_SUBNET_IPV6}"'' frr/frr.conf.tmpl
706+
fi
707+
708+
# Add route-reflector-client for IPv6 neighbors
709+
sed -i '/neighbor fc00.*remote-as 64512/a \ neighbor {{ . }} route-reflector-client' frr/frr.conf.tmpl
710+
fi
680711
./demo.sh
681712
popd || exit 1
713+
if [ "$KIND_IPV6_SUPPORT" == true ]; then
714+
# Enable IPv6 forwarding in FRR
715+
docker exec frr sysctl -w net.ipv6.conf.all.forwarding=1
716+
fi
717+
}
718+
719+
deploy_bgp_external_server() {
720+
# We create an external docker container that acts as the server (or client) outside the cluster
721+
# in the e2e tests that levergae router advertisements.
722+
# This container will be connected to the frr container deployed above to simulate a realistic
723+
# network topology
724+
# ----------------- ------------------ ---------------------
725+
# | | 172.26.0.0/16 | | 172.18.0.0/16 | ovn-control-plane |
726+
# | external |<------------- | FRR router |<------ KIND cluster -- ---------------------
727+
# | server | | | | ovn-worker | (client pod advertised
728+
# ----------------- ------------------ --------------------- using RouteAdvertisements
729+
# | ovn-worker2 | from default pod network)
730+
# ---------------------
731+
local ip_family ipv6_network
732+
if [ "$KIND_IPV4_SUPPORT" == true ] && [ "$KIND_IPV6_SUPPORT" == true ]; then
733+
ip_family="dual"
734+
ipv6_network="--ipv6 --subnet=${BGP_SERVER_NET_SUBNET_IPV6}"
735+
elif [ "$KIND_IPV6_SUPPORT" == true ]; then
736+
ip_family="ipv6"
737+
ipv6_network="--ipv6 --subnet=${BGP_SERVER_NET_SUBNET_IPV6}"
738+
else
739+
ip_family="ipv4"
740+
ipv6_network=""
741+
fi
742+
docker network create --subnet="${BGP_SERVER_NET_SUBNET_IPV4}" ${ipv6_network} --driver bridge bgpnet
743+
docker network connect bgpnet frr
744+
docker run --cap-add NET_ADMIN --user 0 -d --network bgpnet --rm --name bgpserver -p 8080:8080 registry.k8s.io/e2e-test-images/agnhost:2.45 netexec
745+
# let's make the bgp external server have its default route towards FRR router so that we don't need to add routes during tests back to the pods in the
746+
# cluster for return traffic
747+
local bgp_network_frr_v4 bgp_network_frr_v6
748+
bgp_network_frr_v4=$($OCI_BIN inspect -f '{{index .NetworkSettings.Networks "bgpnet" "IPAddress"}}' frr)
749+
echo "FRR kind network IPv4: ${bgp_network_frr_v4}"
750+
$OCI_BIN exec bgpserver ip route replace default via "$bgp_network_frr_v4"
751+
if [ "$KIND_IPV6_SUPPORT" == true ] ; then
752+
bgp_network_frr_v6=$($OCI_BIN inspect -f '{{index .NetworkSettings.Networks "bgpnet" "GlobalIPv6Address"}}' frr)
753+
echo "FRR kind network IPv6: ${bgp_network_frr_v6}"
754+
$OCI_BIN exec bgpserver ip -6 route replace default via "$bgp_network_frr_v6"
755+
fi
756+
}
757+
758+
destroy_bgp() {
759+
if docker ps --format '{{.Names}}' | grep -Eq '^bgpserver$'; then
760+
docker stop bgpserver
761+
fi
762+
if docker ps --format '{{.Names}}' | grep -Eq '^frr$'; then
763+
docker stop frr
764+
fi
765+
if docker network ls --format '{{.Name}}' | grep -q '^bgpnet$'; then
766+
docker network rm bgpnet
767+
fi
682768
}
683769

684770
install_ffr_k8s() {
@@ -693,7 +779,19 @@ install_ffr_k8s() {
693779
# apply a BGP peer configration with the external gateway that does not
694780
# exchange routes
695781
pushd "${FRR_TMP_DIR}"/frr-k8s/hack/demo/configs || exit 1
696-
sed 's/all$/filtered/g' receive_all.yaml > receive_filtered.yaml
782+
sed 's/mode: all/mode: filtered/g' receive_all.yaml > receive_filtered.yaml
783+
# Allow receiving the bgp external server's prefix
784+
sed -i '/mode: filtered/a\ prefixes:\n - prefix: '"${BGP_SERVER_NET_SUBNET_IPV4}"'' receive_filtered.yaml
785+
# If IPv6 is enabled, add the IPv6 prefix as well
786+
if [ "$KIND_IPV6_SUPPORT" == true ]; then
787+
# Find all line numbers where the IPv4 prefix is defined
788+
IPv6_LINE=" - prefix: ${BGP_SERVER_NET_SUBNET_IPV6}"
789+
# Process each occurrence of the IPv4 prefix
790+
for LINE_NUM in $(grep -n "prefix: ${BGP_SERVER_NET_SUBNET_IPV4}" receive_filtered.yaml | cut -d ':' -f 1); do
791+
# Insert the IPv6 prefix after each IPv4 prefix line
792+
sed -i "${LINE_NUM}a\\${IPv6_LINE}" receive_filtered.yaml
793+
done
794+
fi
697795
kubectl apply -f receive_filtered.yaml
698796
popd || exit 1
699797

contrib/kind.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ delete() {
4545
if [ "$KIND_INSTALL_METALLB" == true ]; then
4646
destroy_metallb
4747
fi
48+
if [ "$ENABLE_ROUTE_ADVERTISEMENTS" == true ]; then
49+
destroy_bgp
50+
fi
4851
timeout 5 kubectl --kubeconfig "${KUBECONFIG}" delete namespace ovn-kubernetes || true
4952
sleep 5
5053
kind delete cluster --name "${KIND_CLUSTER_NAME:-ovn}"
@@ -586,6 +589,8 @@ set_default_params() {
586589
TRANSIT_SWITCH_SUBNET_IPV6=${TRANSIT_SWITCH_SUBNET_IPV6:-fd97::/64}
587590
METALLB_CLIENT_NET_SUBNET_IPV4=${METALLB_CLIENT_NET_SUBNET_IPV4:-172.22.0.0/16}
588591
METALLB_CLIENT_NET_SUBNET_IPV6=${METALLB_CLIENT_NET_SUBNET_IPV6:-fc00:f853:ccd:e792::/64}
592+
BGP_SERVER_NET_SUBNET_IPV4=${BGP_SERVER_NET_SUBNET_IPV4:-172.26.0.0/16}
593+
BGP_SERVER_NET_SUBNET_IPV6=${BGP_SERVER_NET_SUBNET_IPV6:-fc00:f853:ccd:e796::/64}
589594

590595
KIND_NUM_MASTER=1
591596
OVN_ENABLE_INTERCONNECT=${OVN_ENABLE_INTERCONNECT:-false}
@@ -1183,6 +1188,7 @@ if [ "$OVN_ENABLE_DNSNAMERESOLVER" == true ]; then
11831188
fi
11841189
if [ "$ENABLE_ROUTE_ADVERTISEMENTS" == true ]; then
11851190
deploy_frr_external_container
1191+
deploy_bgp_external_server
11861192
fi
11871193
build_ovn_image
11881194
detect_apiserver_url

test/scripts/e2e-cp.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ if [[ "${WHAT}" != "${NETWORK_SEGMENTATION_TESTS}"* ]]; then
160160
SKIPPED_TESTS+=$NETWORK_SEGMENTATION_TESTS
161161
fi
162162

163+
# Only run bgp tests if they are explicitly requested
164+
BGP_TESTS="BGP"
165+
if [[ "${WHAT}" != "${BGP_TESTS}"* ]]; then
166+
if [ "$SKIPPED_TESTS" != "" ]; then
167+
SKIPPED_TESTS+="|"
168+
fi
169+
SKIPPED_TESTS+=$BGP_TESTS
170+
fi
171+
163172
# setting these is required to make RuntimeClass tests work ... :/
164173
export KUBE_CONTAINER_RUNTIME=remote
165174
export KUBE_CONTAINER_RUNTIME_ENDPOINT=unix:///run/containerd/containerd.sock

0 commit comments

Comments
 (0)