diff --git a/e2etests/pkg/routes/routes.go b/e2etests/pkg/routes/routes.go index cb20c9bc..2e85fd9a 100644 --- a/e2etests/pkg/routes/routes.go +++ b/e2etests/pkg/routes/routes.go @@ -4,7 +4,6 @@ package routes import ( "bytes" - "errors" "fmt" "net" @@ -31,32 +30,28 @@ func PodHasPrefixFromContainer(pod *v1.Pod, frr frrcontainer.FRR, prefix string) // CheckNeighborHasPrefix tells if the given frr container has a route toward the given prefix // via the set of node passed to this function. -func CheckNeighborHasPrefix(neighbor frrcontainer.FRR, prefix string, nodes []v1.Node) (bool, error) { +func CheckNeighborHasPrefix(neighbor frrcontainer.FRR, prefix string, nodes []v1.Node) error { routesV4, routesV6, err := frr.Routes(neighbor) if err != nil { - return false, err + return err } _, cidr, err := net.ParseCIDR(prefix) if err != nil { - return false, err + return err } route, err := routeForCIDR(cidr, routesV4, routesV6) - var notFound RouteNotFoundError - if errors.As(err, ¬Found) { - return false, nil - } if err != nil { - return false, err + return err } cidrFamily := ipfamily.ForCIDR(cidr) err = frr.RoutesMatchNodes(nodes, route, cidrFamily, neighbor.RouterConfig.VRF) if err != nil { - return false, nil + return nil } - return true, nil + return nil } func cidrsAreEqual(a, b *net.IPNet) bool { diff --git a/e2etests/tests/validate.go b/e2etests/tests/validate.go index 0a058dbd..61f243c3 100644 --- a/e2etests/tests/validate.go +++ b/e2etests/tests/validate.go @@ -47,10 +47,9 @@ func ValidatePrefixesForNeighbor(neigh frrcontainer.FRR, nodes []v1.Node, prefix ginkgo.By(fmt.Sprintf("checking prefixes %v for %s", prefixes, neigh.Name)) Eventually(func() error { for _, prefix := range prefixes { - found, err := routes.CheckNeighborHasPrefix(neigh, prefix, nodes) - Expect(err).NotTo(HaveOccurred()) - if !found { - return fmt.Errorf("Neigh %s does not have prefix %s", neigh.Name, prefix) + err := routes.CheckNeighborHasPrefix(neigh, prefix, nodes) + if err != nil { + return fmt.Errorf("Neigh %s does not have prefix %s: %w", neigh.Name, prefix, err) } } return nil @@ -61,14 +60,13 @@ func ValidateNeighborNoPrefixes(neigh frrcontainer.FRR, nodes []v1.Node, prefixe ginkgo.By(fmt.Sprintf("checking prefixes %v not announced to %s", prefixes, neigh.Name)) Eventually(func() error { for _, prefix := range prefixes { - found, err := routes.CheckNeighborHasPrefix(neigh, prefix, nodes) - Expect(err).NotTo(HaveOccurred()) - if found { - return fmt.Errorf("Neigh %s has prefix %s", neigh.Name, prefix) + err := routes.CheckNeighborHasPrefix(neigh, prefix, nodes) + if err != nil { + return fmt.Errorf("Neigh %s does not have prefix %s: %w", neigh.Name, prefix, err) } } return nil - }, 5*time.Second, time.Second).ShouldNot(HaveOccurred()) + }, 5*time.Second, time.Second).Should(MatchError(routes.RouteNotFoundError(""))) } func ValidateNeighborCommunityPrefixes(neigh frrcontainer.FRR, community string, prefixes []string, ipfam ipfamily.Family) {