blob: be79ce250fb691ed211dd3fd5c07e0eb244985c8 [file] [log] [blame]
Maros Ondrejickadb823ed2022-12-14 16:30:04 +01001package main
2
3import (
4 "time"
5)
6
Maros Ondrejickaffa3f602023-01-26 10:07:29 +01007const (
8 // These correspond to names used in yaml config
9 serverInterfaceName = "vppsrv"
10 clientInterfaceName = "vppcln"
11)
12
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010013type VethsSuite struct {
14 HstSuite
15}
16
17func (s *VethsSuite) SetupSuite() {
18 time.Sleep(1 * time.Second)
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010019
20 s.configureNetworkTopology("2peerVeth")
21
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010022 s.loadContainerTopology("2peerVeth")
23}
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010024
25func (s *VethsSuite) SetupTest() {
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010026 s.skipIfUnconfiguring()
27
Maros Ondrejickae7625d02023-02-28 16:55:01 +010028 s.setupVolumes()
29 s.setupContainers()
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010030
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010031 // Setup test conditions
32
33 var startupConfig Stanza
34 startupConfig.
Maros Ondrejickae7625d02023-02-28 16:55:01 +010035 newStanza("session").
36 append("enable").
37 append("use-app-socket-api").close()
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010038
39 // ... For server
40 serverContainer := s.getContainerByName("server-vpp")
41
42 serverVpp, _ := serverContainer.newVppInstance(startupConfig)
43 s.assertNotNil(serverVpp)
44
45 s.setupServerVpp()
46
47 // ... For client
48 clientContainer := s.getContainerByName("client-vpp")
49
50 clientVpp, _ := clientContainer.newVppInstance(startupConfig)
51 s.assertNotNil(clientVpp)
52
53 s.setupClientVpp()
54}
55
56func (s *VethsSuite) setupServerVpp() {
57 serverVpp := s.getContainerByName("server-vpp").vppInstance
58
59 err := serverVpp.start()
60 s.assertNil(err)
61
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010062 serverVeth := s.netInterfaces[serverInterfaceName]
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010063 idx, err := serverVpp.createAfPacket(serverVeth)
64 s.assertNil(err)
65 s.assertNotEqual(0, idx)
66
67 namespaceSecret := "1"
68 err = serverVpp.addAppNamespace(1, idx, namespaceSecret)
69 s.assertNil(err)
70
71}
72
73func (s *VethsSuite) setupClientVpp() {
74 clientVpp := s.getContainerByName("client-vpp").vppInstance
75
76 err := clientVpp.start()
77 s.assertNil(err)
78
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010079 clientVeth := s.netInterfaces[clientInterfaceName]
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010080 idx, err := clientVpp.createAfPacket(clientVeth)
81 s.assertNil(err)
82 s.assertNotEqual(0, idx)
83
84 clientNamespaceSecret := "2"
85 err = clientVpp.addAppNamespace(2, idx, clientNamespaceSecret)
86 s.assertNil(err)
87}