Skip to content

Commit 36d67b7

Browse files
authored
test: add BGP speaker unit and end-to-end coverage (#7241)
Signed-off-by: Zujian Zhang <zhangzujian.7@gmail.com>
1 parent fc131b9 commit 36d67b7

10 files changed

Lines changed: 1028 additions & 8 deletions

File tree

.github/workflows/build-x86-image.yaml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,148 @@ jobs:
17191719
name: non-primary-cni-e2e-${{ matrix.ip-family }}-ko-log
17201720
path: non-primary-cni-e2e-${{ matrix.ip-family }}-ko-log.tar.gz
17211721

1722+
bgp-speaker-e2e:
1723+
name: BGP Speaker E2E
1724+
needs:
1725+
- build-kube-ovn
1726+
- build-e2e-binaries
1727+
runs-on: ubuntu-24.04
1728+
timeout-minutes: 30
1729+
steps:
1730+
- uses: jlumbroso/free-disk-space@v1.3.1
1731+
with:
1732+
android: true
1733+
dotnet: true
1734+
haskell: true
1735+
docker-images: false
1736+
large-packages: false
1737+
tool-cache: false
1738+
swap-storage: false
1739+
1740+
- uses: actions/checkout@v7
1741+
1742+
- name: Create the default branch directory
1743+
if: (github.base_ref || github.ref_name) != github.event.repository.default_branch
1744+
run: mkdir -p test/e2e/source
1745+
1746+
- name: Check out the default branch
1747+
if: (github.base_ref || github.ref_name) != github.event.repository.default_branch
1748+
uses: actions/checkout@v7
1749+
with:
1750+
ref: ${{ github.event.repository.default_branch }}
1751+
fetch-depth: 1
1752+
path: test/e2e/source
1753+
1754+
- name: Export E2E directory
1755+
run: |
1756+
if [ '${{ github.base_ref || github.ref_name }}' = '${{ github.event.repository.default_branch }}' ]; then
1757+
echo "E2E_DIR=." >> "$GITHUB_ENV"
1758+
else
1759+
echo "E2E_DIR=test/e2e/source" >> "$GITHUB_ENV"
1760+
fi
1761+
1762+
- uses: actions/setup-go@v7
1763+
id: setup-go
1764+
with:
1765+
go-version-file: ${{ env.E2E_DIR }}/go.mod
1766+
check-latest: true
1767+
cache: false
1768+
1769+
- name: Export Go full version
1770+
run: echo "GO_VERSION=${{ steps.setup-go.outputs.go-version }}" >> "$GITHUB_ENV"
1771+
1772+
- name: Go cache
1773+
uses: actions/cache/restore@v6
1774+
with:
1775+
path: |
1776+
~/.cache/go-build
1777+
~/go/pkg/mod
1778+
key: ${{ runner.os }}-e2e-go-${{ env.GO_VERSION }}-x86-${{ github.ref_name }}-${{ hashFiles(format('{0}/**/go.sum', env.E2E_DIR)) }}
1779+
restore-keys: |
1780+
${{ runner.os }}-e2e-go-${{ env.GO_VERSION }}-x86-${{ github.ref_name }}-
1781+
${{ runner.os }}-e2e-go-${{ env.GO_VERSION }}-x86-${{ github.base_ref }}-
1782+
1783+
- name: Install kind
1784+
uses: helm/kind-action@v1.14.0
1785+
with:
1786+
version: ${{ env.KIND_VERSION }}
1787+
install_only: true
1788+
1789+
- name: Download kube-ovn image
1790+
uses: actions/download-artifact@v8
1791+
with:
1792+
name: kube-ovn
1793+
1794+
- name: Load kube-ovn image
1795+
run: docker load -i kube-ovn.tar
1796+
1797+
- name: Create BGP kind and containerlab topology
1798+
id: setup
1799+
env:
1800+
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1801+
run: |
1802+
pipx install jinjanator
1803+
make kind-ghcr-pull kind-init-bgp
1804+
1805+
- name: Install Kube-OVN and BGP speakers
1806+
id: install
1807+
run: make kind-install-bgp
1808+
1809+
- name: Run BGP speaker E2E
1810+
id: e2e
1811+
working-directory: ${{ env.E2E_DIR }}
1812+
env:
1813+
E2E_BRANCH: ${{ github.base_ref || github.ref_name }}
1814+
E2E_IP_FAMILY: ipv4
1815+
E2E_NETWORK_MODE: overlay
1816+
run: make kube-ovn-bgp-speaker-e2e
1817+
1818+
- name: Check kube ovn pod restarts
1819+
id: check-restarts
1820+
if: ${{ success() || (failure() && (steps.install.conclusion == 'failure' || steps.e2e.conclusion == 'failure')) }}
1821+
run: make check-kube-ovn-pod-restarts
1822+
1823+
- name: Collect BGP diagnostics
1824+
if: failure() && (steps.setup.conclusion == 'failure' || steps.install.conclusion == 'failure' || steps.e2e.conclusion == 'failure' || steps.check-restarts.conclusion == 'failure')
1825+
run: |
1826+
mkdir -p bgp-speaker-e2e-diagnostics
1827+
docker exec clab-bgp-router vtysh -c "show bgp ipv4 unicast summary json" > bgp-speaker-e2e-diagnostics/frr-summary.json || true
1828+
docker exec clab-bgp-router vtysh -c "show bgp ipv4 unicast json" > bgp-speaker-e2e-diagnostics/frr-routes.json || true
1829+
kubectl -n kube-system get ds kube-ovn-speaker -o yaml > bgp-speaker-e2e-diagnostics/speaker-daemonset.yaml || true
1830+
kubectl -n kube-system get pods -l app=kube-ovn-speaker -o wide > bgp-speaker-e2e-diagnostics/speaker-pods.txt || true
1831+
kubectl -n kube-system logs -l app=kube-ovn-speaker --all-containers --prefix > bgp-speaker-e2e-diagnostics/speaker.log || true
1832+
kubectl get events -A -o yaml > bgp-speaker-e2e-diagnostics/events.yaml || true
1833+
docker cp kube-ovn-control-plane:/var/log/kubernetes/kube-apiserver-audit.log bgp-speaker-e2e-diagnostics/ || true
1834+
tar zcf bgp-speaker-e2e-diagnostics.tar.gz bgp-speaker-e2e-diagnostics
1835+
1836+
- name: Upload BGP diagnostics
1837+
uses: actions/upload-artifact@v7
1838+
if: failure() && (steps.setup.conclusion == 'failure' || steps.install.conclusion == 'failure' || steps.e2e.conclusion == 'failure' || steps.check-restarts.conclusion == 'failure')
1839+
with:
1840+
name: bgp-speaker-e2e-diagnostics
1841+
path: bgp-speaker-e2e-diagnostics.tar.gz
1842+
1843+
- name: kubectl ko log
1844+
if: failure() && (steps.setup.conclusion == 'failure' || steps.install.conclusion == 'failure' || steps.e2e.conclusion == 'failure' || steps.check-restarts.conclusion == 'failure')
1845+
run: |
1846+
if make kubectl-ko-log && test -f kubectl-ko-log.tar.gz; then
1847+
mv kubectl-ko-log.tar.gz bgp-speaker-e2e-ko-log.tar.gz
1848+
else
1849+
echo "kubectl ko log was unavailable because the BGP test cluster did not become usable." > bgp-speaker-e2e-ko-log-unavailable.txt
1850+
tar zcf bgp-speaker-e2e-ko-log.tar.gz bgp-speaker-e2e-ko-log-unavailable.txt
1851+
fi
1852+
1853+
- name: Upload kubectl ko log
1854+
uses: actions/upload-artifact@v7
1855+
if: failure() && (steps.setup.conclusion == 'failure' || steps.install.conclusion == 'failure' || steps.e2e.conclusion == 'failure' || steps.check-restarts.conclusion == 'failure')
1856+
with:
1857+
name: bgp-speaker-e2e-ko-log
1858+
path: bgp-speaker-e2e-ko-log.tar.gz
1859+
1860+
- name: Clean BGP topology
1861+
if: always()
1862+
run: make kind-clean-bgp
1863+
17221864
kube-ovn-hosted-ovn-central-e2e:
17231865
name: Kube-OVN Hosted OVN Central E2E (${{ matrix.ip-family }}, ${{ matrix.tenant-control-plane }} control-plane)
17241866
needs:
@@ -4418,6 +4560,7 @@ jobs:
44184560
- kube-ovn-underlay-metallb-e2e
44194561
- multus-conformance-e2e
44204562
- non-primary-cni-e2e
4563+
- bgp-speaker-e2e
44214564
- kube-ovn-hosted-ovn-central-e2e
44224565
- vpc-egress-gateway-e2e
44234566
- ovn-vpc-nat-gw-conformance-e2e

makefiles/e2e.mk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ e2e-build:
9292
$(GINKGO_E2E_BUILD) ./test/e2e/ovn-ic
9393
$(GINKGO_E2E_BUILD) ./test/e2e/multus
9494
$(GINKGO_E2E_BUILD) ./test/e2e/non-primary-cni
95+
$(GINKGO_E2E_BUILD) ./test/e2e/bgp
9596
$(GINKGO_E2E_BUILD) ./test/e2e/lb-svc
9697
$(GINKGO_E2E_BUILD) ./test/e2e/vip
9798
$(GINKGO_E2E_BUILD) ./test/e2e/vpc-egress-gateway
@@ -189,6 +190,16 @@ kube-ovn-non-primary-cni-e2e:
189190
$(GINKGO_E2E_RUN_PARALLEL) --timeout=15m \
190191
--focus="group:non-primary-cni" ./test/e2e/non-primary-cni/non-primary-cni.test -- $(TEST_BIN_ARGS)
191192

193+
.PHONY: kube-ovn-bgp-speaker-e2e
194+
kube-ovn-bgp-speaker-e2e:
195+
$(call kind_load_image,kube-ovn,$(AGNHOST_IMAGE),1)
196+
$(GINKGO_E2E_BUILD) ./test/e2e/bgp
197+
E2E_BRANCH=$(E2E_BRANCH) \
198+
E2E_IP_FAMILY=ipv4 \
199+
E2E_NETWORK_MODE=overlay \
200+
$(GINKGO_E2E_RUN) --timeout=15m \
201+
--focus="group:bgp-speaker" ./test/e2e/bgp/bgp.test -- $(TEST_BIN_ARGS)
202+
192203
.PHONY: kube-ovn-lb-svc-conformance-e2e
193204
kube-ovn-lb-svc-conformance-e2e:
194205
$(call kind_load_image,kube-ovn,$(AGNHOST_IMAGE),1)

makefiles/kind.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,8 @@ kind-install-bgp: kind-install
701701
-e 's/--neighbor-as=.*/--neighbor-as=65001/' \
702702
-e 's/--cluster-as=.*/--cluster-as=65002/' yamls/speaker.yaml | \
703703
kubectl apply -f -
704+
kubectl -n kube-system patch ds kube-ovn-speaker --type=json \
705+
-p='[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--announce-cluster-ip=true"}]'
704706
kubectl -n kube-system rollout status ds kube-ovn-speaker --timeout 60s
705707
docker exec clab-bgp-router vtysh -c "show ip route bgp"
706708

0 commit comments

Comments
 (0)