blob: 8593c88740afda77366e00d1cc841d026ce88106 [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)
Filip Tehlar608d0062023-04-28 10:29:47 +020019 s.HstSuite.SetupSuite()
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010020 s.configureNetworkTopology("2peerVeth")
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010021 s.loadContainerTopology("2peerVeth")
22}
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010023
24func (s *VethsSuite) SetupTest() {
Filip Tehlar608d0062023-04-28 10:29:47 +020025 s.HstSuite.SetupTest()
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010026
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010027 // Setup test conditions
28
Filip Tehlar608d0062023-04-28 10:29:47 +020029 var sessionConfig Stanza
30 sessionConfig.
Maros Ondrejickae7625d02023-02-28 16:55:01 +010031 newStanza("session").
32 append("enable").
33 append("use-app-socket-api").close()
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010034
35 // ... For server
36 serverContainer := s.getContainerByName("server-vpp")
37
Filip Tehlar608d0062023-04-28 10:29:47 +020038 cpus := s.AllocateCpus()
adrianvillin7c675472024-02-12 02:44:53 -050039 serverVpp, err := serverContainer.newVppInstance(cpus, sessionConfig)
40 s.assertNotNil(serverVpp, err)
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010041
42 s.setupServerVpp()
43
44 // ... For client
45 clientContainer := s.getContainerByName("client-vpp")
46
Filip Tehlar608d0062023-04-28 10:29:47 +020047 cpus = s.AllocateCpus()
adrianvillin7c675472024-02-12 02:44:53 -050048 clientVpp, err := clientContainer.newVppInstance(cpus, sessionConfig)
49 s.assertNotNil(clientVpp, err)
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010050
51 s.setupClientVpp()
52}
53
54func (s *VethsSuite) setupServerVpp() {
55 serverVpp := s.getContainerByName("server-vpp").vppInstance
Filip Tehlar56e17cf2024-01-11 17:17:33 +010056 s.assertNil(serverVpp.start())
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010057
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010058 serverVeth := s.netInterfaces[serverInterfaceName]
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010059 idx, err := serverVpp.createAfPacket(serverVeth)
adrianvillin7c675472024-02-12 02:44:53 -050060 s.assertNil(err, err)
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010061 s.assertNotEqual(0, idx)
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010062}
63
64func (s *VethsSuite) setupClientVpp() {
65 clientVpp := s.getContainerByName("client-vpp").vppInstance
Filip Tehlar56e17cf2024-01-11 17:17:33 +010066 s.assertNil(clientVpp.start())
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010067
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010068 clientVeth := s.netInterfaces[clientInterfaceName]
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010069 idx, err := clientVpp.createAfPacket(clientVeth)
adrianvillin7c675472024-02-12 02:44:53 -050070 s.assertNil(err, err)
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010071 s.assertNotEqual(0, idx)
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010072}