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) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 19 | |
| 20 | s.configureNetworkTopology("2peerVeth") |
| 21 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 22 | s.loadContainerTopology("2peerVeth") |
| 23 | } |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 24 | |
| 25 | func (s *VethsSuite) SetupTest() { |
Maros Ondrejicka | af004dd | 2023-02-27 16:52:57 +0100 | [diff] [blame^] | 26 | s.skipIfUnconfiguring() |
| 27 | |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 28 | s.SetupVolumes() |
| 29 | s.SetupContainers() |
| 30 | |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 31 | // Setup test conditions |
| 32 | |
| 33 | var startupConfig Stanza |
| 34 | startupConfig. |
| 35 | NewStanza("session"). |
| 36 | Append("enable"). |
| 37 | Append("use-app-socket-api").Close() |
| 38 | |
| 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 | |
| 56 | func (s *VethsSuite) setupServerVpp() { |
| 57 | serverVpp := s.getContainerByName("server-vpp").vppInstance |
| 58 | |
| 59 | err := serverVpp.start() |
| 60 | s.assertNil(err) |
| 61 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 62 | serverVeth := s.netInterfaces[serverInterfaceName] |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 63 | 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 | |
| 73 | func (s *VethsSuite) setupClientVpp() { |
| 74 | clientVpp := s.getContainerByName("client-vpp").vppInstance |
| 75 | |
| 76 | err := clientVpp.start() |
| 77 | s.assertNil(err) |
| 78 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 79 | clientVeth := s.netInterfaces[clientInterfaceName] |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 80 | 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 | } |