Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "time" |
| 5 | ) |
| 6 | |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 7 | const ( |
| 8 | // These correspond to names used in yaml config |
| 9 | serverInterfaceName = "vppsrv" |
| 10 | clientInterfaceName = "vppcln" |
| 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 |
| 28 | |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 29 | var sessionConfig Stanza |
| 30 | sessionConfig. |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 31 | newStanza("session"). |
| 32 | append("enable"). |
| 33 | append("use-app-socket-api").close() |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 34 | |
| 35 | // ... For server |
| 36 | serverContainer := s.getContainerByName("server-vpp") |
| 37 | |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 38 | cpus := s.AllocateCpus() |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 39 | serverVpp, err := serverContainer.newVppInstance(cpus, sessionConfig) |
| 40 | s.assertNotNil(serverVpp, err) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 41 | |
| 42 | s.setupServerVpp() |
| 43 | |
| 44 | // ... For client |
| 45 | clientContainer := s.getContainerByName("client-vpp") |
| 46 | |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 47 | cpus = s.AllocateCpus() |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 48 | clientVpp, err := clientContainer.newVppInstance(cpus, sessionConfig) |
| 49 | s.assertNotNil(clientVpp, err) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 50 | |
| 51 | s.setupClientVpp() |
| 52 | } |
| 53 | |
| 54 | func (s *VethsSuite) setupServerVpp() { |
| 55 | serverVpp := s.getContainerByName("server-vpp").vppInstance |
Filip Tehlar | 56e17cf | 2024-01-11 17:17:33 +0100 | [diff] [blame] | 56 | s.assertNil(serverVpp.start()) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 57 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 58 | serverVeth := s.netInterfaces[serverInterfaceName] |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 59 | idx, err := serverVpp.createAfPacket(serverVeth) |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 60 | s.assertNil(err, err) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 61 | s.assertNotEqual(0, idx) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | func (s *VethsSuite) setupClientVpp() { |
| 65 | clientVpp := s.getContainerByName("client-vpp").vppInstance |
Filip Tehlar | 56e17cf | 2024-01-11 17:17:33 +0100 | [diff] [blame] | 66 | s.assertNil(clientVpp.start()) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 67 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 68 | clientVeth := s.netInterfaces[clientInterfaceName] |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 69 | idx, err := clientVpp.createAfPacket(clientVeth) |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 70 | s.assertNil(err, err) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 71 | s.assertNotEqual(0, idx) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 72 | } |