Skip to content

Commit 90513a0

Browse files
oribonfedepaol
authored andcommitted
E2E: Establish session using DynamicASN
Signed-off-by: Ori Braunshtein <[email protected]>
1 parent fd27de1 commit 90513a0

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

e2etests/tests/session.go

+65
Original file line numberDiff line numberDiff line change
@@ -263,5 +263,70 @@ var _ = ginkgo.Describe("Session", func() {
263263
ginkgo.Entry("IPV4", ipfamily.IPv4),
264264
ginkgo.Entry("IPV6", ipfamily.IPv6),
265265
)
266+
267+
ginkgo.DescribeTable("Establishes sessions with dynamicASN", func(family ipfamily.Family) {
268+
frrs := config.ContainersForVRF(infra.FRRContainers, "")
269+
neighbors := []frrk8sv1beta1.Neighbor{}
270+
271+
for _, f := range frrs {
272+
addresses := f.AddressesForFamily(family)
273+
ebgpMultihop := false
274+
if f.NeighborConfig.MultiHop && f.NeighborConfig.ASN != f.RouterConfig.ASN {
275+
ebgpMultihop = true
276+
}
277+
278+
dynamicASN := frrk8sv1beta1.InternalASNMode
279+
if f.RouterConfig.ASN != infra.FRRK8sASN {
280+
dynamicASN = frrk8sv1beta1.ExternalASNMode
281+
}
282+
283+
for _, address := range addresses {
284+
neighbors = append(neighbors, frrk8sv1beta1.Neighbor{
285+
DynamicASN: dynamicASN,
286+
Address: address,
287+
Password: f.RouterConfig.Password,
288+
Port: &f.RouterConfig.BGPPort,
289+
EBGPMultiHop: ebgpMultihop,
290+
})
291+
}
292+
}
293+
294+
config := frrk8sv1beta1.FRRConfiguration{
295+
ObjectMeta: metav1.ObjectMeta{
296+
Name: "test",
297+
Namespace: k8s.FRRK8sNamespace,
298+
},
299+
Spec: frrk8sv1beta1.FRRConfigurationSpec{
300+
BGP: frrk8sv1beta1.BGPConfig{
301+
Routers: []frrk8sv1beta1.Router{
302+
{
303+
ASN: infra.FRRK8sASN,
304+
VRF: "",
305+
Neighbors: neighbors,
306+
},
307+
},
308+
},
309+
},
310+
}
311+
312+
ginkgo.By("pairing with nodes")
313+
for _, c := range frrs {
314+
err := frrcontainer.PairWithNodes(cs, c, family)
315+
Expect(err).NotTo(HaveOccurred())
316+
}
317+
318+
err := updater.Update([]corev1.Secret{}, config)
319+
Expect(err).NotTo(HaveOccurred())
320+
321+
nodes, err := k8s.Nodes(cs)
322+
Expect(err).NotTo(HaveOccurred())
323+
324+
for _, c := range frrs {
325+
ValidateFRRPeeredWithNodes(nodes, c, family)
326+
}
327+
},
328+
ginkgo.Entry("IPV4", ipfamily.IPv4),
329+
ginkgo.Entry("IPV6", ipfamily.IPv6),
330+
)
266331
})
267332
})

e2etests/tests/webhooks.go

+32
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ var _ = ginkgo.Describe("Webhooks", func() {
8888
ASN: 100,
8989
Neighbors: []frrk8sv1beta1.Neighbor{
9090
{
91+
ASN: 100,
9192
Address: "192.a.b.10",
9293
},
9394
},
@@ -102,6 +103,7 @@ var _ = ginkgo.Describe("Webhooks", func() {
102103
{
103104
Neighbors: []frrk8sv1beta1.Neighbor{
104105
{
106+
ASN: 100,
105107
Address: "1.2.3.4",
106108
ToAdvertise: frrk8sv1beta1.Advertise{
107109
PrefixesWithLocalPref: []frrk8sv1beta1.LocalPrefPrefixes{
@@ -118,6 +120,36 @@ var _ = ginkgo.Describe("Webhooks", func() {
118120
},
119121
"localPref associated to non existing prefix",
120122
),
123+
ginkgo.Entry("both asn and dynamicASN not specified",
124+
func(cfg *frrk8sv1beta1.FRRConfiguration) {
125+
cfg.Spec.BGP.Routers = []frrk8sv1beta1.Router{
126+
{
127+
Neighbors: []frrk8sv1beta1.Neighbor{
128+
{
129+
Address: "1.2.3.4",
130+
},
131+
},
132+
},
133+
}
134+
},
135+
"has no ASN or DynamicASN specified",
136+
),
137+
ginkgo.Entry("both asn and dynamicASN specified",
138+
func(cfg *frrk8sv1beta1.FRRConfiguration) {
139+
cfg.Spec.BGP.Routers = []frrk8sv1beta1.Router{
140+
{
141+
Neighbors: []frrk8sv1beta1.Neighbor{
142+
{
143+
ASN: 100,
144+
DynamicASN: frrk8sv1beta1.ExternalASNMode,
145+
Address: "1.2.3.4",
146+
},
147+
},
148+
},
149+
}
150+
},
151+
"has both ASN and DynamicASN specified",
152+
),
121153
)
122154

123155
ginkgo.It("Should reject create/update when there is a conflict with an existing config", func() {

0 commit comments

Comments
 (0)