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 |
| 5 | mirroringClientInterfaceName = "hst_client" |
| 6 | mirroringServerInterfaceName = "hst_server" |
| 7 | vppProxyContainerName = "vpp-proxy" |
| 8 | nginxProxyContainerName = "nginx-proxy" |
| 9 | nginxServerContainerName = "nginx-server" |
| 10 | ) |
| 11 | |
| 12 | type NginxSuite struct { |
| 13 | HstSuite |
| 14 | } |
| 15 | |
| 16 | func (s *NginxSuite) SetupSuite() { |
| 17 | s.loadNetworkTopology("2taps") |
| 18 | |
| 19 | s.loadContainerTopology("nginxProxyAndServer") |
| 20 | } |
| 21 | |
| 22 | func (s *NginxSuite) SetupTest() { |
Maros Ondrejicka | 7e1d6ef | 2023-02-28 19:40:09 +0100 | [diff] [blame] | 23 | s.skipIfUnconfiguring() |
| 24 | |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 25 | s.setupVolumes() |
| 26 | s.setupContainers() |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 27 | |
| 28 | // Setup test conditions |
| 29 | var startupConfig Stanza |
| 30 | startupConfig. |
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 | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 34 | |
| 35 | // ... for proxy |
| 36 | vppProxyContainer := s.getContainerByName(vppProxyContainerName) |
| 37 | proxyVpp, _ := vppProxyContainer.newVppInstance(startupConfig) |
| 38 | proxyVpp.start() |
| 39 | |
| 40 | clientInterface := s.netInterfaces[mirroringClientInterfaceName] |
| 41 | proxyVpp.createTap(clientInterface, 1) |
| 42 | |
| 43 | serverInterface := s.netInterfaces[mirroringServerInterfaceName] |
| 44 | proxyVpp.createTap(serverInterface, 2) |
| 45 | |
| 46 | nginxContainer := s.getTransientContainerByName(nginxProxyContainerName) |
| 47 | nginxContainer.create() |
Maros Ondrejicka | 85396a5 | 2023-02-28 12:49:43 +0100 | [diff] [blame] | 48 | |
| 49 | values := struct { |
| 50 | Proxy string |
| 51 | Server string |
| 52 | }{ |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 53 | Proxy: clientInterface.peer.ip4AddressString(), |
| 54 | Server: serverInterface.ip4AddressString(), |
Maros Ondrejicka | 85396a5 | 2023-02-28 12:49:43 +0100 | [diff] [blame] | 55 | } |
| 56 | nginxContainer.createConfig( |
| 57 | "/nginx.conf", |
| 58 | "./resources/nginx/nginx_proxy_mirroring.conf", |
| 59 | values, |
| 60 | ) |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 61 | nginxContainer.start() |
| 62 | |
Florin Coras | e2415f7 | 2023-02-28 14:51:03 -0800 | [diff] [blame] | 63 | proxyVpp.waitForApp("nginx-", 5) |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 64 | } |