From 31d9289be484548d8e039ce368fc43bf0b3322aa Mon Sep 17 00:00:00 2001 From: karampok Date: Wed, 23 Oct 2024 19:30:43 +0200 Subject: [PATCH] wip: run many times test to flake Signed-off-by: karampok --- Makefile | 2 +- e2etests/pkg/k8s/pods.go | 1 + e2etests/tests/graceful_restart.go | 35 +++++++++++++++++++++++------- internal/frr/templates/frr.tmpl | 2 ++ 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 31b445b1..2dd42915 100644 --- a/Makefile +++ b/Makefile @@ -238,7 +238,7 @@ $(APIDOCSGEN): $(LOCALBIN) .PHONY: e2etests e2etests: ginkgo kubectl - $(GINKGO) -v $(GINKGO_ARGS) --timeout=3h ./e2etests -- --kubectl=$(KUBECTL) $(TEST_ARGS) + $(GINKGO) -v $(GINKGO_ARGS) --repeat=50 --timeout=3h ./e2etests -- --kubectl=$(KUBECTL) $(TEST_ARGS) .PHONY: kind-cluster diff --git a/e2etests/pkg/k8s/pods.go b/e2etests/pkg/k8s/pods.go index cbddfdea..860b0048 100644 --- a/e2etests/pkg/k8s/pods.go +++ b/e2etests/pkg/k8s/pods.go @@ -74,6 +74,7 @@ func RestartFRRK8sPods(cs clientset.Interface) error { return false, nil } } + ginkgo.By(fmt.Sprintf("\tfrrk8s pod ARE ready")) return true, nil }) } diff --git a/e2etests/tests/graceful_restart.go b/e2etests/tests/graceful_restart.go index cfea006e..2b5f342c 100644 --- a/e2etests/tests/graceful_restart.go +++ b/e2etests/tests/graceful_restart.go @@ -3,6 +3,7 @@ package tests import ( + "errors" "fmt" "time" @@ -26,7 +27,7 @@ import ( clientset "k8s.io/client-go/kubernetes" ) -var _ = ginkgo.Describe("Establish BGP session with EnableGracefulRestart", func() { +var _ = ginkgo.FDescribe("Establish BGP session with EnableGracefulRestart", func() { var ( cs clientset.Interface updater *config.Updater @@ -103,7 +104,7 @@ var _ = ginkgo.Describe("Establish BGP session with EnableGracefulRestart", func err := updater.Update(peersConfig.Secrets, frrConfigCR) Expect(err).NotTo(HaveOccurred(), "apply the CR in k8s api failed") - check := func() error { + Eventually(func() error { for _, p := range peersConfig.Peers() { err := routes.CheckNeighborHasPrefix(p.FRR, p.FRR.RouterConfig.VRF, prefix, nodes) if err != nil { @@ -111,11 +112,9 @@ var _ = ginkgo.Describe("Establish BGP session with EnableGracefulRestart", func } } return nil - } - - Eventually(check, time.Minute, time.Second).ShouldNot(HaveOccurred(), - "route should exist before we restart frr-k8s") + }, time.Minute, time.Second).ShouldNot(HaveOccurred(), "route should exist before we restart frr-k8s") + time.Sleep(5 * time.Second) c := make(chan struct{}) go func() { // go restart frr-k8s while Consistently check that route exists defer ginkgo.GinkgoRecover() @@ -124,12 +123,32 @@ var _ = ginkgo.Describe("Establish BGP session with EnableGracefulRestart", func close(c) }() + check := func() error { + var returnError error + + for _, p := range peersConfig.Peers() { + err = routes.CheckNeighborHasPrefix(p.FRR, p.FRR.RouterConfig.VRF, prefix, nodes) + if err != nil { + returnError = errors.Join(returnError, fmt.Errorf("Neigh %s does not have prefix %s: %w", p.FRR.Name, prefix, err)) + for i := 0; i < 5; i++ { + if err := routes.CheckNeighborHasPrefix(p.FRR, p.FRR.RouterConfig.VRF, prefix, nodes); err != nil { + ginkgo.By(fmt.Sprintf("%d Neigh %s does not have prefix %s: %s", i, p.FRR.Name, prefix, err)) + time.Sleep(time.Second) + } else { + ginkgo.By(fmt.Sprintf("%d Neigh %s does have prefix %s: %s", i, p.FRR.Name, prefix, err)) + } + } + } + } + return returnError + } + // 2*time.Minute is important because that is the Graceful Restart timer. Consistently(check, 2*time.Minute, time.Second).ShouldNot(HaveOccurred()) Eventually(c, time.Minute, time.Second).Should(BeClosed(), "restart FRRK8s pods are not yet ready") }, - ginkgo.Entry("IPV4", ipfamily.IPv4, "192.168.2.0/24"), - ginkgo.Entry("IPV6", ipfamily.IPv6, "fc00:f853:ccd:e799::/64"), + ginkgo.Entry("IPV4", ipfamily.IPv4, "5.5.5.5/32"), + ginkgo.Entry("IPV6", ipfamily.IPv6, "2001:db8:5555::5/128"), ) }) }) diff --git a/internal/frr/templates/frr.tmpl b/internal/frr/templates/frr.tmpl index 00546c32..d503f3fb 100644 --- a/internal/frr/templates/frr.tmpl +++ b/internal/frr/templates/frr.tmpl @@ -19,6 +19,8 @@ debug route-map detail hostname {{.Hostname}} ip nht resolve-via-default ipv6 nht resolve-via-default +bgp route-map delay-timer 0 + {{- range $r := .Routers }} {{- range .Neighbors }}