Skip to content

Commit

Permalink
E2E: Establish session using DynamicASN
Browse files Browse the repository at this point in the history
Signed-off-by: Ori Braunshtein <[email protected]>
  • Loading branch information
oribon committed Aug 29, 2024
1 parent 14c9d6a commit a596472
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
65 changes: 65 additions & 0 deletions e2etests/tests/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
})
})
32 changes: 32 additions & 0 deletions e2etests/tests/webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ var _ = ginkgo.Describe("Webhooks", func() {
ASN: 100,
Neighbors: []frrk8sv1beta1.Neighbor{
{
ASN: 100,
Address: "192.a.b.10",
},
},
Expand All @@ -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{
Expand All @@ -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() {
Expand Down

0 comments on commit a596472

Please sign in to comment.