Skip to content

Commit c6c5e59

Browse files
authored
test: Add e2e test testing vlan/subinterface functionality (#1872)
1 parent e307931 commit c6c5e59

File tree

2 files changed

+303
-4
lines changed

2 files changed

+303
-4
lines changed

tests/e2e/010_interfaces_test.go

Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ package e2e
1616

1717
import (
1818
"context"
19+
"os"
1920
"testing"
21+
"time"
2022

2123
. "github.com/onsi/gomega"
2224

2325
"go.ligato.io/vpp-agent/v3/proto/ligato/kvscheduler"
2426
linux_interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/linux/interfaces"
2527
linux_namespace "go.ligato.io/vpp-agent/v3/proto/ligato/linux/namespace"
2628
vpp_interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces"
29+
vpp_l2 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l2"
2730
)
2831

2932
// connect VPP with a microservice via TAP interface
@@ -148,6 +151,302 @@ func TestInterfaceConnTap(t *testing.T) {
148151
ctx.Expect(ctx.AgentInSync()).To(BeTrue())
149152
}
150153

154+
//
155+
// +---------------------------------------------------+
156+
// | VPP |
157+
// | |
158+
// | +---------------+ +---------------+ |
159+
// | |192.168.1.10/24| |192.168.2.20/24| |
160+
// | +-------+-------+ +-------+-------+ |
161+
// | | (SUBIF) | (SUBIF) |
162+
// | +-------+-----------------------+-------+ |
163+
// | | | |
164+
// | +-------------------+-------------------+ |
165+
// +-------------------------|-------------------------+
166+
// | (MEMIF)
167+
// +-------------------------|-------------------------+
168+
// | +-------------------+-------------------+ |
169+
// | | | |
170+
// | +-------+-----------------------+-------+ |
171+
// | | (SUBIF) | (SUBIF) |
172+
// | +-------+-------+ +-------+-------+ |
173+
// | |192.168.1.10/24| |192.168.2.20/24| |
174+
// | +-------+-------+ +-------+-------+ |
175+
// | | | |
176+
// | VPP | (BD) | (BD) |
177+
// | | | |
178+
// | +-------+-------+ +-------+-------+ |
179+
// | |192.168.1.11/24| |192.168.2.22/24| |
180+
// | +-------+-------+ +-------+-------+ |
181+
// +-------------|-----------------------|-------------+
182+
// | (TAP) | (TAP)
183+
// +-------------|----------+ +----------|-------------+
184+
// | +-------+-------+ | | +-------+-------+ |
185+
// | |192.168.1.11/24| | | |192.168.2.22/24| |
186+
// | +-------+-------+ | | +-------+-------+ |
187+
// | | | |
188+
// | LINUX | | LINUX |
189+
// +------------------------+ +------------------------+
190+
//
191+
// This test tests the primarily the following pings:
192+
// from: 192.168.1.10 (left subif in top vpp) to: 192.168.1.11 (left linux microservice) - should pass (same vlan)
193+
// from: 192.168.2.20 (right subif in top vpp) to: 192.168.2.22 (right linux microservice) - should pass (same vlan)
194+
// from: 192.168.1.10 (left subif in top vpp) to: 192.168.2.22 (right linux microservice) - should fail (different vlans)
195+
// from: 192.168.2.20 (right subif in top vpp) to: 192.168.1.11 (left linux microservice) - should fail (different vlans)
196+
//
197+
func TestMemifSubinterfaceVlanConn(t *testing.T) {
198+
ctx := Setup(t)
199+
defer ctx.Teardown()
200+
201+
const (
202+
vpp1MemifName = "vpp1-to-vpp2"
203+
vpp2MemifName = "vpp2-to-vpp1"
204+
vpp1Subif1Name = "vpp1Subif1"
205+
vpp1Subif2Name = "vpp1Subif2"
206+
vpp1Subif1IP = "192.168.1.10"
207+
vpp1Subif2IP = "192.168.2.20"
208+
vpp2Subif1Name = "vpp2Subif1"
209+
vpp2Subif2Name = "vpp2Subif2"
210+
vpp2Tap1Name = "vpp2-to-ms1"
211+
vpp2Tap2Name = "vpp2-to-ms2"
212+
ms1TapName = "ms1-to-vpp2"
213+
ms2TapName = "ms2-to-vpp2"
214+
ms1TapIP = "192.168.1.11"
215+
ms2TapIP = "192.168.2.22"
216+
bd1Name = "bd1"
217+
bd2Name = "bd2"
218+
ms1Name = "ms1"
219+
ms2Name = "ms2"
220+
agent2Name = "agent2"
221+
netMask = "/24"
222+
msTapHostname = "tap"
223+
memifFilepath = "/test-memif-subif-vlan-conn/memif/"
224+
memifSockname = "memif.sock"
225+
)
226+
227+
// needed for creation of memif socket
228+
if err := os.MkdirAll(shareDir+memifFilepath, os.ModePerm); err != nil {
229+
t.Fatal(err)
230+
}
231+
232+
// agent1 configuration
233+
vpp1Memif := &vpp_interfaces.Interface{
234+
Name: vpp1MemifName,
235+
Type: vpp_interfaces.Interface_MEMIF,
236+
Enabled: true,
237+
Link: &vpp_interfaces.Interface_Memif{
238+
Memif: &vpp_interfaces.MemifLink{
239+
Master: true,
240+
Id: 1,
241+
SocketFilename: shareDir + memifFilepath + memifSockname,
242+
},
243+
},
244+
}
245+
vpp1Subif1 := &vpp_interfaces.Interface{
246+
Name: vpp1Subif1Name,
247+
Type: vpp_interfaces.Interface_SUB_INTERFACE,
248+
Enabled: true,
249+
IpAddresses: []string{vpp1Subif1IP + netMask},
250+
Link: &vpp_interfaces.Interface_Sub{
251+
Sub: &vpp_interfaces.SubInterface{
252+
ParentName: vpp1MemifName,
253+
SubId: 10,
254+
TagRwOption: vpp_interfaces.SubInterface_POP1,
255+
},
256+
},
257+
}
258+
vpp1Subif2 := &vpp_interfaces.Interface{
259+
Name: vpp1Subif2Name,
260+
Type: vpp_interfaces.Interface_SUB_INTERFACE,
261+
Enabled: true,
262+
IpAddresses: []string{vpp1Subif2IP + netMask},
263+
Link: &vpp_interfaces.Interface_Sub{
264+
Sub: &vpp_interfaces.SubInterface{
265+
ParentName: vpp1MemifName,
266+
SubId: 20,
267+
TagRwOption: vpp_interfaces.SubInterface_POP1,
268+
},
269+
},
270+
}
271+
272+
// agent2 configuration
273+
vpp2Memif := &vpp_interfaces.Interface{
274+
Name: vpp2MemifName,
275+
Type: vpp_interfaces.Interface_MEMIF,
276+
Enabled: true,
277+
Link: &vpp_interfaces.Interface_Memif{
278+
Memif: &vpp_interfaces.MemifLink{
279+
Master: false,
280+
Id: 1,
281+
SocketFilename: shareDir + memifFilepath + memifSockname,
282+
},
283+
},
284+
}
285+
vpp2Subif1 := &vpp_interfaces.Interface{
286+
Name: vpp2Subif1Name,
287+
Type: vpp_interfaces.Interface_SUB_INTERFACE,
288+
Enabled: true,
289+
Link: &vpp_interfaces.Interface_Sub{
290+
Sub: &vpp_interfaces.SubInterface{
291+
ParentName: vpp2MemifName,
292+
SubId: 10,
293+
TagRwOption: vpp_interfaces.SubInterface_POP1,
294+
},
295+
},
296+
}
297+
vpp2Subif2 := &vpp_interfaces.Interface{
298+
Name: vpp2Subif2Name,
299+
Type: vpp_interfaces.Interface_SUB_INTERFACE,
300+
Enabled: true,
301+
Link: &vpp_interfaces.Interface_Sub{
302+
Sub: &vpp_interfaces.SubInterface{
303+
ParentName: vpp2MemifName,
304+
SubId: 20,
305+
TagRwOption: vpp_interfaces.SubInterface_POP1,
306+
},
307+
},
308+
}
309+
310+
vpp2Tap1 := &vpp_interfaces.Interface{
311+
Name: vpp2Tap1Name,
312+
Type: vpp_interfaces.Interface_TAP,
313+
Enabled: true,
314+
Link: &vpp_interfaces.Interface_Tap{
315+
Tap: &vpp_interfaces.TapLink{
316+
Version: 2,
317+
ToMicroservice: MsNamePrefix + ms1Name,
318+
},
319+
},
320+
}
321+
vpp2Tap2 := &vpp_interfaces.Interface{
322+
Name: vpp2Tap2Name,
323+
Type: vpp_interfaces.Interface_TAP,
324+
Enabled: true,
325+
Link: &vpp_interfaces.Interface_Tap{
326+
Tap: &vpp_interfaces.TapLink{
327+
Version: 2,
328+
ToMicroservice: MsNamePrefix + ms2Name,
329+
},
330+
},
331+
}
332+
333+
ms1Tap := &linux_interfaces.Interface{
334+
Name: ms1TapName,
335+
Type: linux_interfaces.Interface_TAP_TO_VPP,
336+
Enabled: true,
337+
IpAddresses: []string{ms1TapIP + netMask},
338+
HostIfName: msTapHostname,
339+
Link: &linux_interfaces.Interface_Tap{
340+
Tap: &linux_interfaces.TapLink{
341+
VppTapIfName: vpp2Tap1Name,
342+
},
343+
},
344+
Namespace: &linux_namespace.NetNamespace{
345+
Type: linux_namespace.NetNamespace_MICROSERVICE,
346+
Reference: MsNamePrefix + ms1Name,
347+
},
348+
}
349+
ms2Tap := &linux_interfaces.Interface{
350+
Name: ms2TapName,
351+
Type: linux_interfaces.Interface_TAP_TO_VPP,
352+
Enabled: true,
353+
IpAddresses: []string{ms2TapIP + netMask},
354+
HostIfName: msTapHostname,
355+
Link: &linux_interfaces.Interface_Tap{
356+
Tap: &linux_interfaces.TapLink{
357+
VppTapIfName: vpp2Tap2Name,
358+
},
359+
},
360+
Namespace: &linux_namespace.NetNamespace{
361+
Type: linux_namespace.NetNamespace_MICROSERVICE,
362+
Reference: MsNamePrefix + ms2Name,
363+
},
364+
}
365+
366+
bd1 := &vpp_l2.BridgeDomain{
367+
Name: bd1Name,
368+
Flood: true,
369+
Forward: true,
370+
Learn: true,
371+
Interfaces: []*vpp_l2.BridgeDomain_Interface{
372+
{
373+
Name: vpp2Subif1Name,
374+
},
375+
{
376+
Name: vpp2Tap1Name,
377+
},
378+
},
379+
}
380+
bd2 := &vpp_l2.BridgeDomain{
381+
Name: bd2Name,
382+
Flood: true,
383+
Forward: true,
384+
Learn: true,
385+
Interfaces: []*vpp_l2.BridgeDomain_Interface{
386+
{
387+
Name: vpp2Subif2Name,
388+
},
389+
{
390+
Name: vpp2Tap2Name,
391+
},
392+
},
393+
}
394+
395+
ctx.StartMicroservice(ms1Name)
396+
ctx.StartMicroservice(ms2Name)
397+
agent1 := ctx.Agent
398+
agent2 := ctx.StartAgent(agent2Name)
399+
400+
err := agent1.GenericClient().ChangeRequest().Update(
401+
vpp1Memif,
402+
vpp1Subif1,
403+
vpp1Subif2,
404+
).Send(context.Background())
405+
ctx.Expect(err).ToNot(HaveOccurred())
406+
err = agent2.GenericClient().ChangeRequest().Update(
407+
vpp2Memif,
408+
vpp2Subif1,
409+
vpp2Subif2,
410+
vpp2Tap1,
411+
vpp2Tap2,
412+
ms1Tap,
413+
ms2Tap,
414+
bd1,
415+
bd2,
416+
).Send(context.Background())
417+
ctx.Expect(err).ToNot(HaveOccurred())
418+
419+
if ctx.VppRelease() <= "21.01" {
420+
time.Sleep(5 * time.Second)
421+
}
422+
423+
// Check VPP1 value states
424+
ctx.Eventually(agent1.GetValueStateClb(vpp1Memif)).Should(Equal(kvscheduler.ValueState_CONFIGURED))
425+
ctx.Expect(agent1.GetValueState(vpp1Subif1)).To(Equal(kvscheduler.ValueState_CONFIGURED))
426+
ctx.Expect(agent1.GetValueState(vpp1Subif2)).To(Equal(kvscheduler.ValueState_CONFIGURED))
427+
// Check VPP2 value states
428+
ctx.Eventually(agent2.GetValueStateClb(vpp2Memif)).Should(Equal(kvscheduler.ValueState_CONFIGURED))
429+
ctx.Expect(agent2.GetValueState(vpp2Subif1)).To(Equal(kvscheduler.ValueState_CONFIGURED))
430+
ctx.Expect(agent2.GetValueState(vpp2Subif2)).To(Equal(kvscheduler.ValueState_CONFIGURED))
431+
ctx.Expect(agent2.GetValueState(ms1Tap)).To(Equal(kvscheduler.ValueState_CONFIGURED))
432+
ctx.Expect(agent2.GetValueState(ms2Tap)).To(Equal(kvscheduler.ValueState_CONFIGURED))
433+
ctx.Expect(agent2.GetValueState(vpp2Tap1)).To(Equal(kvscheduler.ValueState_CONFIGURED))
434+
ctx.Expect(agent2.GetValueState(vpp2Tap2)).To(Equal(kvscheduler.ValueState_CONFIGURED))
435+
// Pings from VPP should automatically go through correct vlan
436+
ctx.Expect(agent1.PingFromVPP(ms1TapIP)).To(Succeed())
437+
ctx.Expect(agent1.PingFromVPP(ms2TapIP)).To(Succeed())
438+
// Pings from correct vlan should succeed
439+
ctx.Expect(agent1.PingFromVPP(ms1TapIP, "source", "memif1/1.10")).To(Succeed())
440+
ctx.Expect(agent1.PingFromVPP(ms2TapIP, "source", "memif1/1.20")).To(Succeed())
441+
ctx.Expect(ctx.PingFromMs(ms1Name, vpp1Subif1IP)).To(Succeed())
442+
ctx.Expect(ctx.PingFromMs(ms2Name, vpp1Subif2IP)).To(Succeed())
443+
// Pings from incorrect vlan should fail
444+
ctx.Expect(agent1.PingFromVPP(ms1TapIP, "source", "memif1/1.20")).NotTo(Succeed())
445+
ctx.Expect(agent1.PingFromVPP(ms2TapIP, "source", "memif1/1.10")).NotTo(Succeed())
446+
ctx.Expect(ctx.PingFromMs(ms1Name, vpp1Subif2IP)).NotTo(Succeed())
447+
ctx.Expect(ctx.PingFromMs(ms2Name, vpp1Subif1IP)).NotTo(Succeed())
448+
}
449+
151450
// connect VPP with a microservice via TAP tunnel interface
152451
// TODO: fix topology setup for a traffic (ping) test
153452
func TestInterfaceTapTunnel(t *testing.T) {

tests/e2e/vppagent.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,16 @@ func (agent *Agent) ExecVppctl(action string, args ...string) (string, error) {
265265

266266
// PingFromVPPAsCallback can be used to ping repeatedly inside the assertions "Eventually"
267267
// and "Consistently" from Omega.
268-
func (agent *Agent) PingFromVPPAsCallback(destAddress string) func() error {
268+
func (agent *Agent) PingFromVPPAsCallback(destAddress string, args ...string) func() error {
269269
return func() error {
270-
return agent.PingFromVPP(destAddress)
270+
return agent.PingFromVPP(destAddress, args...)
271271
}
272272
}
273273

274274
// PingFromVPP pings <dstAddress> from inside the VPP.
275-
func (agent *Agent) PingFromVPP(destAddress string) error {
275+
func (agent *Agent) PingFromVPP(destAddress string, args ...string) error {
276276
// run ping on VPP using vppctl
277-
stdout, err := agent.ExecVppctl("ping", destAddress)
277+
stdout, err := agent.ExecVppctl("ping", append([]string{destAddress}, args...)...)
278278
if err != nil {
279279
return err
280280
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy