diff --git a/e2etests/tests/session.go b/e2etests/tests/session.go index 7f56fa4c..46251525 100644 --- a/e2etests/tests/session.go +++ b/e2etests/tests/session.go @@ -263,5 +263,70 @@ var _ = ginkgo.Describe("Session", func() { ginkgo.Entry("IPV4", ipfamily.IPv4), ginkgo.Entry("IPV6", ipfamily.IPv6), ) + + ginkgo.DescribeTable("Establishes sessions with dynamicASN", func(family ipfamily.Family) { + frrs := config.ContainersForVRF(infra.FRRContainers, "") + neighbors := []frrk8sv1beta1.Neighbor{} + + for _, f := range frrs { + addresses := f.AddressesForFamily(family) + ebgpMultihop := false + if f.NeighborConfig.MultiHop && f.NeighborConfig.ASN != f.RouterConfig.ASN { + ebgpMultihop = true + } + + dynamicASN := frrk8sv1beta1.InternalASNMode + if f.RouterConfig.ASN != infra.FRRK8sASN { + dynamicASN = frrk8sv1beta1.ExternalASNMode + } + + for _, address := range addresses { + neighbors = append(neighbors, frrk8sv1beta1.Neighbor{ + DynamicASN: dynamicASN, + Address: address, + Password: f.RouterConfig.Password, + Port: &f.RouterConfig.BGPPort, + EBGPMultiHop: ebgpMultihop, + }) + } + } + + config := frrk8sv1beta1.FRRConfiguration{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + Namespace: k8s.FRRK8sNamespace, + }, + Spec: frrk8sv1beta1.FRRConfigurationSpec{ + BGP: frrk8sv1beta1.BGPConfig{ + Routers: []frrk8sv1beta1.Router{ + { + ASN: infra.FRRK8sASN, + VRF: "", + Neighbors: neighbors, + }, + }, + }, + }, + } + + ginkgo.By("pairing with nodes") + for _, c := range frrs { + err := frrcontainer.PairWithNodes(cs, c, family) + Expect(err).NotTo(HaveOccurred()) + } + + err := updater.Update([]corev1.Secret{}, config) + Expect(err).NotTo(HaveOccurred()) + + nodes, err := k8s.Nodes(cs) + Expect(err).NotTo(HaveOccurred()) + + for _, c := range frrs { + ValidateFRRPeeredWithNodes(nodes, c, family) + } + }, + ginkgo.Entry("IPV4", ipfamily.IPv4), + ginkgo.Entry("IPV6", ipfamily.IPv6), + ) }) }) diff --git a/e2etests/tests/webhooks.go b/e2etests/tests/webhooks.go index ad2873db..46ac01e4 100644 --- a/e2etests/tests/webhooks.go +++ b/e2etests/tests/webhooks.go @@ -88,6 +88,7 @@ var _ = ginkgo.Describe("Webhooks", func() { ASN: 100, Neighbors: []frrk8sv1beta1.Neighbor{ { + ASN: 100, Address: "192.a.b.10", }, }, @@ -102,6 +103,7 @@ var _ = ginkgo.Describe("Webhooks", func() { { Neighbors: []frrk8sv1beta1.Neighbor{ { + ASN: 100, Address: "1.2.3.4", ToAdvertise: frrk8sv1beta1.Advertise{ PrefixesWithLocalPref: []frrk8sv1beta1.LocalPrefPrefixes{ @@ -118,6 +120,36 @@ var _ = ginkgo.Describe("Webhooks", func() { }, "localPref associated to non existing prefix", ), + ginkgo.Entry("both asn and dynamicASN not specified", + func(cfg *frrk8sv1beta1.FRRConfiguration) { + cfg.Spec.BGP.Routers = []frrk8sv1beta1.Router{ + { + Neighbors: []frrk8sv1beta1.Neighbor{ + { + Address: "1.2.3.4", + }, + }, + }, + } + }, + "has no ASN or DynamicASN specified", + ), + ginkgo.Entry("both asn and dynamicASN specified", + func(cfg *frrk8sv1beta1.FRRConfiguration) { + cfg.Spec.BGP.Routers = []frrk8sv1beta1.Router{ + { + Neighbors: []frrk8sv1beta1.Neighbor{ + { + ASN: 100, + DynamicASN: frrk8sv1beta1.ExternalASNMode, + Address: "1.2.3.4", + }, + }, + }, + } + }, + "has both ASN and DynamicASN specified", + ), ) ginkgo.It("Should reject create/update when there is a conflict with an existing config", func() {