Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | const ( |
| 4 | // These correspond to names used in yaml config |
adrianvillin | fbf5f2b | 2024-02-13 03:26:25 -0500 | [diff] [blame] | 5 | mirroringClientInterfaceName = "hstcln" |
| 6 | mirroringServerInterfaceName = "hstsrv" |
| 7 | vppProxyContainerName = "vpp-proxy" |
| 8 | nginxProxyContainerName = "nginx-proxy" |
| 9 | nginxServerContainerName = "nginx-server" |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 10 | ) |
| 11 | |
| 12 | type NginxSuite struct { |
| 13 | HstSuite |
| 14 | } |
| 15 | |
| 16 | func (s *NginxSuite) SetupSuite() { |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 17 | s.HstSuite.SetupSuite() |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 18 | s.loadNetworkTopology("2taps") |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 19 | s.loadContainerTopology("nginxProxyAndServer") |
| 20 | } |
| 21 | |
| 22 | func (s *NginxSuite) SetupTest() { |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 23 | s.HstSuite.SetupTest() |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 24 | |
| 25 | // Setup test conditions |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 26 | var sessionConfig Stanza |
| 27 | sessionConfig. |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 28 | newStanza("session"). |
| 29 | append("enable"). |
| 30 | append("use-app-socket-api").close() |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 31 | |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 32 | cpus := s.AllocateCpus() |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 33 | // ... for proxy |
| 34 | vppProxyContainer := s.getContainerByName(vppProxyContainerName) |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 35 | proxyVpp, _ := vppProxyContainer.newVppInstance(cpus, sessionConfig) |
Filip Tehlar | 56e17cf | 2024-01-11 17:17:33 +0100 | [diff] [blame] | 36 | s.assertNil(proxyVpp.start()) |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 37 | |
| 38 | clientInterface := s.netInterfaces[mirroringClientInterfaceName] |
Filip Tehlar | 56e17cf | 2024-01-11 17:17:33 +0100 | [diff] [blame] | 39 | s.assertNil(proxyVpp.createTap(clientInterface, 1)) |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 40 | |
| 41 | serverInterface := s.netInterfaces[mirroringServerInterfaceName] |
Filip Tehlar | 56e17cf | 2024-01-11 17:17:33 +0100 | [diff] [blame] | 42 | s.assertNil(proxyVpp.createTap(serverInterface, 2)) |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 43 | |
| 44 | nginxContainer := s.getTransientContainerByName(nginxProxyContainerName) |
| 45 | nginxContainer.create() |
Maros Ondrejicka | 85396a5 | 2023-02-28 12:49:43 +0100 | [diff] [blame] | 46 | |
| 47 | values := struct { |
| 48 | Proxy string |
| 49 | Server string |
| 50 | }{ |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 51 | Proxy: clientInterface.peer.ip4AddressString(), |
| 52 | Server: serverInterface.ip4AddressString(), |
Maros Ondrejicka | 85396a5 | 2023-02-28 12:49:43 +0100 | [diff] [blame] | 53 | } |
| 54 | nginxContainer.createConfig( |
| 55 | "/nginx.conf", |
| 56 | "./resources/nginx/nginx_proxy_mirroring.conf", |
| 57 | values, |
| 58 | ) |
Filip Tehlar | 56e17cf | 2024-01-11 17:17:33 +0100 | [diff] [blame] | 59 | s.assertNil(nginxContainer.start()) |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 60 | |
Florin Coras | e2415f7 | 2023-02-28 14:51:03 -0800 | [diff] [blame] | 61 | proxyVpp.waitForApp("nginx-", 5) |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 62 | } |