Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "time" |
| 5 | ) |
| 6 | |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 7 | // These correspond to names used in yaml config |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 8 | const ( |
adrianvillin | fbf5f2b | 2024-02-13 03:26:25 -0500 | [diff] [blame] | 9 | serverInterfaceName = "srv" |
| 10 | clientInterfaceName = "cln" |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 11 | ) |
| 12 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 13 | type VethsSuite struct { |
| 14 | HstSuite |
| 15 | } |
| 16 | |
| 17 | func (s *VethsSuite) SetupSuite() { |
| 18 | time.Sleep(1 * time.Second) |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 19 | s.HstSuite.SetupSuite() |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 20 | s.configureNetworkTopology("2peerVeth") |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 21 | s.loadContainerTopology("2peerVeth") |
| 22 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 23 | |
| 24 | func (s *VethsSuite) SetupTest() { |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 25 | s.HstSuite.SetupTest() |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 26 | |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 27 | // Setup test conditions |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 28 | var sessionConfig Stanza |
| 29 | sessionConfig. |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 30 | newStanza("session"). |
| 31 | append("enable"). |
| 32 | append("use-app-socket-api").close() |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 33 | |
| 34 | // ... For server |
| 35 | serverContainer := s.getContainerByName("server-vpp") |
| 36 | |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 37 | cpus := s.AllocateCpus() |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 38 | serverVpp, err := serverContainer.newVppInstance(cpus, sessionConfig) |
| 39 | s.assertNotNil(serverVpp, err) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 40 | |
| 41 | s.setupServerVpp() |
| 42 | |
| 43 | // ... For client |
| 44 | clientContainer := s.getContainerByName("client-vpp") |
| 45 | |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 46 | cpus = s.AllocateCpus() |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 47 | clientVpp, err := clientContainer.newVppInstance(cpus, sessionConfig) |
| 48 | s.assertNotNil(clientVpp, err) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 49 | |
| 50 | s.setupClientVpp() |
| 51 | } |
| 52 | |
| 53 | func (s *VethsSuite) setupServerVpp() { |
| 54 | serverVpp := s.getContainerByName("server-vpp").vppInstance |
Filip Tehlar | 56e17cf | 2024-01-11 17:17:33 +0100 | [diff] [blame] | 55 | s.assertNil(serverVpp.start()) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 56 | |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 57 | serverVeth := s.getInterfaceByName(serverInterfaceName) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 58 | idx, err := serverVpp.createAfPacket(serverVeth) |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 59 | s.assertNil(err, err) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 60 | s.assertNotEqual(0, idx) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | func (s *VethsSuite) setupClientVpp() { |
| 64 | clientVpp := s.getContainerByName("client-vpp").vppInstance |
Filip Tehlar | 56e17cf | 2024-01-11 17:17:33 +0100 | [diff] [blame] | 65 | s.assertNil(clientVpp.start()) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 66 | |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 67 | clientVeth := s.getInterfaceByName(clientInterfaceName) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 68 | idx, err := clientVpp.createAfPacket(clientVeth) |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 69 | s.assertNil(err, err) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 70 | s.assertNotEqual(0, idx) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 71 | } |