blob: 94fd010814a18718c28c722dfe6fb2f75e30199f [file] [log] [blame]
Maros Ondrejickac2f76f42023-02-27 13:22:45 +01001package main
2
3const (
4 // These correspond to names used in yaml config
adrianvillinfbf5f2b2024-02-13 03:26:25 -05005 mirroringClientInterfaceName = "hstcln"
6 mirroringServerInterfaceName = "hstsrv"
7 vppProxyContainerName = "vpp-proxy"
8 nginxProxyContainerName = "nginx-proxy"
9 nginxServerContainerName = "nginx-server"
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010010)
11
12type NginxSuite struct {
13 HstSuite
14}
15
16func (s *NginxSuite) SetupSuite() {
Filip Tehlar608d0062023-04-28 10:29:47 +020017 s.HstSuite.SetupSuite()
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010018 s.loadNetworkTopology("2taps")
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010019 s.loadContainerTopology("nginxProxyAndServer")
20}
21
22func (s *NginxSuite) SetupTest() {
Filip Tehlar608d0062023-04-28 10:29:47 +020023 s.HstSuite.SetupTest()
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010024
25 // Setup test conditions
Filip Tehlar608d0062023-04-28 10:29:47 +020026 var sessionConfig Stanza
27 sessionConfig.
Maros Ondrejickae7625d02023-02-28 16:55:01 +010028 newStanza("session").
29 append("enable").
30 append("use-app-socket-api").close()
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010031
Filip Tehlar608d0062023-04-28 10:29:47 +020032 cpus := s.AllocateCpus()
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010033 // ... for proxy
34 vppProxyContainer := s.getContainerByName(vppProxyContainerName)
Filip Tehlar608d0062023-04-28 10:29:47 +020035 proxyVpp, _ := vppProxyContainer.newVppInstance(cpus, sessionConfig)
Filip Tehlar56e17cf2024-01-11 17:17:33 +010036 s.assertNil(proxyVpp.start())
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010037
38 clientInterface := s.netInterfaces[mirroringClientInterfaceName]
Filip Tehlar56e17cf2024-01-11 17:17:33 +010039 s.assertNil(proxyVpp.createTap(clientInterface, 1))
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010040
41 serverInterface := s.netInterfaces[mirroringServerInterfaceName]
Filip Tehlar56e17cf2024-01-11 17:17:33 +010042 s.assertNil(proxyVpp.createTap(serverInterface, 2))
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010043
44 nginxContainer := s.getTransientContainerByName(nginxProxyContainerName)
45 nginxContainer.create()
Maros Ondrejicka85396a52023-02-28 12:49:43 +010046
47 values := struct {
48 Proxy string
49 Server string
50 }{
Maros Ondrejickae7625d02023-02-28 16:55:01 +010051 Proxy: clientInterface.peer.ip4AddressString(),
52 Server: serverInterface.ip4AddressString(),
Maros Ondrejicka85396a52023-02-28 12:49:43 +010053 }
54 nginxContainer.createConfig(
55 "/nginx.conf",
56 "./resources/nginx/nginx_proxy_mirroring.conf",
57 values,
58 )
Filip Tehlar56e17cf2024-01-11 17:17:33 +010059 s.assertNil(nginxContainer.start())
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010060
Florin Corase2415f72023-02-28 14:51:03 -080061 proxyVpp.waitForApp("nginx-", 5)
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010062}